ASLprep error freesurfer subjects directory in NeurodeskApp

Summary of what happened:

Hello!

I am running aslprep through Neurodesk.
And we are getting back the same error, what we believe does not make sense…

Any help would be appreciated.

Thanks in advance!

Version:

0.7.2

Environment (Docker, Singularity / Apptainer, custom installation):

Neurodesk

I have used the following command (which I have been using for long at it previously worked perfectly):

Command used

aslprep \
neurodesktop-storage/Agueda/BIDS \
neurodesktop-storage/Agueda/BIDS/derivatives/aslprep \
participant \
--participant-label sub-388 \
--force-bbr \
--basil \
 --ignore t2w \
--fs-subjects-dir neurodesktop-storage/Agueda/BIDS/derivatives/freesurfer/sourcedata/freesurfer_pre/sourcedata \
--bids-filter-file neurodesktop-storage/Agueda/BIDS/BIDS_filter_file.json \
--fs-license-file neurodesktop-storage/Agueda/BIDS/license.txt \
--skip_bids_validation \
-vv \
-w \
neurodesktop-storage/Agueda/BIDS

We have tried to run without freesurfer pre-existing directory and with --fs-no-reconall command. We also tried using previous version on aslprep (0.6.0 and 0.7.0) and we are receiving the same error all the times.

aslprep \
neurodesktop-storage/Agueda/BIDS \
neurodesktop-storage/Agueda/BIDS/derivatives/aslprep \
participant \
--participant-label sub-388 \
--force-bbr \
--basil \
--ignore t2w \
--fs-no-reconall \
--bids-filter-file neurodesktop-storage/Agueda/BIDS/BIDS_filter_file.json \
--fs-license-file neurodesktop-storage/Agueda/BIDS/license.txt \
--skip_bids_validation \
-vv \
-w neurodesktop-storage/Agueda/BIDS

Relevant Log Outputs

> Traceback (most recent call last):
  File "/opt/conda/envs/aslprep/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/conda/envs/aslprep/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/cli/workflow.py", line 95, in build_workflow
    retval["workflow"] = init_aslprep_wf()
                         ^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/workflows/base.py", line 68, in init_aslprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/workflows/base.py", line 273, in init_single_subject_wf
    anat_fit_wf = init_anat_fit_wf(
                  ^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/smriprep/workflows/anatomical.py", line 749, in init_anat_fit_wf
    anat_template_wf = init_anat_template_wf(
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/smriprep/workflows/anatomical.py", line 1483, in init_anat_template_wf
    StructuralReference(
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/freesurfer/base.py", line 244, in __init__
    super(FSCommandOpenMP, self).__init__(**inputs)
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/freesurfer/base.py", line 134, in __init__
    self.inputs.subjects_dir = self._subjects_dir
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
    self.error(objekt, name, str(value))
  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'subjects_dir' trait of a RobustTemplateInputSpec instance must be a pathlike object or string representing an existing directory, but a value of '/home/jovyan/freesurfer-subjects-dir' <class 'str'> was specified.

Just to make sure I understand, when you set --fd-subjects-dirs to that path, you still get the error saying that the subjects dir is /home/jovyan/freesurfer-subjects-dir?

Yes, and the thing is we are getting the same error even with --fs-no-reconall and trying to run freesurfer

I’m not sure what could be causing that. Can you share the config.toml file and full log files?

It stops before generating any log file. config.toml shows this:

[environment]
cpu_count = 20
exec_env = "singularity"
free_mem = 45.6
overcommit_policy = "always"
overcommit_limit = "50%"
nipype_version = "1.8.6"
templateflow_version = "24.2.0"
version = "0.7.2"

[execution]
bids_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS"
derivatives = []
bids_database_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/20240916-115054_e08873f6-91db-4804-9846-5236a18ea43c/bids_db"
boilerplate_only = false
sloppy = false
debug = []
aslprep_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/aslprep"
fs_license_file = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/license.txt"
fs_subjects_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/freesurfer/sourcedata/freesurfer_pre/sourcedata"
layout = "BIDS Layout: ...urodesktop-storage/Agueda/BIDS | Subjects: 91 | Sessions: 170 | Runs: 0"
log_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/aslprep/logs"
log_level = 15
low_mem = false
md_only_boilerplate = false
notrack = false
output_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/aslprep"
output_spaces = "MNI152NLin2009cAsym:res-native"
reports_only = false
run_uuid = "20240916-115054_e08873f6-91db-4804-9846-5236a18ea43c"
participant_label = [ "319", "320",]
templateflow_home = "/home/jovyan/.cache/templateflow"
work_dir = "/home/jovyan/neurodesktop-storage/Agueda/BIDS"
write_graph = false

[workflow]
anat_only = false
asl2t1w_dof = 6
asl2t1w_init = "register"
m0_scale = 1
cifti_output = false
dummy_scans = 0
fmap_bspline = false
force_syn = false
hires = true
ignore = [ "t2w",]
level = "full"
longitudinal = false
run_msmsulc = false
medial_surface_nan = false
project_goodvoxels = false
run_reconall = true
skull_strip_fixed_seed = false
skull_strip_template = "OASIS30ANTs"
skull_strip_t1w = "force"
use_bbr = true
use_syn_sdc = false
smooth_kernel = 5
scorescrub = false
basil = true

[nipype]
crashfile_format = "txt"
get_linked_libs = false
nprocs = 20
omp_nthreads = 8
plugin = "MultiProc"
resource_monitor = false
stop_on_first_crash = false

[seeds]
master = 13810
ants = 64169
numpy = 28357

[nipype.plugin_args]
maxtasksperchild = 1
raise_insufficient = false

[execution.bids_filters.t1w]
datatype = "anat"
session = "1"
acquisition = "<Query.NONE: 1>"
suffix = "T1w"

[execution.bids_filters.asl]
datatype = "perf"
session = "1"
suffix = "asl"

That is very confusing. I will try to reproduce the error on my end, but it may take a couple of days.

Just on the off chance this is a known issue with recent versions of sMRIPrep (since ASLPrep’s anatomical processing is mostly copied from fMRIPrep and relies on sMRIPrep), @effigies does this error look familiar? No worries if not.

Also tagging @stebo85 as this could be a neurodesk hard coding variables thing.

1 Like

I haven’t seen this before.

1 Like

It seems to be an issue with Neurodesk

1 Like

It could be an issue on our side. I have a look.

I had a quick look: We set a Freesurfer SUBJECTS_DIR globally in Neurodesk so users don’t have to specify this. Somehow this now interferes with aslprep, but I am not sure why yet.

For now, can you try to unset this variable before running your pipeline?

Hi @stebo85!
Apologize for the late reply. The thing is that we have precomputed freesurfer outputs and we want to use them. I have tried again and that did not solve our issue.

Dear @lucia_sanchez_aranda,

That makes sense! If you want to use precomputed freesurfer outputs can you try to set the Freesurfer variable to this location as well?

export SUBJECTS_DIR=$PWD/freesurfer_pre_computed_output
aslprep ds000240 \
   aslprep-output-with-freesurfer-precomputed \
   participant \
   --participant-label 01 \
   --fs-license-file ~/.license \
   --fs-subjects-dir $SUBJECTS_DIR
   -w aslprep-work-with-freesurfer-precomputed