nii image not displaying with SimpleITK gui

I have a 3D nii image representing the ROI of tumor region in brain. It is displaying properly with Slicer.

However, when I try to display the same image using SimpleITK gui, I see a black image. My SimpleITK code is

import SimpleITK as sitk
import gui
import numpy as np


ROI_image = sitk.ReadImage("Coreg/Data1/roi.nii", sitk.sitkFloat32)
ROIwindowMinimum = float(np.array(ROI_image).min())
ROIwindowMaximum = float(np.array(ROI_image).max())
ROI_window_level = (ROIwindowMaximum-ROIwindowMinimum, (ROIwindowMaximum+ROIwindowMinimum)/2)

print(ROIwindowMinimum)
print(ROIwindowMaximum)
print(ROI_window_level)

gui.MultiImageDisplay(
    image_list=[ROI_image],
    title_list=["ROI"],
    figure_size=(8, 4),
    window_level_list=[ROI_window_level],
);

Output is

Hello @debapriya,

You are trying to display a label image, which was not the original intent of the MultiImageDisplay. The documentation for this component gives a hint to the possible problem: “The range of the intensity slider is set to be from top/bottom 2% of intensities”. You can modify your code so that the range includes all intensities (intensity_slider_range_percentile parameter in constructor) and then the labels should be visible.

2 Likes

Thank you @zivy. It worked.