Fmriprep T2 images

I have been using fmriprep to successfully process my T1w and BOLD images. My data set also includes FLAIR images. I would like to include these images in the analysis. My end goal is to have the T2 FLAIR images skull stripped in native space and transform the images into MNI space.

My current understanding of fmriprep and T2/FLAIR images is from the documentation. The fmriprep docs uses the workflow fmriprep.workflows.anatomical.init_anat_preproc_wf. This workflow includes T2 and FLAIR images as inputs. It lists the outputs as transforms of the T1w images to MNI space. It looks like the workflow FLAIR images may be used to improve the processing of the pial surface in FreeSurfer with the workflow fmriprep.workflows.anatomical.init_surface_recon_wf.

I am using the BIDS format. Images in my anat directory are T2 or FLAIR. I have tried both. However, these images don’t seem to be incorporated into the fmriprep processing. There doesn’t seem to be a switch in the fmriprep help to specifically tell it to include T2 or FLAIR images into the analysis.

Are my expectations that T2 images can also be processed by fmriprep? If not is it acceptable to run freesurfer to process the T2/FLAIR images as described here
recon-all -subject subjectname -T2 /path/to/T2_volume -T2pial -autorecon3

Your help and suggestions are greatly appreciated.



T2w and FLAIR images are automatically added to FreeSurfer, so it will use them to refine the pial surface (so the the command you showed is run), but we do not currently register these images to the T1w template spaces and place them in the derivatives directory.

We would certainly welcome a contribution here; it shouldn’t be too much work, actually. The main question is what the best tool to coregister to T1w would be. After that, it’s a question of setting up the transforms and copying the outputs to the derivatives.

1 Like

Thank you for the clarification. I will look closer at the output of freesurfer. I am hoping that the registration has already been done and I can just apply these transformations.

Following Chris’s advice I have looked into this a little more. If I have a T2w image in my fmriprep anat folder then fmriprep detects the T2w image and processes it along with the T1w image in the freesurfer mri directory.

Here is the contents of my anat folder for a single subject containing a T2w image.

aging1a ➜  anat llr
total 29822
-rw-rw-r-- 1 bkraft infinite     1312 Feb 19  2018 sub-imove1011_ses-1_T1w.json
-rw-rw-r-- 1 bkraft infinite     1351 Feb 19  2018 sub-imove1011_ses-1_T2w.json
-rw-rw---- 1 bkraft infinite 10956897 Feb 19  2018 sub-imove1011_ses-1_T1w.nii.gz
-rw-rw---- 1 bkraft infinite  9050621 Feb 19  2018 sub-imove1011_ses-1_T2w.nii.gz

Here is the corresponding freesurfer/mri directory

aging1a ➜  mri ls
aparc.a2009s+aseg.mgz                    orig           T2.prenorm.mgz
aparc+aseg.mgz                           brainmask.mgz               orig.mgz       talairach.label_intensities.txt
aparc.DKTatlas+aseg.mgz                  brain.mgz                   orig_nu.mgz    talairach.log                            ctrl_pts.mgz                rawavg.mgz     transforms
aseg.auto_noCCseg.label_intensities.txt  filled.mgz                  rh.ribbon.mgz  wm.asegedit.mgz
aseg.auto_noCCseg.mgz                    lh.ribbon.mgz               ribbon.mgz     wm.mgz
aseg.mgz                                 mri_nu_correct.mni.log      segment.dat    wmparc.mgz
aseg.presurf.hypos.mgz                   mri_nu_correct.mni.log.bak  T1.mgz         wm.seg.mgz
aseg.presurf.mgz                         norm.mgz                    T2.mgz
brain.finalsurfs.mgz                     nu.mgz                      T2.norm.mgz

You can see the T2 images in the mri directory.

If I do the same thing with FLAIR images.

aging1a ➜  anat llr
total 27982
-rw-rw---- 1 bkraft infinite     1351 Aug 29 11:54 sub-imove9011_ses-1_FLAIR.json
-rw-rw---- 1 bkraft infinite 10956897 Aug 29 11:54 sub-imove9011_ses-1_T1w.nii.gz
-rw-rw---- 1 bkraft infinite  9050621 Aug 29 11:54 sub-imove9011_ses-1_FLAIR.nii.gz
-rw-rw---- 1 bkraft infinite     1312 Aug 29 11:54 sub-imove9011_ses-1_T1w.json

Here is the corresponding freesurfer/mri directory

aging1a ➜  mri ls
aparc.a2009s+aseg.mgz                    brain.finalsurfs.mgz        norm.mgz       T1.mgz
aparc+aseg.mgz                           nu.mgz         talairach.label_intensities.txt
aparc.DKTatlas+aseg.mgz                  brainmask.mgz               orig           talairach.log                            brain.mgz                   orig.mgz       transforms
aseg.auto_noCCseg.label_intensities.txt  ctrl_pts.mgz                orig_nu.mgz    wm.asegedit.mgz
aseg.auto_noCCseg.mgz                    filled.mgz                  rawavg.mgz     wm.mgz
aseg.mgz                                 lh.ribbon.mgz               rh.ribbon.mgz  wmparc.mgz
aseg.presurf.hypos.mgz                   mri_nu_correct.mni.log      ribbon.mgz     wm.seg.mgz
aseg.presurf.mgz                         mri_nu_correct.mni.log.bak  segment.dat

