pythonnumpypipantsantspyx

module 'ants' has no attribute 'from_numpy'


I am working in a jupyter notebook, and used pip to install ANTsPy:

pip install antspyx

However, using the function from_numpy throws an error:

import ants

Im2Use=Im[0,:,:,:]
fixed, moving, mytx=reg(Im2Use, t_rz)
fwdtransforms=mytx['fwdtransforms']
fixed_ants= ants.from_numpy(Im2Use.astype(float))
moving_ants= ants.from_numpy(t_rz.astype(float))
mywarpedimage=ants.apply_transforms( fixed=fixed_ants, moving=moving_ants,transformlist=fwdtransforms)

AttributeError: module 'ants' has no attribute 'from_numpy'

How can I solve this? I've also tried importing ants using import ants.from_numpy, but that did not work.


Solution

  • The issue in this case was scipy versioning. I downgraded from version 1.7.3 to version 1.2.0, which then solved the problem. Why? It's because ants library expects a function called "factorial" in scipy.misc, but version 1.7.3 moved the location of factorial.