Trouble viewing PET image (mha file) in SimpleITK

Hello,
I am using the following python code to view a PET and an MR image.

fixed_image = sitk.ReadImage("PET.mha", sitk.sitkFloat64)
moving_image = sitk.ReadImage("MR.mha", sitk.sitkFloat64)

point_acquisition_interface = gui.RegistrationPointDataAquisition(
     fixed_image, moving_image, fixed_window_level=(215, 50)
 )

In the resulting display, details of the PET image is lost.

The original PET image looks as follows, when viewed by a different viewer.

How can I improve display of the PET image in SimpleITK?

Hello @debapriya,

You are explicitly setting the PET display values via the parameter fixed_window_level=(215, 50). You will need to change these settings to something that is appropriate for your data. First, try without explicitly setting the value, internally this defaults to using the whole intensity range (as done below). If this doesn’t work, you can try various settings changing the windowMinimum, windowMaximum values:

import SimpleITK as sitk

file_name = 
fixed_image = sitk.ReadImage(file_name)

# Modify the following two lines
windowMinimum = float(sitk.GetArrayViewFromImage(fixed_image).min()) 
windowMaximum = float(sitk.GetArrayViewFromImage(fixed_image).max())

fixed_window_level = (windowMaximum-windowMinimum, (windowMaximum+windowMinimum)/2)
sitk.Show(sitk.Cast(sitk.IntensityWindowing(fixed_image, windowMinimum, windowMaximum, outputMinimum=0, outputMaximum=255), sitk.sitkUInt8))
1 Like

Thank you @zivy . It worked.