Longitudinal Processing with sMRIPrep and QSIPrep

Hi all! I have some subjects in my dataset that have multiple MRI scans, but I’m struggling to understand the output structure of sMRIPrep (and QSIPrep for that matter) for these longitudinal cases.

For a subject with one scan, the “smriprep” output and “freesurfer” output generated by sMRIPrep looks like this:


For subjects with multiple scans, inside “smriprep” there is a set of processed files (nii.gz, .gii, etc.) I assume from one of the scans (the first? last? I’m unsure) under “anat”, and then inside each session folder is a single text file.

I would like to obtain the smriprep and freesurfer output for each scanning session, so that I can obtain metrics for each timepoint, and then subsequently perform QSIPrep on each scan to generate white matter tracts for each timepoint. I’ve tried running QSIPrep on a longitudinal case (with freesurfer-input set to sMRIPrep’s freesurfer output) and it fails, giving me a FileNotFoundError:

FileNotFoundError: /out/workdir/qsirecon_wf/sub-{PIDN}mrtrix_multishell_msmt_pyafq_tractometry/sub{PIDN}ses{DATE}_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/resample_mask/result_resample_mask.pklz

Thank you so much in advance to anyone who can help provide some insight on this!

Hi @mkersey ,

When there are multiple sessions, the default for smriprep, qsiprep and fmriprep is to merge the anatomical image into what it is called a robust template, with the FreeSurfer methodology. There are different ways to merge several images into such a template. Here again, the default is to align this template on the first image (according to the name of the session in alphabetical order).
More details here.

If you want to process each session separately, you can follow the recommendation from @Steven from another thread:

For more details on the creation of the robust template within fmriprep (and also what happens to the T2w images), you can look at this other discussion:

1 Like

Thank you @jsein! This makes more sense now. So the default is to create a “robust template” which merges the sessions, but if I want to process each session separately I can use “–bids-filter-file” and this will automatically created the longitudinal file structure that would go along with it. I will try this out. Thanks again.

1 Like

Hi @jsein @Steven ! I was wondering if there are any different updates on processing longitudinal cases for the same subject such that the sessions remain separate. Some of my colleagues are also having the same trouble with keeping processing separate for cases with multiple sessions, and the --bids-filter-file option isn’t working out as a solution.

Thank you so much for your work and the time you put into answering our questions! :slight_smile:

Echoing @mkersey comments. The use case I ran into earlier is a longitudinal dataset of children, where T1s still evolve quite significantly over time. So we don’t want to average them but would prefer to process each session independently.

Even if the bids-filter-file were to work to sub-select only one session to run at a time, the current output structure of QSIPrep is:

qsiprep/
  sub-01/
    anat/*T1.nii.gz* #that's the issue
    ses-001/
      anat/
        some_transform.txt
        # it would be better to have the preprocessed session T1 here
      dwi/session_dwi.nii.gz

My current workaround, which is not super BIDS friendly, is to treat sessions as new subjects:

sub-01SES1/ses-1/
sub-01SES2/ses-2/
sub-02SES1/ses-1/
...

Any thoughts?

This is exactly what we do too, also with fmriprep.

One of the upcoming changes we’re planning on will put the anatomical data into the session directory unless the longitudinal flag is used.

1 Like

I misread your answer. We actually use the bids filter file and make a zip of the results that 's named sub-X_ses-Y_qsiprep.zip. This serves a few purposes - working around this session issue, keeping the outputs (individually at least) bidsy and is easier on our HPC (which is almost out of inodes)

1 Like

Awesome to hear that you’re planning to move the anatomical data to the session for, unless otherwise specified. Thanks!

Re: processing in HPC. I also process bids files by copying only a specific subject session pair to the compute node local storage (keeping the bids structure), and then copy results back to the main bids folder. But this didn’t work here because the anatomy file outside of the session dir would get overwritten by latest job’s file.