ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
637 stars 162 forks source link

raise ValueError('images with more than 1 component not currently supported') ValueError: images with more than 1 component not currently supported #716

Closed hz1z closed 2 weeks ago

hz1z commented 2 weeks ago

I want to rasample a 3d tmax img, but it seem not support. my antspy version is 0.4.2.

Do I need to modify the code, or has a higher version of antspy already supported the resample of colored tmax.

import ants

fix_img_pt = '/home/hyh/datasets/me_test/tmax/tmax_dcm.nii.gz'
fix_img = ants.image_read(fix_img_pt)
resample_img = ants.resample_image(fix_img,(2.5,2.5),
                                   False,1)
save_path = 'resample_img.nii.gz'
ants.image_write(resample_img,save_path)
print(fix_img)

image

ntustison commented 2 weeks ago

The direct application of a the resample function is only applicable to single component images. If you wish to resample multi-component images, you need to first split the channels (see ants.split_channels), resample each channel/component separately, and then merge the results (see ants.merge_channels).

hz1z commented 2 weeks ago

thanks your reply