There is no corresponding FLAIR images. I have processed other data sets with FLAIR images directly with FreeSurfer’s recon-all scripts. Here is a snippet of that output.

aging1a ➜  mri ls
aparc.a2009s+aseg.mgz                                        mri_nu_correct.mni.log.bak
aparc+aseg.mgz                                               norm.mgz                                                nu.mgz
aseg.auto_noCCseg.label_intensities.txt                      nu_noneck.mgz
aseg.auto_noCCseg.mgz                                        orig
aseg.mgz                                                     orig.mgz
brain.finalsurfs.manedit.mgz                                 orig_nu.log
brain.finalsurfs.mgz                                         orig_nu.mgz
brain.finalsurfs.mgz.qm_edit_pial.bkraft.d20161215_110456    overlay_ortho.png
brain.finalsurfs.mgz.qm_edit_pial.clinvill.d20161214_134308  rawavg.mgz
brain.finalsurfs.mgz.qm_edit_pial.clinvill.d20161214_135103  rh.ribbon.mgz                                           ribbon.mgz
brainmask.mgz                                                segment.dat
brain.mgz                                                    transforms
ctrl_pts.mgz                                                 wm.asegedit.mgz
filled.mgz                                                   wm.mgz
FLAIR.mgz                                                    wmparc.mgz
lh.ribbon.mgz                                                wm.seg.mgz

The FLAIR images are clearly present in the standard FreeSurfer recon-all processing.

I checked the logs of the fmriprep processing the FLAIR images and I didn’t see any errors or anything out of the ordinary.

Any suggestions on what is the next step to track down this problem, which could be human error on my part, would be greatly appreciated.



Just to clarify, you’re saying you have T2w images and FLAIR images, and want both to be used in FreeSurfer? FreeSurfer will only use one or the other, and we have preferred to send T2w images over FLAIR images to FreeSurfer. So this is what is expected, if not what you want.

But it sounds like what you really want is T2w and FLAIR coregistered to T1w in the derivatives directory… I think that will be best handled in fMRIPrep, as the T1w output is not necessarily aligned (the difference is a rigid transform) to the FreeSurfer T1.mgz.

My apologies for not being clear. I understand that FreeSurfer only uses T2w or FLAIR images but not both. I am only interested in one or the other. We collect FLAIR images to measure white matter lesion load.

My end goal is just as you said. I want “FLAIR coregistered to T1w”. I thought if the FLAIR images are co-registered to the T1w images in the FreeSurfer. Eventually, I would also like the FLAIR images in the MNI space. I was thinking that I could apply the same T1w transforms to the FLAIR images to normalize the FLAIR images to MNI space.

Sorry to take so long to get back. There are basically two issues here:

  1. It looks like there’s a bug in FLAIR handling. I’m not sure why it’s not getting included in the FreeSurfer directories. Until this is fixed, you can manually add it like so:
recon-all -s $SUBJID -flair $FLAIRIMG -autorecon3 -flairpial
  1. Getting outputs registered to T1w images. If you’re happy working in the FreeSurfer space (we refer to it as fsnative, and it may vary slightly from the T1w space, as FreeSurfer does their own recentering), then you can use the updated FLAIR image found in the FreeSurfer directory. However, what I had been initially suggesting is that it would probably be a useful addition to register the FLAIR or T2 images to the T1w space and include it in the fMRIPrep derivatives. It would then be trivial to add a transform to output these images in the template space, as well. Registering other modalities is on our to-do list, but if you’re interested in taking a crack at it, we’d be glad to guide you through the process.

I am trying to do the same thing and was wondering if there was any progress on this issue since you discussed it here?


I have the opposite question. Can you turn off use of T2/FLAIR ?

We should be able to add an --ignore T2w or similar option. Please open an issue on GitHub for a feature request.

Incidentally, the reason we never added an --ignore T2w option was that we hadn’t encountered a case where T2w images of reasonable resolution didn’t improve surface reconstruction. T2w images with voxel sizes >= 1.2mm are already ignored, as suggested by FreeSurfer. Could you describe this case better?

In our case, the protocol has an anisotropic partial coverage hippocampal T2 and a 1 mm FLAIR which isn’t always collected.

I’ve opened an issue regarding ignoring T2w/FLAIR here:

Thanks for looking at this!

Hi, are FLAIR images with voxel size >= 1.2mm automatically ignored in fmriprep pipeline? Or only T2w ones?


FLAIR is treated the same as T2w, with the exception that T2w is preferred if both are present.