Quality control of labelled sulci

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

Quality control of labelled sulci

Post by f4bry »

Hi,
I would like to perform a quality control of left/right labelled sulci.
In my previous posts I asked how to take snapshots of the graphs and this method works (thanks!).

The 'problem' now is that I'd like to run the sulci labelling and QC a large number of subjects and I would like to run both processes on a server, without opening any window for the snapshots.
I can run the brainvisa scripts for the sulci extraction and labelling using command lines (without setting the brainvisa database) and this works fine.

Is there a way to save graphs images without using the GUI? Do you think this will be a good method for QC? Is it possible to save (as .jpeg or similar) graphs objects using some matplotlib function or others?

Thank you!
Fab
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quality control of labelled sulci

Post by riviere »

Hi,

The problem of off-screen rendering using OpenGL is not so simple. There are several ways, but none will work out of the box.

One is to program a special "off-screen rendering" feature in Anatomist, it would require specific programming, using OSMesa lib (or maybe just a framebuffer object?), and probably turning all anatomist into a special mode which would then not allow regular rendering at all because rendering contexts would not be compatible with real screen rendering in this case.

Another would be to run anatomist in a "virtual" X server, which would need to be installed on the server. xvfb does apparently not support GLX (openGL rendering) (not sure of that, actually), but we could work using xpra/Xdummy and virtualgl (xpra is in Ubuntu distribs for instance, but virtualgl is not, but it's rather easy to install). See http://xpra.org/trac/wiki/Xdummy for explanations.
Then you could run the sulci rendering process in batch mode, using vglrun + the axon-runprocess script.
This second solution has the (large) advantage of being able to use the regular, unmodified brainvisa/anatomist.
As I understand xpra still needs the server machine to be able to render X and OpenGL (X11 installed? and working OpenGL library), so it might not run on every server.
So a typical script could look like:

Code: Select all

# run virtual X, as in http://xpra.org/trac/wiki/Xdummy
xpra --xvfb="Xorg -noreset -nolisten tcp +extension GLX \
    -config /etc/xpra/xorg.conf \
    +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg-10.log"     start :100
# switch to the virtual screen
export DISPLAY=:100
# run the rendering process
vglrun axon-runprocess --enabledb multiSubjectSulciSnapshotBoard graphs="['/home/gollum/bv_data/subjects/bd090157/t1mri/mprage_3t/default_analysis/folds/3.1/default_session_auto/Lbd090157_default_session_auto.arg', '/home/gollum/bv_data/subjects/bd090157/t1mri/mprage_3t/default_analysis/folds/3.1/default_session_auto/Rbd090157_default_session_auto.arg']" output_image=/tmp/snapshot2.jpg
# stop xpra (if not needed any longer)
xpra exit
It should be possible to use this virtual screen config for all remote distributed processing in brainvisa (via soma-workflow), if xpra is running on the server side, and the login/ssh config (.bash_profile) sets the DISPLAY=:100 variable.
In principle the virtual X server xpra could run on another machine, or a cluster front-end machine, if it cannot run on cluster nodes. Each node should have client X libs, however.

We have found this solution just a few days ago (because we have the same questions here), and I have not explored yet all the possible ways to use it...
Is it possible to save (as .jpeg or similar) graphs objects using some matplotlib function or others?
Matplotlib can display existing images (jpegs or others) or display images built "by hand" or show arrays, but cannot directly display sulci, and has no 3D OpenGL features (as I know).

Denis
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

Re: Quality control of labelled sulci

Post by f4bry »

Hi Denis,

I am trying the second option you proposed, running BrainVISA 4.4.0 on Ubuntu 14.04, installed using VirtualBox 5.0.14 (host: Mac OS X 10.11.3). I can work with the BrainVISA GUI disabling the VirtualBox 3D acceleration and the BrainVISA's libstdc++.so.6

Installing virtualgl, and running exactly the script that you posted, I've got the errors that you can see in the attachment. And these are the same errors that I obtain if I run the multisubject snapshot tool from the GUI.

Do you know how can I fix these errors?

Thank you very much!
Fab
Attachments
multisubjectsnapshot_log.txt
(8.19 KiB) Downloaded 339 times
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quality control of labelled sulci

Post by riviere »

Well, the messages "couldn't read /home/username/Applications/brainvisa/share/brainvisa-share-4.4/nomenclature/syntax/adap.stx" and simimar are highly doubtful, I guess that the sulci graphs could not be read in this situation.
How did you call the brainvisa process ?
vglrun /home/username/Applications/brainvisa/bin/axon-runprocess ... ?

Can you remind me why you had to remove the libstdc++ from Brainvisa ? I know that in some situations you might have to do so, but I don't remember all, and it could possibly be the cause of the error messages.

I have just tried it on my side (Ubuntu 14.04 also, but not in a VM) using the binary distribution of BV 4.4. (I left the libstdc++ lib in BV). I don't have these messages (even if I have the fontconfig warnings). The process runs without error, but it writes blank image at the end. Using the (still beta) 4.5 version all is well. However the snapshot script has not changed. So either a change in anatomist has induced a different behaviour (but I don't know why), or one of the libraries have changed (maybe the PIL module in python).

