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

python can't find itk-elastix on arm64 Mac #240

Closed
Pedro-Filipe opened this issue Aug 11, 2023 · 3 comments
Closed

python can't find itk-elastix on arm64 Mac #240

Pedro-Filipe opened this issue Aug 11, 2023 · 3 comments

Comments

@Pedro-Filipe
Copy link

Hi,

This issue happens on my M1 MacBook but not on my intel iMac.

I have a python env with itk and itk-elastix installed. I checked with pip show itk-elastix command that itk-elastix is installed in the env and in the same location as itk. But when I run this minimal code:

import itk
import numpy as np

img_a = np.zeros([128, 256], dtype=np.float32)
img_a[64, 32:42] = 1

img_b = np.zeros([128, 256], dtype=np.float32)
img_b[64, 42:52] = 1

img_ref = itk.GetImageFromArray(img_a)
img = itk.GetImageFromArray(img_b)

# register
img_reg, result_transform_parameters = itk.elastix_registration_method(img_ref, img)

print("Done!")

I get this error:

    img_ref = itk.GetImageFromArray(img_a)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'itk' has no attribute 'GetImageFromArray'

I think this means python can't find itk-elastix. Any tips on investigating why this is happening?

Many thanks.

@Pedro-Filipe
Copy link
Author

Pedro-Filipe commented Aug 11, 2023

Update: I can see the function GetImageFromArray in the env:
./.venv/lib/python3.10/site-packages/itk/support/extras.py

So not sure why I get this error!

@thewtex
Copy link
Member

thewtex commented Aug 16, 2023

Hi @Pedro-Filipe ,

Are you using itk-elastix==0.17.3 ? This is the latest version with mac ARM support that addressed a few previous issues.

@Pedro-Filipe
Copy link
Author

It worked! Thanks for the tip.

I had to update itk also to 5.4rc1.

❯ pip list
Package          Version
---------------- -------
itk              5.4rc1
itk-core         5.4rc1
itk-elastix      0.17.3
itk-filtering    5.4rc1
itk-io           5.4rc1
itk-numerics     5.4rc1
itk-registration 5.4rc1
itk-segmentation 5.4rc1
numpy            1.25.2
pip              23.2.1
setuptools       68.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants