ANTsPy
ANTsPy copied to clipboard
resampling to new voxel
I want to convert the 3d 111 flair image of the same patient to 3d 115 flair. My code: from ants import crop_indices, pad_image, image_read,resample_image t2_ants = image_read(t2_path) t2_ants_resampled = resample_image(t2_ants,(1,1,5,3) , use_voxels=False, interp_type=4)
The image came in sagittal, but which I put in was the transverse plane. I couldn't understand where the wrong is. Thanks in advance!
For starters, the second argument should only have 3 elements (instead of 4).
I write 1,1,5 in my python command. Just here is typo. I couldnt fix the error. My images acquired originally 3d sequence. May it be something related to that?
Do i need to do different something from resampling? Like multiplanar reconstruction? My original image 111 doesnt have an orientation like sagittal, i can see it every axises
What program are you using to visualize your results?
I checked python output on Itksnap. I tried fsl for resampling and then, i checked them on fsleyes and mricron.
My guess is it's an issue related to package differences (e.g., nifty header). As a result, visualizations can vary. If you want me to take a closer look, you'll need to post the data.
datas.zip there are one reference image which I want the voxel size of and one input image (originally acquired 3d)
I add the resampled one. resampled.zip
and here the command was: t2_ants=image_read(path_t) t2_ants_resampled=resample_image(t2_ants, (0.67, 5.5, 0.67), use_voxels=False, interp_type=4)
thanks in advance.
Yeah, it's a nifti header issue, as mentioned above. If you open the image in ITK-SNAP, they're both consistently displayed (see below). As explained in the Wiki page, other packages, such as FSL, treat the header information so you have to be careful when mixing inputs/outputs.
I also displayed it this way on itk-snap. why does this python command display the sliced image this way? Shouldn't the result of the command (t2_ants_resampled=resample_image(t2_ants, (0.67, 0.67, 5.5), use_voxels=False, interp_type=4)) be axially sliced? not( (0.67, 5.5, 0.67))
the output of the command: flirt -in /ms/flairhigh.nii -ref /ms/flairtransvers.nii -applyxfm -out /ms/out It is sagittal again not axial. but the reference is axial
This is what I get when I resample and view the results within ANTs/ITK:
>>> import ants
>>> t2_ants = ants.image_read("3D_FLAIR.nii")
>>> t2_ants_resampled = ants.resample_image(t2_ants, (0.67, 0.67, 5.5), use_voxels=False, interp_type=4)
>>> t2_ants_resampled.spacing
(0.67, 0.67, 5.5)
We don't provide support that result from mixing packages.
Note that this is a much more general problem beyond ANTs that involves multiple neuroimaging packages. For example, see the discussion here.