SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
507 stars 149 forks source link

RuntimeError: Exception thrown in SimpleITK Elastix #478

Open martinloh opened 2 years ago

martinloh commented 2 years ago

Hi,

when I try to run the following code:

`path = r"\nas-fa0efsusr1\lohmn\My Documents\Auswertungen\Niere" filename_moving = '45_b1_moving.nii' filename_fixed = '45_fixed.nii'

image_fixed = sitk.ReadImage(os.path.join(path, filename_fixed)) image_moving = sitk.ReadImage(os.path.join(path, filename_moving))

Register

elastixImageFilter = sitk.ElastixImageFilter() elastixImageFilter.SetFixedImage(image_fixed) elastixImageFilter.SetMovingImage(image_moving) elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap('groupwise')) elastixImageFilter.Execute()`

I receive the following runtime error:

Exception thrown in SimpleITK ElastixImageFilter_Execute: C:\dafne\SimpleElastix\Code\Elastix\src\sitkElastixImageFilterImpl.cxx:259: sitk::ERROR: itk::ExceptionObject (000000E4B07E83E0) Location: "unknown" File: c:\dafne\simpleelastix\build3.9\elastix\core\main\elxElastixFilter.hxx Line: 253 Description: itk::ERROR: ElastixFilter(000001E4BE8B5570): Internal elastix error: See elastix log (use LogToConsoleOn() or LogToFileOn()).

It's very similar to issue #132, but it didn't get me any further unfortunately. I also have no idea how to use LogToConsoleOn() or LogToFileOn().

Thank you

Kiiaan commented 1 year ago

Hi!

I also have no idea how to use LogToConsoleOn() or LogToFileOn().

You can activate logging to file with the following commands before running Execute():

elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.LogToFileOn()
elastixImageFilter.SetOutputDirectory("./")

Then elastix.log will be created in your current directory and your error will be logged there.