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

Use SynthSeg outputs for 5TT #114

Open
smeisler opened this issue Oct 2, 2024 · 4 comments
Open

Use SynthSeg outputs for 5TT #114

smeisler opened this issue Oct 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@smeisler
Copy link
Contributor

smeisler commented Oct 2, 2024

Summary

Instead of FAST, use SynthSeg segmentations for 5TT/GMWMI generation

Additional details

FAST isn't great, and we already have SynthSeg outputs from QSIPrep

Next steps

Here is the full pipeline for 5ttgen fsl, with added comments / variable names. Basically, take the below code and create a custome 5ttgen command, skipping steps and replacing segmentation maps as needed.

# Change image strides
mrconvert $INPUT_T1.NII.GZ $INPUT.MIF
mrconvert $INPUT.MIF $CONFORMED_T1.NII -strides -1,+2,+3

# Register to MNI (Can be skipped because qsiprep does this)
maskfilter /Applications/fsl/data/standard/MNI152_T1_1mm_brain_mask_dil.nii.gz dilate mni_mask.nii -npass 4
standard_space_roi  $CONFORMED_T1.NII T1_preBET.nii.gz -maskMASK mni_mask.nii -roiFOV

# Mask T1 (can be skipped because qsiprep does this)
bet T1_preBET.nii.gz T1_BET.nii.gz -f 0.15 -R

# Segment T1
fast T1_BET.nii.gz # Can be skipped because qsiprep does this)
run_first_all -m none -s L_Accu,R_Accu,L_Caud,R_Caud,L_Pall,R_Pall,L_Puta,R_Puta,L_Thal,R_Thal -i T1.nii -o first

# Generating partial volume images for SGM structures
mrmath [mesh2voxel_*.mif] sum - | mrcalc - 1.0 -min all_sgms.mif
mrthreshold T1_BET_pve_2.nii.gz - -abs 0.001 | maskfilter - connect - -connectivity | mrcalc 1 - 1 -gt -sub remove_unconnected_wm_mask.mif -datatype bit

### HERE IS WHERE SYNTHSEG MAPS CAN COME IN!
mrcalc T1_BET_pve_0.nii.gz remove_unconnected_wm_mask.mif -mult csf.mif
mrcalc 1.0 csf.mif -sub all_sgms.mif -min sgm.mif
mrcalc 1.0 csf.mif sgm.mif -add -sub T1_BET_pve_1.nii.gz T1_BET_pve_2.nii.gz -add -div multiplier.mif
mrcalc multiplier.mif -finite multiplier.mif 0.0 -if multiplier_noNAN.mif
mrcalc T1_BET_pve_1.nii.gz multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult cgm.mif
mrcalc T1_BET_pve_2.nii.gz multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult wm.mif
mrcalc 0 wm.mif -min path.mif
mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - combined_precrop.mif -strides +2,+3,+4,+1
mrmath combined_precrop.mif sum - -axis 3 | mrthreshold - - -abs 0.5 | mrgrid combined_precrop.mif crop result.mif -mask -

# Save and check file
mrconvert result.mif $OUTPUT
5ttcheck result.mif
@smeisler smeisler added the enhancement New feature or request label Oct 2, 2024
@mattcieslak
Copy link
Contributor

What does it look like if you do the 5ttgen with freesurfer mode? That might be more similar to what we want to do with the synthseg outputs

@smeisler
Copy link
Contributor Author

smeisler commented Oct 2, 2024

From https://community.mrtrix.org/t/5ttgen-fsl-vs-5ttgen-freesurfer/5122:

5ttgen freesurfer isn’t very commonly used: while it is based on FreeSurfer segmentation, which is appealing, it’s a simple voxel-by-voxel mapping of binary tissue masks, so there are no partial volume estimates, that’s why it appears so jagged. Indeed it was intended primarily as an exercise in demonstrating that multiple algorithms can be proposed and implemented and distributed for a given image processing task…

The HSVS pipeline can be found here. still understanding where FAST outputs may be used. https://github.com/MRtrix3/mrtrix3/blob/fb66ec3f4c0012be8760dbc0ed52c1824b28b3af/lib/mrtrix3/_5ttgen/hsvs.py

@smeisler
Copy link
Contributor Author

smeisler commented Oct 2, 2024

It looks like in HSVS, FAST is only run in the cerebellum

@mattcieslak
Copy link
Contributor

so maybe it would make the most sense to try to get the synthseg outputs to look like fast outputs?

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

No branches or pull requests

2 participants