To find it out, I have tried the following anatomist script (I saved it as /tmp/testana.py):

Code: Select all

#!/usr/bin/env python

import anatomist.api as ana

# please replace here the file name
filename = '/volatile/riviere/basetests-3.1.0/subjects/101/t1mri/default_acquisition/default_analysis/folds/3.1/default_session_auto/L101_default_session_auto.arg'
snapshot_file = '/tmp/snapshot.jpg'

a = ana.Anatomist('-b')
obj = a.loadObject(filename)
w = a.createWindow('3D')
w.addObjects(obj)
a.execute('WindowConfig', windows=[w], snapshot=snapshot_file)
run via the command:

Code: Select all

vglrun <path_to_brainvisa_4.4>/bin/bv_env python /tmp/testana.py
And it produced a valid image (using BV 4.4 binary distrib). Thus for me, the problem is not in Anatomist.
Could you please try it, to see if it gets to the same point ? (don't forget to change the file name(s)

Denis
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

Re: Quality control of labelled sulci

Post by f4bry »

Hi Denis,

I removed the libstdc++ from Brainvisa as described here http://brainvisa.info/forum/viewtopic.php?f=2&t=1745
Yes, I was running the script as you said: vglrun /home/username/Applications/brainvisa/bin/axon-runprocess ...

Running your script 'testana.py' , with the libstdc++, and activating the VM 3D accelerator (so, closer to your setting if I well understood), I have these errors:

Code: Select all

vglrun /home/username/Applications/brainvisa/bin/bv_env python /home/username/Documents/testana.py
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 78: saw unknown, expected number
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 14: invalid constant used : lcddefault
Starting Anatomist.....
config file : /home/username/.anatomist/config/settings.cfg
PyAnatomist Module present
global modules: /home/username/Application/brainvisa/share/anatomist-4.4/python_plugins
home   modules: /home/username/.anatomist/python_plugins
loading module meshsplit
loading module foldsplit
loading module palettecontrols
loading module histogram
loading module selection
loading module paletteViewer
loading module volumepalettes
loading module intermeas
loading module gradientpalette
loading module profilewindow
loading module bsa_proba
loading module anacontrolmenu
loading module modelGraphs
all python modules loaded
<H1>Anatomist launched</H1>
Reading FGraph version 3.1
bounding box found : 121, 51, 34
                     193, 227, 154
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200001
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200001
X Error: BadValue (integer parameter out of range for operation) 2
  Extension:    154 (Uknown extension)
  Minor opcode: 24 (Unknown request)
  Resource id:  0x0
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200002
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200002
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)

I should be able to run 'testana.py' without vglrun, right?
Doing that I obtain several times this:

Code: Select all

QGLContext::makeCurrent(): Failed.
GLList::generate() could not allocate OpenGL display list: no error
cleaning and trying again...
OpenGL lists cleanup...
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 5 (Unknown request)
  Resource id:  0x4200062
X Error: 0 0
  Extension:    154 (Uknown extension)
  Minor opcode: 26 (Unknown request)
  Resource id:  0x0
QGLContext::makeCurrent(): Failed.
and then the follwing:

Code: Select all

##### ANATOMIST ERROR
Light::RefreshGLList : OpenGL error in glGenLists.
-----------------------------------------------------------
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 5 (Unknown request)
  Resource id:  0x4200062
