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

Wrong fieldmap correction in 23.2.0 using opposite PE images #3229

Open
alexsayal opened this issue Feb 12, 2024 · 9 comments
Open

Wrong fieldmap correction in 23.2.0 using opposite PE images #3229

alexsayal opened this issue Feb 12, 2024 · 9 comments
Labels

Comments

@alexsayal
Copy link

What happened?

I am getting incorrect distortion correction results with the new release of fMRIPrep. Specifically, the new "Alignment between the anatomical reference of the fieldmap and the target EPI" step seems very off:

sub-01_ses-01_task-02a_run-1_desc-fmapCoreg_bold

This generates a bold corrected image with some weird spots and warps:

sub-01_ses-01_task-02a_run-1_desc-sdc_bold

In a different subject, it is a bit worse:

sub-10_ses-01_task-02a_run-1_desc-fmapCoreg_bold

I am using two spin-echo images with opposite phase encoding directions (AP and PA). This error was not found for version 23.1.2.

Do you have any suggestions? Thank you!

What command did you use?

udocker run \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2:/data \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2/derivatives/fmriprep2320:/out \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2/derivatives/fmriprepwork:/work \
    -v /users3/uccibit/alexsayal/freesurfer_license.txt:/licensefile \
    fmriprep2320 \
    --participant_label $SUBJECT \
    --fs-license-file /licensefile \
    /data /out participant \
    -w /work \
    --stop-on-first-crash \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --mem=85G \
    --skip_bids_validation

What version of fMRIPrep are you running?

23.2.0

How are you running fMRIPrep?

Docker

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

@alexsayal alexsayal added the bug label Feb 12, 2024
@effigies
Copy link
Member

Can you share screenshots of the before/after images? GitHub doesn't like to show animated SVGs.

@alexsayal
Copy link
Author

Here they are for the first subject:

1_correctedbold
1_distortedbold
1_fmapref
1_boldref

@effigies
Copy link
Member

Thanks. That's definitely a bad boldref/fmapref alignment, probably due to such different contrasts in your BOLD and your fieldmap inputs. What images are used as inputs to your fieldmap estimation for this BOLD series?

@alexsayal
Copy link
Author

I am using two spin-echo EPI images, known as Spin-Echo Fieldmaps in human connectome project nomenclature. Their geometry and echo spacing matches the functional BOLD images. I can send an example if it helps.

@effigies
Copy link
Member

A listing of the files for this subject would be fine. It sounds like something like:

sub-01/
  fmap/
    sub-01_dir-AP_epi.nii.gz  # single-band
    sub-01_dir-PA_epi.nii.gz  # single-band
  func/
    sub-01_task-sometask_bold.nii.gz  # dir-AP, multiband

If your fieldmaps are already well-aligned to your BOLD, you could try passing in a --derivatives directory containing an identity fmapreg file:

$PRECOMPUTED/
  sub-01/
    func/
      sub-01_task-sometask_from-boldref_to-auto00000_mode-image_xfm.txt

(You'll need to specify the correct fieldmap identifier. You should be able to find the one associated with your BOLD image in your output directory.)

You would then rerun with:

fmriprep $INPUT $OUTPUT participant --derivatives fmapreg=$PRECOMPUTED ...

@alexsayal
Copy link
Author

The following command does not work - it assumes 'fmapreg' is part of the path. What am I missing?

udocker run \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2:/data \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2/derivatives/fmriprep2320:/out \
    -v /users3/uccibit/alexsayal/BIDS-BRAINPLAYBACK-TASK2/derivatives/fmriprepwork:/work \
    -v /users3/uccibit/alexsayal/freesurfer_license.txt:/licensefile \
    fmriprep2320 \
    --participant_label $SUBJECT \
    --fs-license-file /licensefile \
    /data /out participant \
    -w /work \
    --stop-on-first-crash \
    --output-spaces MNI152NLin2009cAsym:res-2 \
    --mem=85G \
    --skip_bids_validation \
    --derivatives fmapreg=/out

@alexsayal
Copy link
Author

Also, you are right about the file listing. Now I have added the transformation matrices as such:

image

@effigies
Copy link
Member

Ah, for some reason I thought that we used named derivatives, but it looks like it's just a list of paths.

You can use --derivatives /out, though I would personally not mix up my inputs and outputs like that. I would probably organize things like:

fmriprep/
    sourcedata/
        raw/
        freesurfer/
        fmapreg/

Then from within fmriprep:

fmriprep sourcedata/raw . participant --derivatives sourcedata/fmapreg ...

You're of course welcome to organize things however you like, but I get paranoid about telling a program that it can write out to one of the input directories.

@alexsayal
Copy link
Author

Thank you, it is now working as expected. I still think the final image is better corrected and aligned to the anatomical with version 23.1.2, so I will keep using that version for now.
One possiblity to explore is to invert the colors of the SPE image before entering fmriPrep to see if it helps the registration to the functional EPI. Do you have any hints for this? This correction algorithm was optimized for images of the same type, right?

@effigies effigies added sdc and removed bug labels Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants