Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding sbrefs for the coregistration reference causes poor registration in low contrast multiband sequences #3056

Closed
effigies opened this issue Jul 7, 2023 · 20 comments

Comments

@effigies
Copy link
Member

effigies commented Jul 7, 2023

What happened?

Reported in https://neurostars.org/t/poor-func-anatomical-registration-with-fmriprep-21-0-2-on-multi-echo-data-set/26217, coregistration is poor. We currently use sbrefs for the initial boldref, but not for the final, which means that we have the benefit of high contrast for HMC, where it matters less, and not for coregistration, where it matters more.

What command did you use?

singularity run --cleanenv -B /projects/:/projects/\
    -B ${WORK_DIR}:/quest_scratch \
    /projects/singularity_images/fmriprep-21.0.2.simg \
    ${BIDS_DIR} \
    ${BIDS_DIR}/${DERIVS_DIR} \
    participant --participant-label ${subject} \
    -w /quest_scratch --omp-nthreads 8 --nthreads 16 \
    --fs-license-file /projects/singularity_images/freesurfer_license.txt \
    --fs-subjects-dir ${BIDS_DIR}/${DERIVS_DIR}/sourcedata/freesurfer \
    --output-spaces MNI152NLin6Asym:res-2 \
    --ignore slicetiming --fd-spike-threshold 0.2 --me-output-echos --resource-monitor

What version of fMRIPrep are you running?

21.0.2 and 23.0.2

How are you running fMRIPrep?

Singularity

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

No response

Additional information / screenshots

No response

@oesteban
Copy link
Member

oesteban commented Aug 2, 2023

I'm not even sure SBRefs should be used at all. We probably want to dismiss them totally: for realignment (head-motion estimation, if you want to be precise) I have the impression that a monomodal cost function (with monomodal inputs, i.e., the time series and a reference extracted FROM the time series) should be generally way more reliable than a multimodal cost function (as mutual information) against the SBRef.

I'd advocate for using SBRefs only in fieldmap estimation by SDCFlows.

WDYT?

@effigies
Copy link
Member Author

effigies commented Aug 2, 2023

I agree that we should stop using sbref for head motion estimation and sbref for SDC. I think we want to use the fieldmap-corrected sbref for coregistration, as it should have better gray/white contrast for boundary-based registration.

@effigies
Copy link
Member Author

effigies commented Aug 2, 2023

Here's my current thinking (updated from #3058):

graph TB;
    sbref.nii---->desc-intermediate_boldref.nii;
    bold.nii --> desc-hmc_boldref.nii;
    desc-hmc_boldref.nii--->desc-intermediate_boldref.nii;
    bold.nii --> from-orig_to-boldref_xfm.txt;
    desc-hmc_boldref.nii-->from-orig_to-boldref_xfm.txt;
    fmap.nii----->from-fmap_to-boldref_xfm.txt;
    desc-intermediate_boldref.nii-->from-fmap_to-boldref_xfm.txt;
    fmap.nii---->space-boldref_fmap.nii;
    from-fmap_to-boldref_xfm.txt-->space-boldref_fmap.nii;
    space-boldref_fmap.nii-->desc-coreg_boldref.nii;
    desc-intermediate_boldref.nii-->desc-coreg_boldref.nii;
    desc-coreg_boldref.nii-->from-boldref_to-T1w_xfm.txt;

@oesteban
Copy link
Member

oesteban commented Aug 3, 2023

I would suggest something like:

graph TB;
    bold.nii --> desc-hmc_boldref.nii;
    bold.nii --> from-orig_to-boldref_xfm.txt;
    bold.nii--->desc-hmc+sdc_boldref.nii;
    sbref.nii --> fmap.nii;
    epi.nii --> fmap.nii;
    sbref.nii --> fmapref.nii;
    epi.nii --> fmapref.nii;
    desc-hmc_boldref.nii --> from-orig_to-boldref_xfm.txt;
    from-orig_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    fmapref.nii--->from-fmap_to-boldref_xfm.txt;
    fmap.nii--->desc-hmc+sdc_bold.nii;
    desc-hmc_boldref.nii--->from-fmap_to-boldref_xfm.txt;
    from-fmap_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    desc-hmc+sdc_bold.nii--->desc-hmc+sdc_boldref.nii;
    desc-hmc+sdc_boldref.nii--->from-boldref_to-T1w.xfm;

