Skip to content

Commit fffe1b2

Browse files
authored
Merge pull request #2003 from mgxd/doc/fs-dir
DOC: Add ``--fs-subjects-dir`` usage to slurm example
2 parents e0d8cd4 + 75e6962 commit fffe1b2

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

docs/_static/sbatch.slurm

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
BIDS_DIR="$STUDY/data"
1717
DERIVS_DIR="derivatives/fmriprep-1.5.0"
18+
LOCAL_FREESURFER_DIR="$STUDY/data/derivatives/freesurfer-6.0.1"
1819

1920
# Prepare some writeable bind-mount points.
2021
TEMPLATEFLOW_HOST_HOME=$HOME/.cache/templateflow
@@ -25,27 +26,21 @@ mkdir -p ${FMRIPREP_HOST_CACHE}
2526
# Prepare derivatives folder
2627
mkdir -p ${BIDS_DIR}/${DERIVS_DIR}
2728

28-
# This trick will help you reuse freesurfer results across pipelines and fMRIPrep versions
29-
mkdir -p ${BIDS_DIR}/derivatives/freesurfer-6.0.1
30-
if [ ! -d ${BIDS_DIR}/${DERIVS_DIR}/freesurfer ]; then
31-
ln -s ${BIDS_DIR}/derivatives/freesurfer-6.0.1 ${BIDS_DIR}/${DERIVS_DIR}/freesurfer
32-
fi
33-
3429
# Make sure FS_LICENSE is defined in the container.
3530
export SINGULARITYENV_FS_LICENSE=$HOME/.freesurfer.txt
3631

3732
# Designate a templateflow bind-mount point
3833
export SINGULARITYENV_TEMPLATEFLOW_HOME="/templateflow"
39-
SINGULARITY_CMD="singularity run --cleanenv -B $BIDS_DIR:/data -B ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME} -B $L_SCRATCH:/work $STUDY/images/poldracklab_fmriprep_1.5.0.simg"
34+
SINGULARITY_CMD="singularity run --cleanenv -B $BIDS_DIR:/data -B ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME} -B $L_SCRATCH:/work -B ${LOCAL_FREESURFER_DIR}:/fsdir $STUDY/images/poldracklab_fmriprep_1.5.0.simg"
4035

4136
# Parse the participants.tsv file and extract one subject ID from the line corresponding to this SLURM task.
4237
subject=$( sed -n -E "$((${SLURM_ARRAY_TASK_ID} + 1))s/sub-(\S*)\>.*/\1/gp" ${BIDS_DIR}/participants.tsv )
4338

4439
# Remove IsRunning files from FreeSurfer
45-
find ${BIDS_DIR}/derivatives/freesurfer-6.0.1/sub-$subject/ -name "*IsRunning*" -type f -delete
40+
find ${LOCAL_FREESURFER_DIR}/sub-$subject/ -name "*IsRunning*" -type f -delete
4641

4742
# Compose the command line
48-
cmd="${SINGULARITY_CMD} /data /data/${DERIVS_DIR} participant --participant-label $subject -w /work/ -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --output-spaces MNI152NLin2009cAsym:res-2 anat fsnative fsaverage5 --use-aroma"
43+
cmd="${SINGULARITY_CMD} /data /data/${DERIVS_DIR} participant --participant-label $subject -w /work/ -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --output-spaces MNI152NLin2009cAsym:res-2 anat fsnative fsaverage5 --use-aroma --fs-subjects-dir /fsdir"
4944

5045
# Setup done, run the command
5146
echo Running task ${SLURM_ARRAY_TASK_ID}
@@ -57,4 +52,4 @@ exitcode=$?
5752
echo "sub-$subject ${SLURM_ARRAY_TASK_ID} $exitcode" \
5853
>> ${SLURM_JOB_NAME}.${SLURM_ARRAY_JOB_ID}.tsv
5954
echo Finished tasks ${SLURM_ARRAY_TASK_ID} with exit code $exitcode
60-
exit $exitcode
55+
exit $exitcode

docs/faq.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,18 @@ Please find more information regarding this error from discussions on
5757

5858
Additionally, consider using the ``--low-mem`` flag, which will make some memory optimizations at the cost of disk space in the working directory.
5959

60+
61+
I have already run ``recon-all`` on my subjects, can I reuse my outputs?
62+
------------------------------------------------------------------------
63+
Yes, as long as the FreeSurfer_ version previously used was ``6.0.0`` or newer.
64+
If running with FreeSurfer, *fMRIPrep* checks if the output directory contains a ``freesurfer``
65+
directory and reuses the outputs found.
66+
Alternatively, you can use the ``--fs-subjects-dir`` flag to specify a different location for the existing FreeSurfer outputs.
67+
68+
6069
ERROR: it appears that ``recon-all`` is already running
6170
-------------------------------------------------------
62-
When running FreeSurfer_'s ``recon-all``, an error may say *it appears it is already running*.
71+
When running FreeSurfer's ``recon-all``, an error may say *it appears it is already running*.
6372
FreeSurfer creates files (called ``IsRunning.{rh,lh,lh+rh}``, under the ``scripts/`` folder)
6473
to determine whether it is already executing ``recon-all`` on that particular subject
6574
in another process, compute node, etc.
@@ -125,7 +134,7 @@ If you would like to run *fMRIPrep* in parallel on multiple subjects please use
125134
How much CPU time and RAM should I allocate for a typical fMRIPrep run?
126135
-----------------------------------------------------------------------
127136
The recommended way to run fMRIPrep is to process one subject per container instance. A typical preprocessing run
128-
without surface processing with freesurfer can be completed in about 2 hours with 4 CPUs or in about 1 hour with 16 CPUs.
137+
without surface processing with FreeSurfer can be completed in about 2 hours with 4 CPUs or in about 1 hour with 16 CPUs.
129138
More than 16 CPUs do not translate into faster processing times for a single subject. About 8GB of memory should be
130139
available for a single subject preprocessing run.
131140

docs/usage.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Command-Line Arguments
3737
:nodefaultconst:
3838

3939

40-
The command-line interface of the docker wrapper
40+
The command-line interface of the docker wrapper
4141
------------------------------------------------
4242

4343
.. argparse::
@@ -57,10 +57,10 @@ The FreeSurfer license
5757
To obtain a FreeSurfer license, simply register for free at
5858
https://surfer.nmr.mgh.harvard.edu/registration.html.
5959

60-
When using manually-prepared environments or singularity, FreeSurfer will search
61-
for a license key file first using the ``$FS_LICENSE`` environment variable and then
62-
in the default path to the license key file (``$FREESURFER_HOME/license.txt``).
63-
If using the ``--cleanenv`` flag and ``$FS_LICENSE`` is set, use ``--fs-license-file $FS_LICENSE``
60+
When using manually-prepared environments or singularity, FreeSurfer will search
61+
for a license key file first using the ``$FS_LICENSE`` environment variable and then
62+
in the default path to the license key file (``$FREESURFER_HOME/license.txt``).
63+
If using the ``--cleanenv`` flag and ``$FS_LICENSE`` is set, use ``--fs-license-file $FS_LICENSE``
6464
to pass the license file location to *fMRIPRep*.
6565

6666
It is possible to run the docker container pointing the image to a local path

0 commit comments

Comments
 (0)