I am in the process of trying to perform coregistration, and I seem to be running into an error. I know that coreg looks for three files (head.fif, lh.seghead, and lh.smseghead). I have done the MRI reconstruction (FreeSurfer) and do not have these files. However, I understand that they can be generated using mne.bem.make_scalp_surfaces.
When I try to use this function (mne.bem.make_scalp_surfaces(āsampleā,subjects_dir=subjects_dir)), I run into an error (subjdir: undefined variable). I am wondering if there is some function/output I am supposed to run/generate before running make_scalp_surfaces, or if I just have some kind of syntax error leading to the undefined variable.
MNE Python version 0.24.0
OS: macOS Monterey v12.0.1
I believe that variable subjects_dir is defined. In my terminal, I run:
export SUBJECTS_DIR=/path/to/subject (the folder I map to contains the āsampleā folder, which contains bem, mri, surf, etc.
Earlier in my code, I generate bem (using mne.bem.make_watershed_bem) which takes subjects_dir as an argument, and the code runs just fine (bem is generated).
I think the issue is that when you do export SUBJECTS_DIR=whatever and then later run spyder, the ipython terminal within spyder is a new terminal and therefore doesnāt inherit your exported environment variables. You can probably fix that by putting the export lines in your .bashrc file so that they get declared when spyder spawns its embedded terminals too.
That may be true, but @ktyner also explicitly passes subjects_dir, which overrides the SUBJECTS_DIR environment variable, so I suspect the issue must be somewhere elseā¦
This is what I thought too Richard. If I pass subjects_dir, there should be an issue with each function I pass it to, not just the make_scalp_surfaces function.
You need to pass $SUBJECT and $SUBJECTS_DIR (with dollar signs) instead of SUBJECT and SUBJECTS_DIR (without dollar signs) on the command line. Or, better yet, pass dir subject name and subjects directory directly. Unless a directory named SUBJECT_DIR actually exists??
We passed $SUBJECT and $SUBJECTS_DIR and received the same error. We also tried passing with the absolute paths for -s and -d and ran into the same error. I do not have a directory named SUBJECT_DIR.
In my terminal, I first activate mne, then I export and source freesurfer. When I run that line of code, I donāt seem to run into any issues. The terminal output is attached.