nipreps / smriprep

Structural MRI PREProcessing (sMRIPrep) workflows for NIPreps (NeuroImaging PREProcessing tools)
https://nipreps.github.io/smriprep
Apache License 2.0
132 stars 39 forks source link

Longitudinal fmriprep with pre-run Freesurfer #21

Open araikes opened 6 years ago

araikes commented 6 years ago

Hi all, In a previous issue (#993), there was a discussion about using fmriprep for longitudinal studies. The question came down to the reusability of Freesurfer outputs. The suggestion was made by @chrisfilo to run Freesurfer first (preferably the BIDS App Freesurfer) and then let fmriprep pull from that.

I've run Freesurfer's recon all for my participants. When I run fmriprep, should I use the --no-fs-reconall option. When I include the flag, the process crashes out with an error (see attached crash text file). When I do not include the flag, the process runs but it's not clear if the freesurfer output is being incorporated.

My call to fmriprep was: -wrap "docker run -i --rm \ -v $INDIVDIR:/data:ro \ -v $OUTDIR:/out \ -v /data/BL2/BIDS_derivatives/code/license.txt:/opt/freesurfer/license.txt \ poldracklab/fmriprep \ /data /out \ participant \ --longitudinal \ --low-mem \ --n_cpus 1 \ --output-space template T1w fsaverage \ --work-dir /scratch \ --use-aroma \ --participant_label "sub-$subject" \ --write-graph"

where $OUTDIR already contains a "freesurfer" folder built from my $INDIVDIR. The --no-fs-reconall was included for one participant and excluded for one participant. The one where it was included completed.

Please let me know what other files might be needed to identify if freesurfer is getting incorporated as intended.

crash-20180414-015316-root-autorecon1-f42ca378-4525-48ee-ac26-65982571c354.txt

effigies commented 6 years ago

You should not use --no-fs-reconall. That indicates that you do not intend to use FreeSurfer surface processing at all, which I do not believe is what you want. The attached crash file, however, seems to be from when you do not include the flag, as autorecon1 should not be run at all if --no-fs-reconall is specified.

Looking at that error, it's finding your FreeSurfer directory, but for some reason not identifying it as being complete. This is most likely a lapse in Nipype's ability to detect a completed directory. I'm not sure what all differences there are in such a directory.

Could you give a full listing of the commands you ran directly with FreeSurfer? If I can replicate your situation, I should be able to get ReconAll to correctly detect that your directory has already been run.

araikes commented 6 years ago

Hi @effigies, Here's the command for running freesurfer. I'm running it in parallel using SLURM on a private cluster.

sbatch -o $LOGS/sub-"$subject"/Freesurfer_out.txt \ -e $LOGS/sub-"$subject"/Freesurfer_error.txt \ --partition="verylong.q" \ --job-name="FS_sub-$subject" \ --wrap "docker run -i --rm \ -v $BIDSDIR:/bids_dataset:ro \ -v $FSOUT:/outputs \ -v /data/BL2/BIDS_derivatives/code/license.txt:/license.txt \ bids/freesurfer \ /bids_dataset \ /outputs \ participant \ --n_cpus 1 \ --multiple_sessions longitudinal \ --hires_mode disable \ --participant_label $subject \ --refine_pial T1only \ --skip_bids_validator \ --license_file "/license.txt""

where $FSOUT is my BIDS derivatives folder/freesurfer.

Attached is a truncated text file with the file tree that gets created from running this. This is the same participant for the crash file I attached previously. The only thing I'm not sure of is whether I needed the "steps" flag in the recon-all call, but it looks like it doesn't. It appears that the cross-sectional, base, and longitudinal folders all got created.

file_tree.txt

Thanks

effigies commented 6 years ago

Could you share the scripts/recon-all.log?

araikes commented 6 years ago

From the cross-sectional folders: ses-Pre: recon-all.log ses-Post: recon-all.log

From the base folder: recon-all.log

From the longitudinal folders: ses-Pre: recon-all.log ses-Post: recon-all.log

effigies commented 6 years ago

Just an update to let you know that (a) I have not yet had time to look further into this and (b) I have not forgotten about this. Thanks for your patience.

araikes commented 6 years ago

Thanks for the update @effigies

pettitta commented 5 years ago

Hi,

I have a follow-up tangential question for OP. I see that you have run the freesurfer scans through the longitudinal pipeline. How do you specify for fmriprep for them to use the longitudinally processed directories for each timepoint and not the original cross-sectional freesurfer output directories?

hpfisher3 commented 5 years ago

Has there been any update on this? I am also running into an issue of fmriprep not being able to recognize previously run freesurfer outputs for a longitudinal design. I get the "you are trying to re-run an existing subject with (possibly) new input data..." error

effigies commented 1 year ago

I think this is finally going to be possible in the near future with https://github.com/nipy/nipype/pull/3529. We will need assistance from somebody familiar with FreeSurfer longitudinal to implement it, however.