Open Planetdtudy opened 2 months ago
Are you certain image is a string? I can read ".nii" files on my machine.
What happens if you do
type(image)
?
If image is an image and not a str, you'll see this error.
Thank you. But it is a nii file. And I can read it with nibabel package.
OK, I'm going to try to replicate more closely. What antspyx version do you have installed? (pip freeze | grep ants) What OS are you using?
Should I use something like this img = ants.image_read(ants.get_ants_data('brain.nii'))
ants.get_ants_data
is a convenience function to return the path to certain built-in ANTs images for examples. It should return a string, so you will see things like
img = ants.image_read(ants.get_ants_data('mni'))
If you have a string, then using your example
image='path/brain.nii'
img = ants.image_read(image)
should work. What happens if you use the literal string?
img = ants.image_read('path/brain.nii')
Sonoma, pip freeze | grep ants antspyx==0.3.8
img = ants.image_read('path/brain.nii') - seams like it works.
Very weird. But
fn = 'path/brain.nii'
type(fn)
img = ants.image_read(fn)
doesn't work? I'm having a hard time imagining how that could happen. Might be worth upgrading to 0.4.2, just in case there was some logic fix I missed.
I think this error might also be caused by running python from the ANTsPy/ source directory
Hi, I am trying to use ANTS, but getting this issue:
I am trying to open .nii file
image='path/brain.nii'
brain_extracted_image = ants.image_read(image) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ants/core/ants_image_io.py", line 495, in image_read if filename.endswith(".npy"): AttributeError: 'ANTsImage' object has no attribute 'endswith'