nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
748 stars 530 forks source link

Register DTI maps onto FreeSurfer conformed space #2157

Closed anbai106 closed 7 years ago

anbai106 commented 7 years ago

Hi, nipype expert:

I have a question about registering DTI maps(10210272, 2mm2mm2mm) onto FreeSurfer conformed space(256256256, 1mm1mm1mm), so what i have done was:

1) register t1 on the umsample b0 image use flirt rigid registration, get the deformation matrix 2) apply the registration matrix for MD and AD, RD, FA maps with the inversed deformation matrix from step 1 to the FreeSurfer space 3) resample the registered FA map into the same size in Freesurfer space (256256256, 1mm1mm1mm)

I did try resampling the FA map before and after registration use mri_convert, but the results do not look well, even the resampling process changes also the space.

Any one have some suggestions?

Hao

oesteban commented 7 years ago

I'd say step 2 already includes step 3. I think there must be an additional qform/sform/tkras matrix you are not taking into account. WDYT @effigies ?

effigies commented 7 years ago

Just to be clear, you want a registration from B0 to FreeSurfer's subject-native volume space? If so, simply using bbregister onto the subject ought to work. Save the registration file, and you can apply it (using tkregister2, I believe) to anything that's in the same space as the B0.

I might be missing a complication, here, though.

oesteban commented 7 years ago

The complication is that @anbai106 seems to prefer FSL FLIRT. But, sure, bbregister would be a lot easier

effigies commented 7 years ago

Hmm. I guess it would be worth seeing the explicit code for the transforms. I'm a little confused why B0 is being up-sampled at all. It could be that I have zero experience with DTI.

I would assume MD, AD, RD and FA are aligned to B0, by definition, but if not, let's use (FA -> B0) to refer to that affine transform. If you register (B0 -> T1) (without upsampling), the transform for (FA -> T1) = (B0 -> T1) * (FA -> B0). FreeSurfer's lta_convert program can move between transform formats, if needed.

Registering (B0 -> T1), where T1 is the space defined by FreeSurfer's T1.mgz should be just as straightforward with FLIRT as bbregister, except you might need to mri_convert T1.mgz T1.nii to make FLIRT recognize it.

anbai106 commented 7 years ago

@oesteban @effigies, thanks for your recommendation, actually, after I get the transformation matrix from T1 to b0 (b0 and FA are in the same space), When I apply this deformation to register MD, I define a template_image to resample the output image and by viewing the registered MD and the brainmask.mgz(normalized T1.mgz in freesurfer), it is quite good, but when I segment the MD map with desikan atlas (aparc+aseg.mgz), the mean MD for subcortical structure looks good, but the mean MD for cortical surface ROI in this atlas give me some 0 in some regions, like the lateral occipital lobe which is not reasonable. From the registration results, it should not be 0 and the cortical surface MD should be higher. So I do not know if this is because the different resolution and image size(10210272, 2mm) between my MD and T1(256256256, 1mm1mm1mm), I tried different interpolation methods, like linear, cubic spline, sinc or nearest, but neitheir gives me ideal results...

What do you think about this??? The problem is from the resolution or the registration?

Hao

effigies commented 7 years ago

Apologies in advance for not addressing your direct questions, but I can't tell from what you've written what's going wrong. However, from what you're saying, I can describe how I would approach the problem:

To get ROI statistics, I would down-sample the atlas into the B0 space, using nearest-neighbor interpolation (you may need to use mri_label2vol to get a volume that can be resampled). Check the alignment of the resulting atlas volume with your MD map visually using freeview, and verify that the affines are the same (or close enough, using numpy.allclose). If both match, then you can straightforwardly run your stats. If not there may be other issues.

anbai106 commented 7 years ago

@oesteban @effigies Actually, I tried to register b0 to Freesurfer conformed space(brainmask.mgz) with different cost function, with bbregister, the result is not good however, I use the wmaparc.mgz to be the wm_seg volume, also tried wm.seg.mgz, not good, the command to run is:

