ANTsPy icon indicating copy to clipboard operation
ANTsPy copied to clipboard

resampling to new voxel

Open dilekozkan opened this issue 1 year ago • 12 comments

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!

dilekozkan avatar Sep 02 '22 09:09 dilekozkan

For starters, the second argument should only have 3 elements (instead of 4).

ntustison avatar Sep 02 '22 14:09 ntustison

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?

dilekozkan avatar Sep 02 '22 14:09 dilekozkan

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

dilekozkan avatar Sep 02 '22 14:09 dilekozkan

What program are you using to visualize your results?

ntustison avatar Sep 02 '22 14:09 ntustison

I checked python output on Itksnap. I tried fsl for resampling and then, i checked them on fsleyes and mricron.

dilekozkan avatar Sep 02 '22 14:09 dilekozkan

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.

ntustison avatar Sep 02 '22 14:09 ntustison

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.

dilekozkan avatar Sep 04 '22 09:09 dilekozkan

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.

Screen Shot 2022-09-04 at 1 43 43 PM

ntustison avatar Sep 04 '22 20:09 ntustison

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))

dilekozkan avatar Sep 05 '22 07:09 dilekozkan

outputfsl.zip

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

dilekozkan avatar Sep 05 '22 07:09 dilekozkan

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.

ntustison avatar Sep 05 '22 16:09 ntustison

Note that this is a much more general problem beyond ANTs that involves multiple neuroimaging packages. For example, see the discussion here.

ntustison avatar Sep 05 '22 16:09 ntustison