-1

i using SLIVER07 dataset for liver segmentation task but i am stuck in reading that images.

import SimpleITK as sitk
import numpy as np
import matplotlib.pyplot as plt

# reading .mhd file from slive07 dataset 
itkimage = sitk.ReadImage('liver-orig001.mhd')
ct_scan = sitk.GetArrayFromImage(itkimage)
plt.imshow(ct_scan[1])

1 Answers1

2

You are trying to pass the entire 3D image volume to imshow. You could instead try:

plt.imshow(ct_scan[40,:,:])

Which will show the 40th slice.

Of interest might be the platipy library, available here, or just $ pip install platipy. The built-in image visualiser (based on matplotlib) is perfect for 3D image visualisation in python, and has lots of cool features.

A little demo:

from platipy.imaging import ImageVisualiser

img = sitk.ReadImage("image_filename.mhd")

vis = ImageVisualiser(img)
fig = vis.show()

ortho_slices_with_platipy

Robbie
  • 4,672
  • 1
  • 19
  • 24