-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide more helpful error message if FreeSurfer executables cannot be found; consider amending install docs #12917
Comments
Can you check for example
do you get the help info? |
Yes, the file is there: /Applications/freesurfer/7.4.1/bin/mri_watershed |
Sorry if this is a bit annoying, but did you literally try to run |
This is what I tried:
|
No what I meant is, if you open a terminal in VS Code (assuming you're using VS Code to run your script?), just run:
Does that work? |
Is this supposed to work? I would always do it as: import os
os.environ["FREESURFER_HOME"] = ... Or actually … I would ensure that the env var is set correctly even before I start Python :) |
just running mri_watershed in the VScode terminal: not found I got the set_config command from here: https://mne.tools/0.22/auto_tutorials/source-modeling/plot_background_freesurfer.html?highlight=mne%20set_config%20freesurfer_home but using the os.environment gives the same error
|
This indicates a setup problem of FreeSurfer Do you know which shell you're using? Bash? Zsh? What's the output of
? |
I am using Zsh |
After sourcing freesurfer from the VScode terminal, I can execute the code and it finds mri_watershed, but only when I run it through the terminal, not in the interactive jupyter notebook. Did I misunderstand how this is supposed to work? |
Did you make sure to launch the jupyter server from the same shell where you sourced the freesurfer setup script? |
How do I find out other than checking that they use the same conda environment? |
I will send you my setup later this afternoon ... busy with something else right now! you should NOT need to manually source FS if you do, that's something we need to address |
By the order in which you execute commands. So if you do for BASH:
then open your notebook in that server things should work. But if you laurch I thought we manually checked and added the correct Line 1245 in c63da99
It looks like we don't actually modify PATH. I guess we could here: Line 1910 in c63da99
But it's probably safest to make sure that people (either in a ZSH/BASH profile script) have |
So this is how I got it working on my Mac:
|
That works, thank you @hoechenberger! |
Great! I'm not sure it it works if you don't start VS Code from the command line, but by clicking on the app icon. In any case, we should probably amend the installation instructions. What I told you above is, while present in the FreeSurfer docs, kind of hidden and hard to find. We should also amend the error message. Edit: I believe the FS docs only mention |
It seems to work also when clicking on the icon. |
@larsoner It seems that currently, I think this is problematic, as demonstrated above: @SophieHerbst set the variable via MNE's config mechanism, but the shell environment was never properly set up. I suggest not to retrieve |
Another option would be to check to see if
So I'm cautiously optimistic we could work some magic here. |
Interesting, also considering that the |
Also makes me wonder why this didn't work for @SophieHerbst, then? |
Yeah I looked at that, I think most of it is probably for
Someone would have to look back at the code and |
Description of the problem
I try to compute BEM surfaces from a freshly recon-alled participant, but I get an error.
FileNotFoundError Traceback (most recent call last)
File /Volumes/neurospin/meg/meg_tmp/Deltaphase_shift_Valentine_2021/code/compute_BEM.py:2
1 #%%
----> 2 mne.bem.make_watershed_bem(subject, subjects_dir=None, overwrite=True)
File :12, in make_watershed_bem(subject, subjects_dir, overwrite, volume, atlas, gcaatlas, preflood, show, copy, T1, brainmask, verbose)
File ~/miniconda3/envs/mne/lib/python3.12/site-packages/mne/bem.py:1330, in make_watershed_bem(subject, subjects_dir, overwrite, volume, atlas, gcaatlas, preflood, show, copy, T1, brainmask, verbose)
1325 logger.info(
1326 "\nRunning mri_watershed for BEM segmentation with the following parameters:\n"
1327 f"\nResults dir = {ws_dir}\nCommand = {' '.join(cmd)}\n"
1328 )
1329 os.makedirs(op.join(ws_dir))
-> 1330 run_subprocess_env(cmd)
1331 del tempdir # clean up directory
1332 if op.isfile(T1_mgz):
File :12, in run_subprocess(command, return_code, verbose, *args, **kwargs)
File ~/miniconda3/envs/mne/lib/python3.12/site-packages/mne/utils/misc.py:144, in run_subprocess(command, return_code, verbose, *args, **kwargs)
142 control_stdout = "stdout" not in kwargs
143 control_stderr = "stderr" not in kwargs
--> 144 with running_subprocess(command, *args, **kwargs) as p:
145 if control_stdout:
...
-> 1953 raise child_exception_type(errno_num, err_msg, err_filename)
1954 else:
1955 raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'mri_watershed'
Steps to reproduce
Link to data
No response
Expected results
Create BEM surfaces
Actual results
error message above
Additional information
Freesurfer is installed and working, mri_watershed exists in
/Applications/freesurfer/7.4.1/bin/mri_watershed
It seems like other users had the same issue recently: https://mne.discourse.group/t/mne-bem-make-watershed-bem-compatablity-with-freesurfer-7-3-2/5794/4
The text was updated successfully, but these errors were encountered: