fMRIprep in macOS and Neurodeskapp

Hello eveyone,

I am trying to run fMRIprep in macOS using neurodeskapp with the following script but does not work despite that It worked on my laptop with window and neurodesk.
Could anyone help me? It seem that the problem is with the working directory or between the differences in macOS and Window:

Script used:

#!/bin/bash

  #User inputs:
  bids_root_dir=/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/fmriprep9
  workingdir=$HOME/fmri/tmp_fmriprep
  subj=$subject
  nthreads=4
  mem=20 #gb 
  participant_labels=("sub-101" "sub-103")  # List of participant labels
  
  #Begin:

  #Convert virtual memory from gb to mb
  mem=`echo "${mem//[!0-9]/}"` #remove gb at end
  mem_mb=`echo $(((mem*1000)-5000))` #reduce some memory for buffer space during pre-processing

  #export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow
  export FS_LICENSE=$bids_root_dir/license.txt

  #Run fmriprep

for subj in "${participant_labels[@]}"; do
    fmriprep $bids_root_dir $bids_root_dir/derivatives \
      participant \
      --participant-label $subj \
      --skip-bids-validation \
      --md-only-boilerplate \
      --fs-license-file $bids_root_dir/license.txt \
      --fs-no-reconall \
      --output-spaces MNI152NLin2009cAsym:res-2 \
      --nthreads $nthreads \
      --stop-on-first-crash \
      --mem_mb $mem_mb \
      -w $workingdir
done

The error that the terminal give me it is this one:

You are using fMRIPrep-23.0.0, and a newer version of fMRIPrep is available: 23.1.4.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
230816-23:36:08,424 cli INFO:
         Telemetry system to collect crashes and errors is enabled - thanks for your feedback!. Use option ``--notrack`` to opt out.
230816-23:36:17,873 nipype.workflow IMPORTANT:
         Running fMRIPrep version 23.0.0

         License NOTICE ##################################################
         fMRIPrep 23.0.0
         Copyright 2023 The NiPreps Developers.
         
         This product includes software developed by
         the NiPreps Community (https://nipreps.org/).
         
         Portions of this software were developed at the Department of
         Psychology at Stanford University, Stanford, CA, US.
         
         This software is also distributed as a Docker container image.
         The bootstrapping file for the image ("Dockerfile") is licensed
         under the MIT License.
         
         This software may be distributed through an add-on package called
         "Docker Wrapper" that is under the BSD 3-clause License.
         #################################################################
230816-23:36:17,970 nipype.workflow IMPORTANT:
         Building fMRIPrep's workflow:
           * BIDS dataset path: /home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/fmriprep9.
           * Participant list: ['103'].
           * Run identifier: 20230816-233607_9a92750c-832e-4f76-b195-12f68ab82322.
           * Output spaces: MNI152NLin2009cAsym:res-2.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/fmriprep9/derivatives/fmriprep/sourcedata/freesurfer.
Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/workflow.py", line 115, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 92, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 306, in init_single_subject_wf
    anat_preproc_wf = init_anat_preproc_wf(
  File "/opt/conda/lib/python3.9/site-packages/smriprep/workflows/anatomical.py", line 345, in init_anat_preproc_wf
    anat_template_wf = init_anat_template_wf(
  File "/opt/conda/lib/python3.9/site-packages/smriprep/workflows/anatomical.py", line 780, in init_anat_template_wf
    StructuralReference(
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/freesurfer/base.py", line 244, in __init__
    super(FSCommandOpenMP, self).__init__(**inputs)
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/freesurfer/base.py", line 134, in __init__
    self.inputs.subjects_dir = self._subjects_dir
  File "/opt/conda/lib/python3.9/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
    self.error(objekt, name, str(value))
  File "/opt/conda/lib/python3.9/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.

Thanks so much,

Beatriz

Hi @Beatriz and welcome to neurostars!

A few things:

I see you’re looping across subjects, but fMRIPrep can process multiple subjects at the same time by inputting multiple subjects (space-delimited) into the --participant-label argument.

This flag is not recommended, see here.

Are your data BIDS valid?

Does /home/jovyan/freesurfer-subjects-dir exist? What are its contents? Also, that doesn’t seem like the one set by fMRIPrep (which should be in sourcedata). This could be a conflicting message from your environment variables (perhaps from a local installation of FreeSurfer). This is why running in containers is recommended. Try explicitly passing in where you want your FreeSurfer directory to be with the --fs-subjects-dir argument.

If none of these above points work, can you try upgrading?

Best,
Steven

I just saw this old post and just in case anyone else comes across this.

It should work when the Freesurfer subjects directory is created manually beforehand, the SUBJECTS_DIR variable is set to this directory and fMRIprep needs to be told to use that directory with the --fs-subjects-dir flag.

So a command like this would work on Neurodesk:

mkdir -p ~/work-freesurfer \
&& export SUBJECTS_DIR=~/work-freesurfer \
&& fmriprep ds000102/ content/ participant \
--fs-license-file ~/.license \
--output-spaces T1w MNI152NLin2009cAsym fsaverage fsnative \
--participant-label 08 \
--nprocs 10 \
--mem 10000 \
--skip_bids_validation -v \
--fs-subjects-dir ~/work-freesurfer