Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ants.convolve_image bug #498

Open
pogos-ed opened this issue Aug 3, 2023 · 4 comments
Open

ants.convolve_image bug #498

pogos-ed opened this issue Aug 3, 2023 · 4 comments
Labels

Comments

@pogos-ed
Copy link

pogos-ed commented Aug 3, 2023

Running ants.convolve_image gives error:

File ".../venv/lib/python3.9/site-packages/ants/utils/invariant_image_similarity.py", line 247, in convolve_image
libfn = utils.get_lib_fn('convolveImageF%i' % image.dimension)
File ".../venv/lib/python3.9/site-packages/ants/utils/process_args.py", line 29, in get_lib_fn
return lib.dict[string]
KeyError: 'convolveImageF3'

To reproduce the error use the code below and npz file I uploaded:

import numpy as np 
import ants

npzfile = np.load(in_file)
junction_im_thr = npzfile['junction_im_thr']
ants_conv_kernel = ants.make_image([5,5,5], 1, [1,1,1], [5,5,5])
junction_im_convolved = ants.convolve_image( ants.from_numpy(junction_im_thr.astype('double')), ants_conv_kernel)

I used antspyx 0.3.8 and python 3.9.
junction_im_thr.npz.zip

@ntustison
Copy link
Member

I'm running into issues with the code/input data:

>>> in_file = "junction_im_thr.npz.zip"
>>> npzfile = np.load(in_file)
>>> junction_im_thr = npzfile['junction_im_thr']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ntustison/miniforge3/envs/antsx/lib/python3.8/site-packages/numpy/lib/npyio.py", line 251, in __getitem__
    raise KeyError("%s is not a file in the archive" % key)
KeyError: 'junction_im_thr is not a file in the archive'

@pogos-ed
Copy link
Author

pogos-ed commented Aug 3, 2023

Sorry, I did mistake when I save the file. Unzip the new one, then:

in_file = "junction_im_thr.npy"
junction_im_thr = np.load(in_file)

junction_im_thr.npy.zip

@ntustison
Copy link
Member

Okay, it would appear that the underlying interface to ITK's convolution image filter is completely absent. So this doesn't work for any image of any dimensionality. This problematic code has been here for awhile so it's obvious that it's not used at all or it would've been discovered previously. You're welcome to work on a pull request to fix it or I might get around to it at some point.

@pogos-ed
Copy link
Author

pogos-ed commented Aug 3, 2023

Ok, thanks for clarification.

@cookpa cookpa added the bug label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants