PennLINC / qsiprep

Preprocessing of diffusion MRI
http://qsiprep.readthedocs.io
BSD 3-Clause "New" or "Revised" License
140 stars 57 forks source link

Reconstruction workflow for longitudinal data #471

Closed csleo95 closed 9 months ago

csleo95 commented 2 years ago

Hi all!

I have been trying to run the mrtrix_singleshell_ss3t_ACT-hsvs reconstruction workflow on longitudinal dwi and T1w data that have gone through qsiprep proprocessing and freesurfer`s recon-all, respectively. I have tried to set up the freesurfer derivatives folder in multiple ways (including following these recommendations: https://surfer.nmr.mgh.harvard.edu/fswiki/BIDS). However, all of them resulted in the crash attached. The only way this reconstruction workflow worked was when I used only one session per subject (i.e., it only worked for cross-sectional data).

Many thanks in advance for the help!!

Best regards, Leo

Code:

docker run -ti --rm \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/data:/data \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/derivatives/qsiprep:/out \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/tmp:/work \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/fs:/fs \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/derivatives/freesurfer3:/str \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/json:/json \
    -v /media/leocs/leo.hd/DRIVE/gamma.test/qsirecon_atlases:/atlas/qsirecon_atlases \
    pennbbl/qsiprep \
   /data /out/qsiprecon \
    participant -w /work \
  --recon-only \
  --recon_input /out/qsiprep \
  --recon-spec /json/mrtrix_singleshell_ss3t_ACT-hsvs-schaefer+gordon.json \
  --freesurfer-input /str \
  --fs-license-file /fs/license.txt \
  --nthreads 10 \
  --stop-on-first-crash \
  -vvv

Crash file: crash-20221002-161658-root-get_atlases-2836cb10-8ff7-4f37-a0ff-f90218b13522.txt

mattcieslak commented 2 years ago

Hi! QSIPrep is expecting regular freesurfer naming, not BIDS.

csleo95 commented 2 years ago

Many thanks for the reply!

I have tried to set up the freesurfer directory using regular freesurfer naming in two ways, but neither worked. From my understanding (and please correct me if I am wrong), qsiprep needs the recon-all output from the T1W template estimated across sessions for each subject. So, I have first tried to set up the fresurfer directory with this output using only the name of the subject (as below), but it only worked when subjects had a single session.

├── freesurfer
│   └── sub-0001
│       ├── label
│       ├── mri
│       ├── scripts
│       ├── stats
│       ├── surf
│       ├── tmp
│       ├── touch
│       └── trash

Alternatively (in case my understanding is wrong), I have tried to set up the freesurfer directory with the recon-all ouput of the T1w of each session using the name of the subject + session (as below - suggested in https://surfer.nmr.mgh.harvard.edu/fswiki/BIDS), but it also did not work.

├── freesurfer
│   ├── sub-0001_ses-post2
│   │   ├── label
│   │   ├── mri
│   │   ├── scripts
│   │   ├── stats
│   │   ├── surf
│   │   ├── tmp
│   │   ├── touch
│   │   └── trash
│   └── sub-0001_ses-pre
│       ├── label
│       ├── mri
│       ├── scripts
│       ├── stats
│       ├── surf
│       ├── tmp
│       ├── touch
│       └── trash

How should the freesurfer directory be structured?

Many thanks again!

julfou81 commented 2 years ago

I got the same error for a dataset in which each subject had two sessions with dwi images in both sessions . I ran through singularity on a HPC with GPU capabilities: FMRIPREP v22.0.2 and QSIPREP v0.16.0RC3 successively on this data set with the following commands:

freesurfer tree:

freesurfer
├── fsaverage
│   ├── label
│   ├── mri
│   ├── mri.2mm
│   ├── scripts
│   ├── surf
│   └── xhemi
└── sub-pilot1
    ├── label
    ├── mri
    ├── scripts
    ├── stats
    ├── surf
    ├── tmp
    ├── touch
    └── trash

crash file for ses-02 when running qsirecon on a subject having dwi images on both ses-01 and ses-02: crash-20221028-135754-jsein-get_atlases-ed4033b2-a680-4250-af04-00da1f9675a1.txt

julfou81 commented 2 years ago

In my case qsirecon works for ses-01 but keeps failing for ses-02, stating: Exception: No MNI to T1w transform found in anatomical directory

My question is: in which anatomical directory is qsirecon looking for when it deals with ses-02, since he finds this file for ses-01

julfou81 commented 2 years ago

@csleo95 : did you try with the --longitudinal flag?

csleo95 commented 2 years ago

@julfou81, I used the --longitudinal flag when running the preprocessing workflow, but not when running the reconstruction workflow. Did you try it for the latter? Did it work?

julfou81 commented 2 years ago

@julfou81, I used the --longitudinal flag when running the preprocessing workflow, but not when running the reconstruction workflow. Did you try it for the latter? Did it work?

No, I am testing it now on the preprocessing workflow, but seeing your response and looking at the documentation, I doubt I would get different results than yours... The --longitudinal options seems to only be used to create a longitudinal template with mri_robust_template function. It is a similar behavior than FMRIPREP and does not force freesurfer to be run in "longitudinal mode".

csleo95 commented 2 years ago

@julfou81, I used the --longitudinal flag when running the preprocessing workflow, but not when running the reconstruction workflow. Did you try it for the latter? Did it work?

No, I am testing it now on the preprocessing workflow, but seeing your response and looking at the documentation, I doubt I would get different results than yours... The --longitudinal options seems to only be used to create a longitudinal template with mri_robust_template function. It is a similar behavior than FMRIPREP and does not force freesurfer to be run in "longitudinal mode".

Yes.. Please let me know if you get a different result. I have been also trying other combinations of flags and directory structures to run the reconstruction workflow. If I get something different, I will let you know!

marlvan commented 1 year ago

Also having an issue running qsirecon on longitudinal data - everything words for ses-001, but the common anatomical files for ses-001 (the transformations and whatnot) are not recognized for ses-002, causing the whole thing to crash..

mattcieslak commented 1 year ago

This sounds like a problem. Are all you running the hsvs workflow? And you have multi session data?

Our group hasn't run into a problem with this yet, but that's probably due to how we structure the running of longitudinal data. We usually have scans separated by a year or more, so mri_robust_template doesn't work. Instead we treat each session as its own subject. You can do this by making a different subject ID in BIDS for each session or you can process the multi-session data once per session using a bids filter file (this is what we do) eg:

filterfile=${PWD}/${sesid}_filter.json
echo "{" > ${filterfile}
echo "'fmap': {'datatype': 'fmap'}," >> ${filterfile}
echo "'dwi': {'datatype': 'dwi', 'session': '$sesid', 'suffix': 'dwi'}," >> ${filterfile}
echo "'sbref': {'datatype': 'func', 'session': '$sesid', 'suffix': 'sbref'}," >> ${filterfile}
echo "'flair': {'datatype': 'anat', 'session': '$sesid', 'suffix': 'FLAIR'}," >> ${filterfile}
echo "'t2w': {'datatype': 'anat', 'session': '$sesid', 'suffix': 'T2w'}," >> ${filterfile}
echo "'t1w': {'datatype': 'anat', 'session': '$sesid', 'suffix': 'T1w'}," >> ${filterfile}
echo "'roi': {'datatype': 'anat', 'session': '$sesid', 'suffix': 'roi'}" >> ${filterfile}
echo "}" >> ${filterfile}

# remove ses and get valid json
sed -i "s/'/\"/g" ${filterfile}
sed -i "s/ses-//g" ${filterfile}