You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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.
The text was updated successfully, but these errors were encountered:
This is what I'm trying:
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.
The text was updated successfully, but these errors were encountered: