Freesurfer is not identified in BrainVISA

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

Dear BrainVisa users,

I would like to use the MarsAtlas to parcellate an individual MRI. I ran the command recon-all in Freesurfer and I've encountered problems with the Freesurfer/Brainvisa interface and I hope that you can help me with it.

Some functions in the Freesurfer toolbox within BrainVisa are greyed out, and when I try to import the results from the Freesurfer pipeline, I get an error indicating that the Freesurfer was not found. So, this is the description of the problem:

- The Freesurfer environment is defined in the bashrc file.
- The userlevel in BrainVisa is set to Expert.
- Brainvisa and Freesurfer are both installed in the folder /usr/local/
- When I go to BrainVisa--> Preferences --> Freesurfer, every time I run BrainVisa, I have to define the HOME and SUBJECTS_DIR of Freesurfer.
- I do not receive any warning in the terminal when BrainVisa is open.
- A recommendation from a previous post in the forum (http://brainvisa.info/forum/viewtopic.php?t=1746) was to take out the libstdc* library, although, unlike said post, I don’t receive any warnings in the terminal when I run BrainVisa. I removed it but I have the same problem.
- When I go to Brainvisa--> Show Log--> BrainVisa session --> Read processes, for some functions of Freesurfer, it says:

Code: Select all

The process freesurfer/processes/Tools/freesurferPipeline.py is not available: FreeSurfer not available. 
​ValidationError
processes.py (4371) in readProcess: 
raise ValidationError(HTMLMessage("The process <em>"+relative_path(processInfo.fileName, neuroConfig.toolboxesDir)+"</em> is not available: <b>"+unicode(e)+"</b>"))
The processes showing this error are: freesurferPipelineComplete.py , freesurferPipeline.py , freesurferMgzToNifti.py , freesurferNiftiToMgz.py , freesurferAverageSubjectLongitudinal.py , freesurferLongitudinalPipeline.py

I’m running BrainVISA 4.5.0 in Ubuntu 12.04, which is running in a virtual machine in a Windows laptop.

Please let me know if you have any ideas.

Best regards,

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

Re: Freesurfer is not identified in BrainVISA

Post by riviere »

Hi Laura,
Well the key of the problem is probably in why the freesurfer config in preferences goes away. I think it is not saved because it is not considered valid, and we have to understand why.
In the "freesurfer_home_path" directory (FS install directory), do you have the script FreeSurferEnv.sh ?
Or, I remember fixing something in the freesurfer config after release 4.5.0, because it ran the script FreeSurferEnv.sh without enforcing the FREESURFER_HOME environment variable, thus it was assuming this variable was already set before running brainvisa, otherwise it would not work.
You can try the patch here:
ftp://ftp.cea.fr/pub/dsv/anatomist/upda ... esurfer.py
save it in <brainvisa_dir>/python/freesurfer/ (overwrite the older one)
and please tell me if it works better or not.
Regards,
Denis
LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Re: Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

Dear Denis,

Thank you for your quick reply. However I'm still not able to solve this issue. To answer your questions:
- There is a FreeSurferEnv.csh and FreeSurferEnv.sh file in the freesurfer directory. I defined the Freesurfer home path in the .bashrc and the respective message shows up every time a open a new terminal, indicating that the Freesurfer environment is properly defined (as far as I know).
- I saved the brainvisaFreesurfer.py that you provided in the /usr/local/brainvisa/python/freesurfer/ folder. I reopened BrainVISA but nothing changed.

I have installed Freesurfer stable v6.0. Maybe this newest version has another change in the definition of variables? Please let me know what you think.


Best regards,

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

Re: Freesurfer is not identified in BrainVISA

Post by riviere »

Hi,
We are also using Freesurfer 6 so this should not be a problem.
  • Checking the code I see that paths are not checked while setting the configuration, so it does not explain why freesurfer config is not saved. Can you check that you have write permission on the file $HOME/.brainvisa/options.minf ? You can also change there the paths directly there (look for the "freesurfer_home_path" entry), save the file and try restarting brainvisa.
  • then we can try to investigate what happens during freesurfer detection test. Can you please replace the (same) brainvisaFreesurfer.py (in python/freesurfer) by this modified one: ftp://ftp.cea.fr/pub/dsv/anatomist/tmp/ ... esurfer.py, then restart brainvisa, and tell what prints in the terminal running brainvisa at startup ? The modified script just prints what it does during the freesurfer test, so we could understand where it goes wrong.
Denis
User avatar
Olivier Coulon
Posts: 176
Joined: Fri Feb 27, 2004 11:48 am
Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by Olivier Coulon »

Hello Denis,
just to add some information: I exchanged a few emails with laura and it turns out that the .brainvisa/options.minf contains the freesurfer paths, so it is even stranger that they do not appear in the preferences.
Also, about the freesurfer version: I am using FS 6.0 on a machine here and I do not encounter the same problem...

Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Re: Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

Dear Denis,

Thank you for taking the time to look into this.
To answer your questions, I usually run BrainVISA as sudo. After saving the last script you provided, I obtain the following message in the terminal when running BrainVISA:

Code: Select all

launchFreesurferCommand
freesurfer_home_path: None
FreeSurferEnv.sh not found, looking for mri_convert
mri_convert not found, searching for FreeSurferEnv.sh in path
could not find FreeSurferEnv.sh
Traceback (most recent call last):
  File "/usr/local/brainvisa/python/freesurfer/brainvisaFreesurfer.py", line 23, in testFreesurferCommand
    launchFreesurferCommand(context, None, 'mri_convert', '-h')
  File "/usr/local/brainvisa/python/freesurfer/brainvisaFreesurfer.py", line 108, in launchFreesurferCommand
    raise ValidationError( 'FreeSurfer is not available' )
ValidationError: FreeSurfer is not available
So there's no freesurfer path even though it is defined in the options.minf file:

Code: Select all

<d><d name="freesurfer">
<s name="subjects_dir_path">/usr/local/freesurfer/subjects</s>
<s name="freesurfer_home_path">/usr/local/freesurfer</s></d>
I hope this might give you an idea.

Best regards,

Laura
User avatar
Olivier Coulon
Posts: 176
Joined: Fri Feb 27, 2004 11:48 am
Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by Olivier Coulon »

Hello Laura,
you wrote this:
I usually run BrainVISA as sudo
This might be the source of your problem. You don't need to run it with sudo. Just type:

Code: Select all

/usr/local/brainvisa/BrainVISA
(if the install directory is not '/usr/local/brainvisa', change it accordingly, e.g. '/usr/local/brainvisa-4/5/0/BrainVISA')
that should be enough and might solve your problem. Let us know.

Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Re: Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

That was then another rookie mistake. Now it is identified and all the functions are activated. Thank you for your help!

Best regards,

Laura
User avatar
Olivier Coulon
Posts: 176
Joined: Fri Feb 27, 2004 11:48 am
Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by Olivier Coulon »

Great, I'm glad it works.

Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
User avatar
Olivier Coulon
Posts: 176
Joined: Fri Feb 27, 2004 11:48 am
Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by Olivier Coulon »

Hello,
although the initial problem has been solved, I am sending a follow up because we seem to have an issue with the Freesurfer toolbox and FS6.0.

Both laura and I encountered the same problem using FS6.0. The main FS pipeline is working fine but when using the 'Import FreeSurfer grey/white segmentation to Morphologist' process we get the message below. I'll try to have a closer look at it but I thought I could post it here just in case:
Launch T1BiasCorrection
Launch VipGreyStatFromClassif to generate a histo analysis file
Now run the last part of the regular Morphologist pipeline.
ERROR
in Import FreeSurfer grey/white segmentation to Morphologist 4 Renorm
The log shows the following:
Renorm
AttributeError
processes.py (2725) in _processExecution:
result = process.execution( self )
Import_FROM_FreeSurfer_TO_Morpho.py (323) in execution:
enode.Renorm.setSelected( False )
processes.py (1799) in __getattr__:
raise AttributeError( attribute )
Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Re: Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

Dear all,

I still can't solve the issue. I decided to start from scratch running the FS pipeline in Brainvisa. I created a new database and selected the raw T1 from there. I removed FS 6.0 and installed FS 5.3, and changed the bashrc file accordingly. As a test, I ran the freeview with a sample image from FS. FS path is identified as all the options for the FS toolbox within BV are available now. When I run the Freesurver/Brainvisa full pipeline I obtain the following error:

Code: Select all


FreeSurfer not available or one freesurfer command line has failed. Please see the log file in the main menu of BrainVISA for more information. 

ValidationError
processes.py (2725) in _processExecution: 
result = process.execution( self )
processes.py (1302) in execution: 
return self._executionNode.run( context )
processes.py (1837) in run: 
return self._run( context )
processes.py (2167) in _run: 
result.append( node.run( context ) )
processes.py (1837) in run: 
return self._run( context )
processes.py (2054) in _run: 
return context.runProcess( self._process )
processes.py (2483) in runProcess: 
result = self._processExecution( _process, None )
processes.py (2725) in _processExecution: 
result = process.execution( self )
freesurferPipeline.py (149) in execution: 
launchFreesurferCommand(context, database, *args, **kwargs)
brainvisaFreesurfer.py (120) in launchFreesurferCommand: 
raise ValidationError( 'FreeSurfer not available or one freesurfer command line has failed. Please see the log file in the main menu of BrainVISA for more information.' )
Does anybody have any ideas as to what could be happening here?

THank you in advance for any comment or suggestion!

Best regards,

Laura
LauraR_15
Posts: 6
Joined: Tue Apr 18, 2017 2:03 pm

Re: Freesurfer is not identified in BrainVISA

Post by LauraR_15 »

Dear BrainVisa users,

I somehow solved my problem, although I still don't know what's causing it. I re-ran everything using FS 5.3, separately from BV. I then imported the FS results to BV, and commented the line 323 from Import_FROM_FreeSurfer_TO_Morpho.py:

Code: Select all

# enode.Renorm.setSelected( False )
This line (and the ones above) is telling Morphologist to skip some steps, so I thought the rest could work without it. And it did. So maybe the experts could look into that call.

I would like to thank you all for your help on this issue.

Best regards,

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

Re: Freesurfer is not identified in BrainVISA

Post by riviere »

Hi,

sorry for the late answer, it seems that the forum notification has somewhat failed, I haven't noticed all the recent messages...

Is there really a difference if you are using FS 6 or 5.x ? The error you get seems to be in setting up the Morphologist pipeline, and the only reasonable explanation (not completely reasonable actually in my mind) of the error on the "enode.Renorm.setSelected()" line seems to be that the "renormalization" sub-pipeline is not present or not valid. It is here when you open the standard Morphologist pipeline ? The sub-pipeline in itself can be found in morphologist/registration/Skull-stripped brain normalization, and its validation should be the same as the normalization pipeline, and... yes maybe I have a clue. The normalization pipeline is mainly based on external software: it can use SPM, FSL, or even Baladin, or the internal command AimsMIRegister. But the last method is really a fallback when no other is available (it lacks robustness) and has been added afterwards. But I see that the noralization pipeline validation function has not been updated to take it into account, so if neither SPM nor FSL is setup in your preferences, the whole normalization pipelines should be disabled. This should be easily visible in the regular Morphologist pipeline.
I'll post a fix for it.
Denis
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by riviere »

OK I have made a patch. You can try replacing <brainvisa>/brainvisa/toolboxes/morphologist/processes/registration/normalizationPipeline.py by this one:
ftp://ftp.cea.fr/pub/dsv/anatomist/upda ... ipeline.py

Anyway as I said just before, the AimsMIRegister method is just a fallback, it's better to have SPM installed and setup in BV preferences.
Denis
User avatar
Olivier Coulon
Posts: 176
Joined: Fri Feb 27, 2004 11:48 am
Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
Contact:

Re: Freesurfer is not identified in BrainVISA

Post by Olivier Coulon »

Hello Denis,
what is the use of the renormalization process. I am asking because several collaborators encountered the problem. Your patch solves it but I am thinking about the consequences of using AimsMIRegister if the process that is not very robust.
Thanks,
Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
Post Reply