SuperElastix / SimpleElastix

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

Fixed mask must be of pixel type sitkUInt8 ' simpleitk" #411

Open Alajmi0 opened 3 years ago

Alajmi0 commented 3 years ago

I am fairly new to image registration by SimpleITK , and I have installed from sources the SimpleITK package on Python3 macOs

I am trying to register three images fixed( T1) , moving ( CT) and third image ( PET).

here is the part of the code:

`## Load fixed and moving image data fixedImage = sitk.ReadImage(FIXED_IMAGE_NAME,sitk.sitkUInt8) movingImage = sitk.ReadImage(MOVING_IMAGE_NAME,sitk.sitkUInt8) sitk.Cast(fixedImage, sitk.sitkUInt8)

Execute elastix registration

elastixImageFilter = sitk.ElastixImageFilter() elastixImageFilter.SetFixedImage(fixedImage) elastixImageFilter.SetMovingImage(movingImage)

try: if FIXED_IMAGE_MASK_NAME != None and FIXED_IMAGE_MASK_NAME != "":

    elastixImageFilter.SetFixedMask(sitk.ReadImage(FIXED_IMAGE_MASK_NAME,sitk.sitkUInt8))

elastixImageFilter.SetParameterMap(parameterMap_rigid)

try: thirdImage = sitk.ReadImage(THIRD_IMAGE_NAME,sitk.sitkUInt8)

transformix = sitk.TransformixImageFilter()
transformix.SetTransformParameterMap(transformParameterMap)
transformix.SetMovingImage(thirdImage)

transformix.Execute()`

I got

sitk::ERROR: Fixed mask must be of pixel type sitkUInt8 but fixed mask 0 is of type "16-bit signed integer". Cast with SimpleITK.Cast(mask, sitk.sitkUInt8).

Can you please direct me where is my problem here?