Error in brainvisa-4.6.0/python/brainvisa/processes.py

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

Hello

We have code calling FreeSurfer functions with launchFreesurferCommand > context.system > _system.
None of the functions called return properly, because line 3454 returns an error.

On my configuration, neuroConfig.brainvisaSysEnv.getVariables() returns None, and own_env.update() is not equipped to handle this.
I fixed this temporarily by replacing line 3453 with:

Code: Select all

    if neuroConfig.brainvisaSysEnv and neuroConfig.brainvisaSysEnv.getVariables() is not None:
Am I doing something wrong?

Thanks
Francois
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

Btw, is this forum the appropriate channel to report this kind of issues?
Or do you have a github on which I could submit issues, or some other bug tracking system?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by riviere »

Hi François,

Your fix is OK, but I find it simpler if this env dict is never None, so I suggest a different fix which would initialize it with an empty dict rather than None.
You can try putting this file at the same location in your brainvisa installation (python/soma/):
ftp://ftp.cea.fr/pub/dsv/anatomist/upda ... oma/env.py

I just wonder how you end up with something empty here: if you are using a binary distribution install, the startup scripts should setup some variables here (to save values of the initial environment actually before it is modified to point to brainvisa paths).

What is the appropriate channel for this kind of issues ? Well, it's still not very clear: this forum is for discussing problems so it is OK to report them here (anyway It seems that I am now the only person who answers questions, not all of them because I don't always have time and then often forget). We have a bug tracker of course but it is not on github, it is on a sources repository which is hosted by our institution, and has only an access with a login (even in read-only mode, which is really a problem). To counter this problem, we have setup a "public" login/password that anyone can use to browse the sources and issues of the open-source projects:

https://bioproj.cea.fr
login: brainvisa
password: Soma2009

Now if you wish to contribute and submit fixes, we would be OK to open an account for you (and happy to have contributors), but working with the sources is more work...

Denis
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

Thanks for the fix and for the info.
If it's OK, I'll stick to posting public messages on this forum for now then.

I got to this point by starting IntrAnat (this SEEG toolbox developed in Grenoble) from the Eclipse/PyDev debugger. So I guess this is why it doesn't initialize everything as expected. But expect for this, so far it seems to work OK.

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

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by riviere »

Oh OK it's less mysterious this way...
I haven't looked how Intranat sets up its environment, if it does or not by itself, or if it is because you maybe run the python scripts directly from Eclipse, bypassing the startup shell scripts which setup the environment (bin/bv_env). Anyway if it works this way it's OK.
Denis
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

Maybe related also with the way I start BrainVISA...
After installing/updating some Ubuntu packages, I get lost of errors when BrainVISA starts. Example:

Code: Select all

OSError
processes.py (5989) in addDir:
toolbox=toolbox) # two arguments : process fullpath and category (directories
separated by /)
processes.py (5586) in readProcess:
moduleName, fileIn, fileName, moduleDescription)
mpegEncode_recmpeg.py (35) in <module>:
from brainvisa.configuration import mpegConfig
mpegConfig.py (151) in <module>:
codecs = findCodecs()
mpegConfig.py (145) in findCodecs:
c[ x ] = findCodec( x )
mpegConfig.py (103) in findCodec:
stderr=subprocess.PIPE )
subprocess.py (679) in __init__:
errread, errwrite)
subprocess.py (1249) in _execute_child:
raise child_exception
ERROR [Errno 2] No such file or directory
It is raised every time the module mpegConfig is imported (brainvisa.configuration).
If comes from line 101 in mpegConfig.py:

Code: Select all

      sproc = subprocess.Popen( ( 'bv_unenv', encoder, '-codecs' ),
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE )
It doesn't prevent the rest of the code to run, but it is quite inaesthetic.
What would be a graceful fix for this?

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

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by riviere »

It seems related to the previous problem. It cannot find bv_unenv in the PATH. However this bv_unenv program should be in the bin/ directory of brainvisa. If it is not (or if it does not have execute permission), then it's probably an install problem. If it is actually here, then it's a PATH problem.
How have you intalled BV, and how do you start it ?
Does it work better if you start it by running <bv_dir>/bin/bv_env <program>, instead of <program> or <path_to>/<program> ?
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

I added brainvisa/bin to the PATH variable and the errors are gone.
It's surprising it didn't cause any problem before... I think I started getting this issue after installing ffmpeg.

We do not start the BrainVISA interface from a terminal.
Various BrainVISA modules are imported in our Python code, and the first BrainVISA call seems to be: axon.initializeProcesses()
(the errors where coming from there)

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

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by riviere »

OK. Normally the "best way" is either to source the bv_env.sh script in the terminal before running any program in the brainvisa distriution, or run them through the bv_env program (without .sh extension). They setup all needed environment variables both to set BV environment, and to get out of it when BV needs to run commands "outside" its distribution (external or system programs). Programs in the main BV distribution do it automatically since everything you find in bin/ is precisely a scripts which runs this bv_env program, but maybe the start script of Intranat was not installed this way.
francois
Posts: 63
Joined: Tue Jul 25, 2017 9:37 am

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by francois »

I'm running this from my PyDev debugger.
In the configuration of my interpreter I added brainvisa folders to my python path, $PATH and $LD_LIBRARY_PATH until it works.
Would you suggest a nicer way of proceeding?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Error in brainvisa-4.6.0/python/brainvisa/processes.py

Post by riviere »

As long as you've found a configuration that works for you, I would say it's OK. But bv_env sets some additional env variables in order to find its internal data (normally optional, it can find data by other paths when the install is organized the standard way), and also some variables to save the state of previous paths, which can be reset to their original values when calling some "external" commandlines, such as the mpeg encoders in your previous posts, or FLS/FreeSurfer, matlab, or anything else. The reason for this is that BV comes with "system" libraries which are built on a given OS (depending on the variant you have installed, Mandriva 2008, Ubuntu 12.04 or 16.04...) which dowork with brainvisa compiled on this "foreign" system, but may not work with programs from your host system. So BV can go back to the host system environment when needed, using these original path variables values. That's why the recommended way to set variables is to use bv_env / bv_env.sh.
You can see what is actually done by running "bv_env" alone (without arguments).
If you are running the same OS as the one used in the BV distribnution you have installed, there should be no problem.
Denis
Post Reply