With the following variations, (1) if all PEs are encoded by EPIs under fmap/ then the sbref can be dismissed if present:

graph TB;
    bold.nii --> desc-hmc_boldref.nii;
    bold.nii --> from-orig_to-boldref_xfm.txt;
    bold.nii--->desc-hmc+sdc_boldref.nii;
    dir-AP_epi.nii --> fmap.nii;
    dir-PA_epi.nii --> fmap.nii;
    dir-AP_epi.nii --> fmapref.nii;
    dir-PA_epi.nii --> fmapref.nii;
    desc-hmc_boldref.nii --> from-orig_to-boldref_xfm.txt;
    from-orig_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    fmapref.nii--->from-fmap_to-boldref_xfm.txt;
    fmap.nii--->desc-hmc+sdc_bold.nii;
    desc-hmc_boldref.nii--->from-fmap_to-boldref_xfm.txt;
    from-fmap_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    desc-hmc+sdc_bold.nii--->desc-hmc+sdc_boldref.nii;
    desc-hmc+sdc_boldref.nii--->from-boldref_to-T1w.xfm;

If the fieldmap comes from a phasediff:

graph TB;
    bold.nii --> desc-hmc_boldref.nii;
    bold.nii --> from-orig_to-boldref_xfm.txt;
    bold.nii--->desc-hmc+sdc_boldref.nii;
    phasediff.nii --> fmap.nii;
    magnitude.nii --> fmapref.nii;
    desc-hmc_boldref.nii --> from-orig_to-boldref_xfm.txt;
    from-orig_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    fmapref.nii--->from-fmap_to-boldref_xfm.txt;
    fmap.nii--->desc-hmc+sdc_bold.nii;
    desc-hmc_boldref.nii--->from-fmap_to-boldref_xfm.txt;
    from-fmap_to-boldref_xfm.txt--->desc-hmc+sdc_bold.nii;
    desc-hmc+sdc_bold.nii--->desc-hmc+sdc_boldref.nii;
    desc-hmc+sdc_boldref.nii--->from-boldref_to-T1w.xfm;

@effigies
Copy link
Member Author

effigies commented Aug 3, 2023

But why do we not want to use sbref for coregistration? That does not make any sense to me.

@oesteban
Copy link
Member

oesteban commented Aug 3, 2023

But why do we not want to use sbref for coregistration? That does not make any sense to me.

Fair point. I'll try to see if that automatically translates my proposal into yours.

@effigies
Copy link
Member Author

effigies commented Aug 3, 2023

Also, a lot of these details about pepolar/phasediff should be abstracted by sdcflows. But if we take fmapref and fmap as given, my graph becomes:

graph TB;
    bold.nii --> desc-hmc_boldref.nii;
    sbref.nii--->desc-intermediate_boldref.nii;
    desc-hmc_boldref.nii-->desc-intermediate_boldref.nii;
    bold.nii --> from-orig_to-boldref_xfm.txt;
    desc-hmc_boldref.nii-->from-orig_to-boldref_xfm.txt;
    fmapref.nii---->from-fmap_to-boldref_xfm.txt;
    desc-intermediate_boldref.nii-->from-fmap_to-boldref_xfm.txt;
    fmap.nii----->space-boldref_fmap.nii;
    from-fmap_to-boldref_xfm.txt-->space-boldref_fmap.nii;
    space-boldref_fmap.nii-->desc-coreg_boldref.nii;
    desc-intermediate_boldref.nii-->desc-coreg_boldref.nii;
    desc-coreg_boldref.nii-->from-boldref_to-T1w_xfm.txt;

Where the intermediate boldref is either the HMC boldref or the sbref, with preference to sbref.

@DVSneuro
Copy link

Hi @effigies and @oesteban -- apologies if this should be a new issue, but I'd like to throw out one additional consideration with respect to sbrefs, coregistration, motion correction, and distortion correction.

