mne-bids-pipeline - subjects dir not found

Hi,

I am trying to reproduce this analysis pipeline on ds000248 from openneuro.org using mne-bids-pipeline. At the source analysis stage, I get the error below.

(my_mne1.2) [ma09@login-j01 ~]$ mne_bids_pipeline --config=/imaging/davis/users/ma09/Projects/MNE_bids_pipeline_test/my_config.py --steps=source
[2022-10-21 13:02:14] ╶╴👋 Welcome aboard the MNE BIDS Pipeline!
[2022-10-21 13:02:14] ╶╴🧾 Using configuration: /imaging/davis/users/ma09/Projects/MNE_bids_pipeline_test/my_config.py
[2022-10-21 13:02:14] ┌╴🚀 scripts/init/_00_init_derivatives_dir Now running  👇
[2022-10-21 13:02:14] └╴🎉 scripts/init/_00_init_derivatives_dir Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/init/_01_find_empty_room Now running  👇
[2022-10-21 13:02:14] │ ✅ init/_01_find_empty_room sub-01 run-01 Computation unnecessary (cached) …
[2022-10-21 13:02:14] └╴🎉 scripts/init/_01_find_empty_room Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_01_make_bem_surfaces Now running  👇
[2022-10-21 13:02:14] │ 🔍 source/_01_make_bem_surfaces sub-01 Computation unnecessary (output files exist) …
[2022-10-21 13:02:14] └╴🎉 scripts/source/_01_make_bem_surfaces Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_02_make_bem_solution Now running  👇
[2022-10-21 13:02:14] │ ✅ source/_02_make_bem_solution sub-01 Computation unnecessary (cached) …
[2022-10-21 13:02:14] └╴🎉 scripts/source/_02_make_bem_solution Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_03_setup_source_space Now running  👇
[2022-10-21 13:02:14] │ ✅ source/_03_setup_source_space sub-01 Computation unnecessary (cached) …
[2022-10-21 13:02:14] └╴🎉 scripts/source/_03_setup_source_space Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_04_make_forward Now running  👇
[2022-10-21 13:02:14] │ ✅ source/_04_make_forward sub-01 Computation unnecessary (cached) …
[2022-10-21 13:02:14] └╴🎉 scripts/source/_04_make_forward Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_05_make_inverse Now running  👇
[2022-10-21 13:02:14] │ ✅ source/_05_make_inverse sub-01 Computation unnecessary (cached) …
[2022-10-21 13:02:14] └╴🎉 scripts/source/_05_make_inverse Done running 👆 ⟮1s⟯
[2022-10-21 13:02:14] ┌╴🚀 scripts/source/_99_group_average Now running  👇
[2022-10-21 13:02:14] │ ⏳️ source/_99_group_average A critical error occurred. The error message was: subjects_dir does not exist: /imaging/ma09/Projects/AVSpeechMEG/data/derivatives/anat

Aborting pipeline run. The full traceback is:

Traceback (most recent call last):

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne_bids_pipeline/config.py", line 2794, in wrapper
    out = memory.cache(func)(*args, **kwargs)

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne_bids_pipeline/config.py", line 2886, in wrapper
    func(*args, **kwargs)

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne_bids_pipeline/scripts/source/_99_group_average.py", line 123, in run_group_average_source
    mne.datasets.fetch_fsaverage(subjects_dir=config.get_fs_subjects_dir())

  File "<decorator-gen-590>", line 12, in fetch_fsaverage

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne/datasets/_fsaverage/base.py", line 67, in fetch_fsaverage
    subjects_dir = _set_montage_coreg_path(subjects_dir)

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne/datasets/_fsaverage/base.py", line 128, in _set_montage_coreg_path
    old_subjects_dir = get_subjects_dir(None, raise_error=False)

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne/utils/config.py", line 381, in get_subjects_dir
    subjects_dir = _check_fname(

  File "<decorator-gen-0>", line 12, in _check_fname

  File "/home/ma09/.conda/envs/my_mne1.2/lib/python3.10/site-packages/mne/utils/check.py", line 245, in _check_fname
    raise FileNotFoundError(f'{name} does not exist: {fname}')

FileNotFoundError: subjects_dir does not exist: /imaging/ma09/Projects/AVSpeechMEG/data/derivatives/anat

In my_config.py I specify the following directories:

bids_root: Optional[PathLike] = os.path.join('/imaging', 'davis', 'Projects', 'Openneuro_datasets', 'ds000248')
deriv_root: Optional[PathLike] = os.path.join('/imaging', 'davis', 'users', 'ma09', 'Projects', 
                                              'MNE_bids_pipeline_test', 'ds000248', 'derivatives', 
                                              'mne-bids-pipeline')
subjects_dir: Optional[PathLike] = os.path.join(bids_root, 'derivatives', 'freesurfer', 'subjects')

The directory in the error message is one that I used ages ago when I analyzed a different dataset using mne-python, which doesn’t exist anymore and I don’t quite understand where mne-bids-pipeline finds its path and why it tries to use that as subject_dir instead of what I specified in my_config.py.

Could anyone plese advise how to solve this issue?

Many thanks,
Máté

System details:

  • MNE version: 1.2
  • mne-bids-pipeline version: 0.1.dev628+g8ad5b0e
  • operating system: Centos 7

hi

did you configure freesurfer? freesurfer is required for automated source modeling.

Alex

Hi Alex,

Thanks for pointing me to the right direction.
I ran the following script before running the pipeline and it works now:

#!/bin/tcsh

# set up freesurfer
setenv FSVER '6.0.0'
setenv FREESURFER_HOME /imaging/local/software/freesurfer/${FSVER}/`arch`
echo $FREESURFER_HOME

source $FREESURFER_HOME/FreeSurferEnv.csh

# root directory for processed MRI data
setenv SUBJECTS_DIR /imaging/davis/Projects/Openneuro_datasets/ds000248/derivatives/freesurfer/subjects
echo $SUBJECTS_DIR

Is it then necessary to set the environmental variable SUBJECTS_DIR as well before running the source reconstruction with the pipeline?

Many thanks,
Máté

no it should not be necessary to set the SUBJECTS_DIR before running the pipeline.

is tcsh your default shell?

when you run this script are you doing:

$. script.sh

?

pay attention to the “.”

Alex

Yes, tcsh is my default shell.
I ran the script doing:
$ ./freesurfer_setup.sh

But it also works if I do this:
$ source freesurfer_setup.sh

It also works if I don’t define the SUBJECTS_DIR environmental variable (starting from scratch in a new shell). The reason I defined it in the first place is because of this tutorial.

Máté

ok if you “source” you should be good

./ should not AFAIK

Alex

You’re right, it doesn’t work with ./, only if I “source”. I’ve made a mistake before.
So the actual solution is to “source” the following script, i.e.
$ source freesurfer_setup.sh

#!/bin/tcsh

# set up freesurfer
setenv FSVER '6.0.0'
setenv FREESURFER_HOME /imaging/local/software/freesurfer/${FSVER}/`arch`
echo $FREESURFER_HOME
source $FREESURFER_HOME/FreeSurferEnv.csh

Many thanks,
Máté

1 Like