Specify anatomic image

Hi all,

three quick fMRIprep/bids questions…

  1. is there a way to specify that fmriprep ONLY assesses a specific T1 image?
  • at the moment, we have an original and a scanner correct MRI output. My supervisor wants the corrected version kept and fmriprep is giving the averaged output from both of these images. I only want fmriprep to run the analysis on the non-scanner corrected T1.
  1. if we specify the -longitudinal flag - fmriprep will use a separate T1 image for each run - correct? I haven’t been using this flag and fmriprep has been averaging the anat images - this is going to be problematic as we haven’t collected our data for every session yet and want to run our processing as we go.

  2. where is one supposed to put the non-bids dicom image copies? do they go in “sourcedata”? Having trouble getting my head around the folder structure in BIDS.

my project
      sub-01
              ses-01
              ses-02
      sourecedata
              sub-01 dicom folder?
      derivatives
              fmriprep
                      sub-01
                      sub-02
                      sub-03
                      sourcedata (with a symbolic link to the primary file)

Thanks,

Jen

You’ll want to use the --bids-filter-file option. See FAQ: How do I select only certain files to be input to fMRIPrep?

No. The difference is in the use of FreeSurfer’s mri_robust_template to create a single T1w image. By default, it will just take the first image (defined lexically) and register the others to that image. If you use --longitudinal, it will attempt to find a position equidistant from all input T1w images.

Yes, sourcedata/ may contain the files used to create the current dataset.

Hi @effigies , I have a question here: if only 2 T1w are detected, and no longitudinal flag is passed, the default of FMRIPREP is still to use MRI_robust_template, right? It is what I understand from the current fmriprep documentation:

In the case of multiple T1w images (across sessions and/or runs), T1w images are merged into a single template image using FreeSurfer’s mri_robust_template. This template may be unbiased , or equidistant from all source images, or aligned to the first image (determined lexicographically by session label). For two images, the additional cost of estimating an unbiased template is trivial and is the default behavior, but, for greater than two images, the cost can be a slowdown of an order of magnitude. Therefore, in the case of three or more images, fMRIPrep constructs templates aligned to the first image, unless passed the --longitudinal flag, which forces the estimation of an unbiased template.

Thank you for all your feedbacks!

awesome thank you for all of the above! Sorry in advance for what is going to be a stupid question. For question 2 above, can I assume that the default fMRIprep will handle preprocessing across subjects in a consistent way when the number of sessions is unmatched between participants during the preprocessing and when we add new sessions to the data?

I notice that when I run default fMRI prep on a participant with 2 sessions, fMRIprep outputs a combined anat.nii.gz file and the anat folders within the sessions are text files.

In contast, when I run on a participant with only one session, the anat.gz.nii file is output within the session. What happens when I add on sessions for preprocessing? Does fMRIprep handle this in a consistent way? - just wanted to avoid having to rerun preprocessing steps.

Hi @AustinBipolar , I think we are raising the same point here and the answer seems to be in the quote I made from FMRIPREP documentation:

  • If your subject has two T1w images, either from the same session or across sessions, the default of fmriprep is to use mri_robust_template. If you want to have fmriprep to use only one T1w image, you have to use the --bids-filter-file option.
  • If your subject has 3 or more T1w images, the default of FMRIPREP is to use the 1st image, no need to put the --bids-filter-file option. But in that case of 3 T1w images or more, if you want FMRIPREP to use mri_robust_template, you have to use the longitudinal flag.

Here is an example of a bids-filter file I used for a study where subjects had two sessions, with one T1w image acquired per session:

{
    "t1w": {
        "datatype": "anat",
        "session": "01",
        "suffix": "T1w"
    }
}

Here to use only the T1w from session ses-01.

I read this too @jsein and am having trouble understanding what this means when T1 images are merged before all the sessions are collected. If fMRI prep automatically selects the first image from the first session, I think that would be fine? Right?

Thanks! This makes sense.

Jen

Sorry, to clarify:

  1. 1 image → template == input image
  2. 2+ images and no --longitudinal → use mri_robust_template --fixtp. You get the averaging over multiple time points, but instead of resampling all images to a midpoint, you resample all images to the field-of-view of the first image.
  3. 2+ images and --longitudinal → use mri_robust_template in its default behavior. If more than 2 images are present, this can be extremely slow.

Note: This is edited to match actual behavior, not the quoted documentation.

1 Like

For this case, I just verified that fmriprep is doing like in case 3: → use mri_robust_template --fixtp (fmriprep v22.0.2)

Ah, we should update the docs then. I had thought that we did it unconditionally, but I believed the docs.

1 Like

** If your subject has two T1w images, either from the same session or across sessions, the default of fmriprep is to use mri_robust_template. If you want to have fmriprep to use only one T1w image, you have to use the --bids-filter-file option.*
** If your subject has 3 or more T1w images, the default of FMRIPREP is to use the 1st image, no need to put the --bids-filter-file option. But in that case of 3 T1w images or more, if you want FMRIPREP to use mri_robust_template, you have to use the longitudinal flag.*

@jsein and @effigies I assume this applies to T2 images as well. To make sure I understand this for our dataset…

We collect a different T1 and T2 for 5 sessions. If I create a session-specific BIDS filter file like the one below (for session 02 for example). This will force fMRI prep to use the mri_robust_template to merge these session-specific T1 and T2 images. I know this is splitting hairs, but we are collecting data in young adults and I worry about minor anatomic changes over a year.

{
“t1w”: {
“datatype”: “anat”,
“session”: “02”,
“suffix”: “T1w”
},
{
“t2w”: {
“datatype”: “anat”,
“session”: “02”,
“suffix”: “T2w”
},

fMRIPrep will not merge T2w images. It will select one to pass to FreeSurfer, and that’s it. I believe the selection process is to take the highest resolution T2w image, and if multiple are found, the one that comes first in alphabetical order.

It wouldn’t merge both together, though possibly I’m misreading. Could you share the listing of an anat/ directory?

Ahhh ok. Sorry, I am slowing getting this.

If I specify a session-specific T2 image with a BIDS filter file. It will use the T2 image to refine the plial surface/send to Freesurfer for processing but is not specifically merged to the T1.

But in this case, a session-specific BIDS filter file like the one below is what I’d want (if I want to focus on session-specific processing). Here is a basic example of my bids data/ anat naming. I’ve changed my bids filter file to reflect the way I named the data.

My data 
     sub-01
          ses-01
              anat
                     sub-lsa101_ses-01_rec-orig_T1w.nii.gz
                     sub-lsa101_ses-01_rec-norm_T1w.nii.gz 
                     sub-lsa101_ses-01_rec-orig_T2w.nii.gz
                     sub-lsa101_ses-01_rec-norm_T2w.nii.gz 
              func
                      task1
                      task2
           ses-02
                    anat
                          sub-lsa101_ses-02_rec-orig_T1w.nii.gz
                          sub-lsa101_ses-02_rec-norm_T1w.nii.gz 
                          sub-lsa101_ses-02_rec-orig_T2w.nii.gz
                          sub-lsa101_ses-02_rec-norm_T2w.nii.gz 
                      func
                            task 1
                             task 2

Bids session specific filter - for session 02
“t1w”: {
“datatype”: “anat”,
“session”: “02”,
“suffix”: “T1w”
“reconstruction”:“orig”
},
{
“t2w”: {
“datatype”: “anat”,
“session”: “02”,
“reconstruction”:“orig”
“suffix”: “T2w”
},

Yes, this looks right (added some braces and spacing):

Thanks sooo much! @effigies