X Error: 0 0
  Extension:    154 (Uknown extension)
  Minor opcode: 26 (Unknown request)
  Resource id:  0x0
QGLContext::makeCurrent(): Failed.
~GLList : Bad GL list - 0
username@username:~$ vglrun ~/Application/brainvisa/bin/bv_env python ~/Documents/testana.py
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 78: saw unknown, expected number
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 14: invalid constant used : lcddefault
Starting Anatomist.....
config file : /home/username/.anatomist/config/settings.cfg
PyAnatomist Module present
global modules: /home/username/Application/brainvisa/share/anatomist-4.4/python_plugins
home   modules: /home/username/.anatomist/python_plugins
loading module meshsplit
loading module foldsplit
loading module palettecontrols
loading module histogram
loading module selection
loading module paletteViewer
loading module volumepalettes
loading module intermeas
loading module gradientpalette
loading module profilewindow
loading module bsa_proba
loading module anacontrolmenu
loading module modelGraphs
all python modules loaded
<H1>Anatomist launched</H1>
Reading FGraph version 3.1
bounding box found : 121, 51, 34
                     193, 227, 154
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200001
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200001
X Error: BadValue (integer parameter out of range for operation) 2
  Extension:    154 (Uknown extension)
  Minor opcode: 24 (Unknown request)
  Resource id:  0x0
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200002
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4200002
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)
Thank you!
Fab
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quality control of labelled sulci

Post by riviere »

So in neither case OpenGL is working. Maybe you should not activate 3D hardware acceleration, it seems not to be working in your VM (it might require a special virtual driver).
What does it do without hardware rendering ?

OK I remember why you removed libstdc++, now. But I'm still puzzled about the errors reading the .stx files.

Denis
f4bry
Posts: 29
Joined: Wed Mar 25, 2009 1:46 pm

Re: Quality control of labelled sulci

Post by f4bry »

Hi,
Without 3D hardware acceleration I got:

Code: Select all

vglrun /home/username/Applications/brainvisa/bin/bv_env ~/Applications/brainvisa/bin/python /home/username/Documents/testana.py

Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 70: non-double matrix element
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 78: saw unknown, expected number
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 14: invalid constant used : lcddefault
Starting Anatomist.....
config file : /home/username/.anatomist/config/settings.cfg
PyAnatomist Module present
global modules: /home/username/Applications/brainvisa/share/anatomist-4.4/python_plugins
home   modules: /home/username/.anatomist/python_plugins
loading module meshsplit
loading module foldsplit
loading module palettecontrols
loading module histogram
loading module selection
loading module paletteViewer
loading module volumepalettes
loading module intermeas
loading module gradientpalette
loading module profilewindow
loading module bsa_proba
loading module anacontrolmenu
loading module modelGraphs
all python modules loaded
<H1>Anatomist launched</H1>
Reading FGraph version 3.1
bounding box found : 121, 51, 34
                     193, 227, 154
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
pci id for fd 12: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4400001
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4400001
X Error: BadValue (integer parameter out of range for operation) 2
  Extension:    154 (Uknown extension)
  Minor opcode: 24 (Unknown request)
  Resource id:  0x0
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4400002
[VGL] WARNING: The OpenGL rendering context obtained on X display
[VGL]    :0 is indirect, which may cause performance to suffer.
[VGL]    If :0 is a local X display, then the framebuffer device
[VGL]    permissions may be set incorrectly.
X Error: GLXBadContext 169
  Extension:    154 (Uknown extension)
  Minor opcode: 6 (Unknown request)
  Resource id:  0x4400002
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python2.7: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)
But, I had the chance to test your script on the server, not VM, and it works! Unfortunately xpra and virtualGL are not installed yet.
I also tried on the local machine (Mac OS X 10.11.3) and it works!!

So, I think you are right, the VM is not well configured.
I hope to have xpra and virtual GL installed soon on the server to be able to work on it.

Thank you very much!
Fab
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Quality control of labelled sulci

Post by riviere »

I haven't tried this kind of configuration actually.
Maybe VirtualGL is not working properly in this VM environment.
You could try it without the virtual X server xpra, to see if rendering works or not (with or without hardware rendering).
And in this situation with software rendering, maybe virtualGL is not needed (?), you coulsd also try anatomist in xpra (without virtualGL) ?
Denis
Post Reply