External Email - Use Caution
Hello,
I produced an m3z warp file with mri_gradunwarp.
Now I need to 0 out all displacement in the z direction, while keeping everything else the same since I need to combine multiple warps from images with different geometries.
I see two strategies:
(1) working directly on the m3z file I could not get mri_convert or mris_calc to do the trick. I thought I nailed it by manually editing the m3z file in freeview, but freeview saves the results in mgz format :-( Is there anything else I missed?
(2) converting to mgz or nii timeseries, manupulate those and convert back to m3z mri_convert produced a nii file that freeview could not read and a single-frame mgz file that looks like some mishmash of the original 3-frame m3z.
Any idea on how I can acheive my goal?
A word on why would I want to do this silly thing. I have single-slice EPI and fov-matched higher-inplane-resolution single-slice GRE images. They have different within-slice gradient-non-linearity-related distortions. I want to undistort the GRE image then distort it to the EPI space. I need to zero out through-plane distortions to avoid displacing signal outside the imaging grid. Ignoring through-plane distortions should not be a problem for overlaying my GRE and EPI since, unlike within-plane distorsions, through-plane distortions are matched.
Thanks a lot for the help and Have a very good day! Sebastien
External Email - Use Caution
You might be able to convert it to a nifti (eg, with mri_warp_convert --outfsl), do your optionations, then convert it back to m3z
On 6/14/2023 4:08 PM, Proulx, Jean Sebastien wrote:
External Email - Use Caution
Hello,
I produced an m3z warp file with mri_gradunwarp.
Now I need to 0 out all displacement in the z direction, while keeping everything else the same since I need to combine multiple warps from images with different geometries.
I see two strategies:
(1) working directly on the m3z file I could not get mri_convert or mris_calc to do the trick. I thought I nailed it by manually editing the m3z file in freeview, but freeview saves the results in mgz format :-( Is there anything else I missed?
(2) converting to mgz or nii timeseries, manupulate those and convert back to m3z mri_convert produced a nii file that freeview could not read and a single-frame mgz file that looks like some mishmash of the original 3-frame m3z.
Any idea on how I can acheive my goal?
A word on why would I want to do this silly thing. I have single-slice EPI and fov-matched higher-inplane-resolution single-slice GRE images. They have different within-slice gradient-non-linearity-related distortions. I want to undistort the GRE image then distort it to the EPI space. I need to zero out through-plane distortions to avoid displacing signal outside the imaging grid. Ignoring through-plane distortions should not be a problem for overlaying my GRE and EPI since, unlike within-plane distorsions, through-plane distortions are matched.
Thanks a lot for the help and Have a very good day! Sebastien
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://secure-web.cisco.com/19DISE_M3EUAQCb0Su0WBCvsncgzoqKbaWLxgBnc_9TWTTD...
External Email - Use Caution
It worked, thanks!
I used --outvox instead if --outfsl, as --outfsl was "not implemented yet" (using dev) and it feels safer since the m3z seems to have voxel units.
For posterity, below is a snippet of the code I used:
gradFile=/space/freesurfer/unwarp/gradient_nonlin_unwarp/gradient_coil_files/coeff_SC72CD.grad for epiFile in $curBidsDir/func/*_bold.nii.gz; do curDerivDir=$(basename $epiFile) curDerivDir=${curDerivDir%.nii.gz} curDerivDir=$derivDir/${curDerivDir%.nii.gz} mkdir -p $curDerivDir ln $epiFile $curDerivDir/epi.nii.gz ### Compute warp mri_gradunwarp --gradcoeff $gradFile \ --i $curDerivDir/epi.nii.gz \ --interp cubic \ --o $curDerivDir/gradCor_epi.nii.gz \ --out_transtbl $curDerivDir/epi_gradWarp.m3z \ --nthreads 10 ### Zero-out z mri_warp_convert \ --inm3z $curDerivDir/epi_gradWarp.m3z \ --outvox $curDerivDir/epi_gradWarpVOX.nii.gz mri_convert -i $curDerivDir/epi_gradWarpVOX.nii.gz --split -o $curDerivDir/epi_gradWarpVOX.nii.gz mri_binarize --i $curDerivDir/epi_gradWarpVOX0002.nii.gz \ --min -inf --max +inf --binval 0 \ --o $curDerivDir/epi_gradWarpVOX0002.nii.gz mri_concat --o $curDerivDir/epi_gradWarpVOX.nii.gz --i $curDerivDir/epi_gradWarpVOX000?.nii.gz mri_warp_convert \ --invox $curDerivDir/epi_gradWarpVOX.nii.gz \ --insrcgeom $curDerivDir/epi.nii.gz \ --outm3z $curDerivDir/epi_gradWarpNoZ.m3z ### Clean rm $curDerivDir/epi_gradWarpVOX*nii.gz done
freesurfer@nmr.mgh.harvard.edu