This is probably an edge case -- and for context note there was some discussion of this issue on the heudiconv page (see nipy/heudiconv#549 (comment)) -- but when users are collecting phase and magnitude images for their functionals (e.g., multi-echo sequences), it looks like fmriprep averages across the sbref images and then uses the average phase and magnitude image as sbref.nii in the graphs above. In my case, I have two sbref images for each functional run (part-phase_sbref and part-mag_sbref). I've ran fmriprep with both images in there and also after deleting the part-phase_sbref image and renaming the part-mag_sbref to remove the part-mag. Comparing these two scenarios, I can see that the carpet plots look very different (suggesting a different reference image). I think the "corrected" image in the distortion correction looks the same, but the "distorted" image (maybe the average of part-phase_sbref and part-mag_sbref?) looks very different to me. See below.

Running fmriprep with part-phase_sbref and part-mag_sbref:

image

Running fmriprep after deleting part-phase_sbref and renaming part-mag_sbref):

image

I know the fmriprep team is still working out how it handles sbref images (#1511), but hopefully this isn't too much of an edge case to merit some attention sooner rather than later. I'd be happy to share some data if it's helpful.

Thanks!
David

@effigies
Copy link
Member Author

effigies commented Aug 19, 2023

Yes, we should update our queries to take part mag or None. That's a quick fix, and you can use it in a BIDS filter file (see FAQ) already.

@DVSneuro
Copy link

Great, thanks! I'll create a config.json file to feed into the --bids-filter-file where I will change the suffix for the sbref image like I have below:

{
  "fmap": {"datatype": "fmap"},
  "bold": {"datatype": "func", "suffix": "bold"},
  "sbref": {"datatype": "func", "suffix": "part-mag_sbref"},
  "flair": {"datatype": "anat", "suffix": "FLAIR"},
  "t2w": {"datatype": "anat", "suffix": "T2w"},
  "t1w": {"datatype": "anat", "suffix": "T1w"},
  "roi": {"datatype": "anat", "suffix": "roi"}
}

This should be much better/easier than deleting and renaming various files.

Thanks again!
David

@effigies
Copy link
Member Author

effigies commented Aug 20, 2023

This won't work:

  "sbref": {"datatype": "func", "suffix": "part-mag_sbref"},

You'll need to specify the part entity:

  "sbref": {"datatype": "func", "suffix": "sbref", "part": [null, "mag"]},

That will accept files that either do not have a part entity, or part == "mag".

Also, you only need to update the filters that you're changing from the default, so your whole file could be:

{
  "sbref": {"datatype": "func", "suffix": "sbref", "part": [null, "mag"]}
}

@DVSneuro
Copy link

Wonderful! Thanks for the fix!

@zachladwig
Copy link

Hi @effigies @oesteban I just wanted to confirm that until this is changed, strategies like this one https://neurostars.org/t/fmriprep-coregistration-within-sessions/5891/6 won't work to align bold across sessions right?

@zachladwig
Copy link

@effigies sorry to bother you! but we want to implement something where we can ensure good cross-session registration of BOLD data in the same subject like here (https://neurostars.org/t/fmriprep-coregistration-within-sessions/5891/6). Ideally we'd like to use fmriprep since thats what we already use and I am hoping there is some way I can implement it. Do you have any suggestions?

@effigies
Copy link
Member Author

Hi @zachladwig, I think that approach should still work, since you won't be depending on using the sbrefs for their contrast, just their position.

@zachladwig
Copy link

zachladwig commented Sep 25, 2023

got it, so because it uses the sbref for HMC, it will align all of the runs to each other (if I pass it in a fake mean sbref).

But, it will not use them for registration. So all of the runs will be aligned to each other (via HMC), but their registration to T1 will be sub-optimal because I will not have the high contrast from the sbref. Right?

@effigies
Copy link
Member Author

The registration will use a boldref created from each BOLD series aligned to your fake sbref. So the registration should be fine. The current problem is not with how realignment happens, just with using suboptimal contrasts.

@zachladwig
Copy link

ah okay i think I understand. thank you for your help

@effigies
Copy link
Member Author

effigies commented Oct 4, 2023

This is fixed in next.

@zachladwig
Copy link

great!

@effigies effigies added the next label Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants