- longitudinal study

I am reorganising a longitudinal study to BIDS convention. Then I plan to process the study using script. My question is – is the compatible with BIDS recommendation for longitudinal studies:


Or is there another recommendation how to deal with longitudinal studies?


Hi @valosekj!

SCT should be able to handle nested folders starting with ses-. For more details see the implementation.

Please test it out and let us know if it does the job as expected :blush:

Thank you for your feedback!

1 Like

Thank you Julien! I let you know when I test it.

Okay, I tested it using the latest SCT version. Generally it works, but I had to do two small tweaks on $SUBJECT variable. I try to describe that for future users.

I have organised data according to BIDS for longitudinal studies like this:

β”œβ”€β”€ sub-01
β”‚   └── ses-01
β”‚       β”œβ”€β”€ anat
β”‚       β”‚   β”œβ”€β”€ sub-01_ses-01_T1w.json
β”‚       β”‚   β”œβ”€β”€ sub-01_ses-01_T1w.nii.gz

And let’s say I have simple script for spinal cord segmentation which I run using sct_run_batch as follow:

sct_run_batch -path-data ./data_bids -path-output ./data_bids_results -sub sub-01 -script

$1 variable passed from sct_run_batch to would be standardly sub-01, but since data has additional subfolder ses-, $1 would be sub-01/ses-01 which is absolutely expected and okay.

In my I had to modify $SUBJECT variable at two places, though:

  1. For rsync command it is necessary to remove ses- from the source path, otherwise data would be copied to data_processed/ses-01/ folder instead of data_processed/sub-01/ses-01/

  2. Since $SUBJECT variable contains sub-01/ses-01, it is necessary to replace / by _ (to get filename like sub-01_ses-01_T1w.nii.gz instead of sub-2246B/ses-01_T1w.nii.gz) for any other command (such as sct_deepseg_sc) which works with filenames

My then looks like:


set -x

# Retrieve input param from sct_run_batch script

# Go to folder where data will be copied and processed

# Copy source images, NB - ${SUBJECT%/*} removes ses-01 from source path
rsync -avzh ${PATH_DATA}/${SUBJECT%/*} .

# Go to anat folder where all structural data are located
cd ${SUBJECT}/anat/

# Run SC segmentation on T1w image, NB - ${SUBJECT/\//_} replaces '/' by '_'
sct_deepseg_sc -i ${file_t1}.nii.gz -c t1

I hope it is understandable :sweat_smile:

Hi @valosekj,

Thank you for the feedback! Indeed, I forgot to mention that the batch script needs to be updated. This should be left at the discretion of the user though, because BIDS allows to name files either with (β€œsub-XX_ses-YY_ZZ”) or without the β€œses-” field nested in the file name (β€œsub-XX_ZZ”).

Your modification is exactly what was needed in your case. You might also want to consider changing the SUBJECT variable in the first place. See for example this recent pipeline that also uses multiple sessions.

1 Like