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.
CodePudding user response:
Can you please specify your IDE if you took care of activating the virtualenv?
Anyways here are the steps to make sure that the python module is propoerly installed in your virtual environment :
python3 -m venv env_name
: this will create a virtual env in your current pathsource env/bin/activate
: this will activate your virtual env (if on windows just cd into activate within your env name.\env\Scripts\activate
- If your using vscode hit ctrl shift p then select interpreter then go to your created env
- now we have our virtual environment just hit
pip install antspyx
then check withpip list
and see in your terminal if the package is propoerly installed - If you still have the error restart your IDE
CodePudding user response:
have you tried:
from ants import from_numpy