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

[WIP / ENH] Add Synb0-DisCo as a SYN Unwarp Method #546

Closed
wants to merge 2 commits into from

Conversation

smeisler
Copy link
Collaborator

@smeisler smeisler commented Apr 11, 2023

Changes proposed in this pull request

Addresses #90. Add Synb0-DisCo (paper, github) as an unwarping method.

SynB0-DisCo is being incorporated in the next release of DIPY, so the Python-ized version of this might be easier to incorporate into QSIPrep and provide advantages over the current ANTs implementation.

At a high level, I imagine the workflow would be something like

  1. Grab the best b0 (i.e., get_best_b0_topup_inputs_from)
    (Maybe we have to register b0 to T1?)
  2. Use the b0 and T1 to synthesize a RPE DWI contrast image using Synb0-DisCo
  3. Ingress that into whatever unwarping software is requested (TOPUP, 3dQWarp, DRBUDDI)

It would operate different from the ANTs method, which is pretty much its own workflow. This would be an intermediary step preceding the normal unwarping methods.

I will also ping @schillkg who developed the algorithm for additional insight.

@mattcieslak
Copy link
Collaborator

I love this idea. But I would recommend holding off on seriously coding for another week or so. I'm totally redoing the anatomical data workflow so users can specify whether they want to use a T1w or T2w as their anatomical reference. And the skull stripping and segmentation are going to be done by synthstrip and synthseg respectively. Anyways, the workflow will look very different soon, but once it's ready we should definitely give this a go!

@mattcieslak
Copy link
Collaborator

@smeisler I've been thinking about this one - how familiar are you with the workflow? I'm assuming the topup step happens before Eddy? I also wonder if the outputs from this could be used by DRBUDDI. I believe @eurotomania has used Synb0 with DRBUDDI with good results.

There may have to be two different workflows for synb0 disco depending on whether it's run with Eddy or SHORELine

@cookpa
Copy link
Collaborator

cookpa commented May 1, 2023

I definitely want to use this feature, happy to test things

@smeisler
Copy link
Collaborator Author

smeisler commented May 1, 2023

@mattcieslak The idea (@schillkg correct me if I am wrong) is that we can use Synb0 only to make a synthesized RPE b0-like image that would then be tunneled into whatever SDC workflow is requested. While the dockerized synb0-DISCO workflow may go through all of the SDC steps, the DIPY version should be a bit more modular, enabling us to do only the synthesis step.

@eurotomania
Copy link

eurotomania commented May 1, 2023 via email

@smeisler
Copy link
Collaborator Author

smeisler commented May 1, 2023

And here is a relevant part from the paper, so looks like TOPUP before EDDY:

Distortion correction was performed by first applying the trained network to a given MPRAGE dataset, resulting in the synthesized b0 image. The synthesized b0 was rigidly registered to the real b0 image (note that these will not, and do not have to, align perfectly as both motion and susceptibility distortions are estimated with TOPUP), and concatenated, which formed the input to TOPUP. TOPUP was then run on the merged b0 volume. Importantly, when setting up the acquisition parameters, the readout time (i.e., time between the center of the first echo and center of last echo) for the synthesized image is set to 0 (while the real b0 retains the correct readout time). This tells the algorithm that the synthesized b0 has an infinite bandwidth in the PE direction, with no distortions, thus fixing its geometry when estimating the susceptibility field. After this, conventional processing is performed, including eddy current correction (FSL eddy) and non-linear least squares diffusion tensor fitting and fractional anisotropy (FA) calculation.

@cookpa
Copy link
Collaborator

cookpa commented May 1, 2023

The docker implementation from the MASI lab will also output just the image if requested. Running topup is on by default but optional.

@schillkg
Copy link

schillkg commented May 1, 2023

@smeisler yes that is likely how it should be integrated into other packages. We've made available a --notopup flag with this in mind where we do not complete the full SDC pipeline. You can grab the synthesized image in native space (b0_u.nii.gz), or the combination of distorted+synthesized image (b0_all.nii.gz) and use as an input to your chosen package. Agree that the DIPY package may be more modular, but should be possible using both DIPY and this already existing docker/singularity.

@mattcieslak
Copy link
Collaborator

Ok, this is great! We can run the b0-synthesizing in the anatomical workflow where it will be accessible to all the dmri processing downstream.

@DelinteNicolas
Copy link

Any update on this pull request ? This feature would be a great addition

@smeisler smeisler marked this pull request as draft November 19, 2024 17:42
@smeisler smeisler closed this Nov 19, 2024
@emilyharriott
Copy link

emilyharriott commented Feb 12, 2025

Hi QSIprep team & friends! Thank you so much for all you do in building & maintaining these programs! :)

I am currently trying to figure out which RPE/field map approach works best for my data (ignore, use the RPEs/fmaps we acquired, use the --use-syn-sdc, or use b0_u.nii.gz from synb0 disco (following Kurt Schilling's instructions from May 1, 2023 (see above)). I could have absolutely missed something somewhere and I sincerely apologize if I did that, but did synb0 disco get incorporated into the pipeline already or is there further guidance on how to integrate it?

For context, using synb0 disco with the -notopup flag, I created a b0_u.nii.gz that I think looks good. I renamed b0_u.nii.gz to follow BIDS format and placed it in the proper /fmap/ folder of BIDSified QSIprep inputs. I kept the original fmap's original associated .json file in /fmap/ (was that wrong? does synb0 disco create a new .json file...?). I then ran QSIprep as normal. My outputs look bad (I'm looking at the .html output from QSIprep and the SDC gif looks very bad as does the gif of coregistration/alignment of dMRI & anatomical data) and I'm trying to figure out why! (that being said it very much so could be user error, and I am absolutely retracing my steps on that front, but I wanted to check in here, too - and again, apologies if I missed something)

Thank you so very much!
Emily

@smeisler
Copy link
Collaborator Author

Hi @emilyharriott,

The new synb0 PR, which we are still working on (got a lot of distractions along the way :/ ) is at #905.

In the meantime, what I would do is run synB0 using an average (or good-quality representative) b0, save the b0_u.nii.gz as an fmap epi in BIDS format, then make a JSON that has the reverse phase encoded direction and right IntendedFor key. I would set the TotalReadoutTime to be something like 0.05. I think that's the only keys you need for the fmap?

@emilyharriott
Copy link

emilyharriott commented Feb 12, 2025

@smeisler once again this is beyond helpful - thank you so much!

what if my average/good quality representative b0 (that went into synb0 disco to create b0_u.nii.gz) was in the i direction and my dw image (that will go into QSIprep) is in the j direction? in the JSON file I'm making, do I list the direction as j or i or even j-?

@smeisler
Copy link
Collaborator Author

hi @emilyharriott the b0 from the original DWI will always be same phase encoding direction as the DWI. You assign a new phase encoding direction (different sign, same axis) to the synb0 output so it can be used in SDC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants