pydicom-seg icon indicating copy to clipboard operation
pydicom-seg copied to clipboard

Segmentation shape is not the same as the original image shape

Open melaniezhang opened this issue 1 year ago • 0 comments

This is what I'm trying:

# read individual segments from dicom file via pydicom_seg
dcm = pydicom.dcmread(dicom_filename)
print(dcm.pixel_array.shape)

# Use a SegmentReader to iterate through all the segments
reader = pydicom_seg.SegmentReader()
result = reader.read(dcm)

segmentations = []
for segment_number in result.available_segments:
    print(segment_number)
    image_data = result.segment_data(segment_number)  # directly available
    image = result.segment_image(segment_number)  # lazy construction
    print(sitk.GetArrayFromImage(image).shape)
    segmentations.append(image)

The original dicom image pixel array's shape is (440, 512, 512).

However the individual segment shapes are (114, 512, 512); strange.

Is there a way to read the segments where the shape of the original image is preserved?

I need this because I'm trying to combine all the segments back to a numpy array, and save it in a different format like .nii.gz, where I need the dimensions of the combined output to be the same as the original dicom input.

melaniezhang avatar Feb 09 '24 23:02 melaniezhang