flirt -in /Users/junhao.wen/test/NODDI/working_dir/noddi_postprocessing_pipeline/noddi_freesurfer_registration_pipeline2/get_b0/mapflow/_get_b00/sub-PREVDEMALS0010001BE_ses-M0_eddy_corrected_roi.nii.gz -ref /Users/junhao.wen/test/NODDI/working_dir/noddi_postprocessing_pipeline/noddi_freesurfer_registration_pipeline2/convert_t1_2_niigz/mapflow/_convert_t1_2_niigz0/brainmask_out.nii.gz -out sub-PREVDEMALS0010001BE_ses-M0_eddy_corrected_roi_flirt.nii.gz -omat sub-PREVDEMALS0010001BE_ses-M0_eddy_corrected_roi_flirt.mat -cost bbr -searchcost bbr -dof 6 -interp nearestneighbour -wmseg /Users/junhao.wen/test/NODDI/working_dir/noddi_postprocessing_pipeline/noddi_freesurfer_registration_pipeline2/convert_wmseg_2_niigz/mapflow/_convert_wmseg_2_niigz0/wmparc_out.nii.gz

The registered b0 image is not alligned with the t1 image at all...

Can you give me some suggestion?

oesteban commented 7 years ago

Other than FreeSurfer's official documentation, I found this: http://community.mrtrix.org/t/registration-of-structural-and-diffusion-weighted-data/203/11

anbai106 commented 7 years ago

@oesteban , thanks for the link, actually what I did is quite similar like what they propose, I use flirt to register t1 to b0 with flirt and apply this deformation to FA with mrtrix back to the FreeSurfer space, for the registration result, checking by eyes in freeview, the result is quite good, but the cortex statistics give me unreasonable value, I think I need to make some mask to check if the registration works really well in these cortex regions.

Thanks

oesteban commented 7 years ago

@anbai106, if you happen to find a robust workflow for this you are always welcome to contribute it here to nipype or maybe to https://github.com/poldracklab/niworkflows

oesteban commented 7 years ago

@anbai106 sorry for the repost. Digging up my records, I found this: http://brainybehavior.com/neuroimaging/2011/04/using-freesurfers-bbregister-for-image-registration/ . I used it some while ago (https://github.com/oesteban/RegSeg/issues/53#issuecomment-16376631). Unfortunatelly, I could not find a workflow using it.

anbai106 commented 7 years ago

@oesteban @effigies , another naive question, I think the registration for T1 and diffusion maps like FA is ok for me right now, but when I calculate the measures for the ROI from aparc+aseg.mgz, I get each lable's coordination from the label image(aparc+aseg.mgz) and then use the same coordination to get all the voxels in FA maps and calculate the mean of each ROI, do you think this is reasonable?? because the aparc+aseg.mgz is from FreeSurfer and FA maps get from Mrtrix, do you think maybe the two softwares have different coordination systems, that is why I get some 0 mean value? I have no MRI background, so if the question is stupid, please forgive me...

Thanks in advance

anbai106 commented 7 years ago

@oesteban @effigies I found the problem, actually, I use mrtrix to apply this transform and the coordiantion system is different with the one in aparc+aseg.mgz, that is why I got 0 value.

I do not know if my pipeline is clear or reliable enough, I will talk to my supervisor, I will contribute it in the future. Thanks for your help

Hao

oesteban commented 7 years ago

By contributing the pipeline you would get a code review for free, a public timestamp for your work and it can be reused (and cited).

anbai106 commented 7 years ago

@oesteban of course, no problem, that is the spirit of Nipype, sharing, actually I want to do more fancy thing, not just FA, and if the results look good, I will contribute my pipeline in Nipype community.

mgxd commented 7 years ago

@anbai106 feel free to open again if needed, and feel free to open a PR if you want to share the pipeline