ANTsPy: ITK ERROR: CenteredTransformInitializer: Fixed Image has not been set

hi

i have problem with registration with ants. i install ants with pip in windows os but when I try this code below for registration I get error that is mentioned: my code:

  registration_path = r"E:\python_venv/medvispy/mri_skull_plugin/savepath"
  input_sample_path = "E:\python_venv\input_sample2/MR_N1.nii"
  database_path = r"E:\python_venv/medvispy/mri_skull_plugin/plugin"

  fname1 = ants.image_read(str(input_sample_path))
   for i in range(1, 8):
       print(f"image {i} out of 8")
       fname2 = ants.image_read(str(database_path / "MR_N{}.nii".format(i)))
       print("error here")
       mytx4 = ants.registration(fixed=fname1, moving=fname2,
                                 type_of_transform="SyN",
                                 outprefix=str(registration_path / "diffToMR_N{}_".format(i)),
                                 reg_iterations=[100, 70, 50, 10],  # -m 100x70x50x10 \
                                 )
       print(mytx4)
       result1 = mytx4["warpedmovout"].to_nibabel()
       result2 = mytx4["warpedfixout"].to_nibabel()
       nib.save(result2, str(registration_path / "N{}_invToMRN1.nii".format(i)))
       nib.save(result1, str(registration_path / "N{}_diffToMRN1.nii".format(i)))

but the result is for each one of registration some thing like below:

 file 0000018600E3C1C0 does not exist . 
Exception Object caught: 

itk::ExceptionObject (0000000A275EBBC0)
Location: "unknown" 
File: D:\a\ANTsPy\ANTsPy\itksource\Modules\Registration\Common\include\itkCenteredTransformInitializer.hxx
Line: 31
Description: ITK ERROR: CenteredTransformInitializer(000001867F47D310): Fixed Image has not been set

{'warpedmovout': ANTsImage (LPI)
	 Pixel Type : float (float32)
	 Components : 1
	 Dimensions : (116, 142, 102)
	 Spacing    : (0.94, 0.94, 0.94)
	 Origin     : (54.05, 66.27, -47.47)
	 Direction  : [-1.  0.  0.  0. -1.  0.  0.  0.  1.]
, 'warpedfixout': ANTsImage (LPI)
	 Pixel Type : float (float32)
	 Components : 1
	 Dimensions : (116, 142, 102)
	 Spacing    : (0.94, 0.94, 0.94)
	 Origin     : (54.05, 66.27, -47.47)
	 Direction  : [-1.  0.  0.  0. -1.  0.  0.  0.  1.]
, 'fwdtransforms': [], 'invtransforms': []}

and in no one of them save fwdtransforms and invtransforms I use same code ,library and python distribution in linux and every thing was alright but I need it in windows actually

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 27 (7 by maintainers)

Most upvoted comments

I try this version [antspyx-0.3.8-cp39-win_amd64] and everything is smoothly and alright

yes it solved thanks alot

May need to install latest version - make sure other versions are purged ….

On Sun, Mar 26, 2023 at 6:03 PM amirreza @.***> wrote:

this is result and it don’t work :

itk::ImageFileWriterException (000000F10CBEBBA0) Location: “unknown” File: D:\a\ANTsPy\ANTsPy\itksource\Modules\IO\ImageBase\include\itkImageFileWriter.hxx Line: 117 Description: Could not create IO object for writing file 0000022DF5626DC0 Tried to create one of the following: BMPImageIO BioRadImageIO Bruker2dseqImageIO GDCMImageIO GE4ImageIO GE5ImageIO GiplImageIO HDF5ImageIO JPEGImageIO JPEG2000ImageIO LSMImageIO MGHImageIO MINCImageIO MRCImageIO MetaImageIO NiftiImageIO NrrdImageIO PNGImageIO StimulateImageIO TIFFImageIO VTKImageIO You probably failed to set a file suffix, or set the suffix to an unsupported type.

Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “E:\python_venv\medvispy\venv\lib\site-packages\ants\registration\interface.py”, line 1390, in registration raise RuntimeError(f"Registration failed with error code {reg_exit}") RuntimeError: Registration failed with error code 1

— Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsPy/issues/437#issuecomment-1484237438, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPE7QUFD2JUNT6RSVR4ODW6C4LLANCNFSM6AAAAAAVX4EGBY . You are receiving this because you were mentioned.Message ID: @.***>

brian

Okay, heavily simplify the code to a single ants.registration call and repost.