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
I'm working on extracting the rtstruct co-ordinates of my file using the example in rtstruct.rst but :
from dicom_csv.rtstruct.csv import collect_rtstructs is not working. I have tried looking through the documentation and there is no function defining RTstruct. Please let me know of any ambiguities.
The text was updated successfully, but these errors were encountered:
Hi, we temporarily remove this functionality, I am currently working on the updated (more general) version. Till then, you could use something like this to get the contours:
def read_contour_sequence(dataset: pydicom.dataset.Dataset) -> dict:
contour_sequence_dict = dict()
if not hasattr(dataset, 'ContourSequence'):
raise AttributeError('Dataset does not have Contour Sequence.')
for _slice in dataset.ContourSequence:
key = _slice.ContourImageSequence[0].ReferencedSOPInstanceUID
coords = np.array(_slice.ContourData)
n = len(coords) // 3
coords = coords.reshape((n, 3))
if key not in contour_sequence_dict:
contour_sequence_dict[key] = [coords]
else:
contour_sequence_dict[key].append(coords)
return contour_sequence_dict
Usage example:
rtstruct = dcmread('path/to/rtstruct.dcm')
contours = list(rtstruct.ROIContourSequence)
contour_coords = read_contour_sequence(contours[0]) # if you have more than one contour in rtstruct you need to iterate over `contours`
contour_coords is a dictionary with keys being SOPInstanceUID of a reference image and values - coordinates of a contour. You might still need to postprocess them in case your image has non-unit ImageOrientationPatient and non-zero ImagePositionPatient fields.
I'm working on extracting the rtstruct co-ordinates of my file using the example in rtstruct.rst but :
from dicom_csv.rtstruct.csv import collect_rtstructs is not working. I have tried looking through the documentation and there is no function defining RTstruct. Please let me know of any ambiguities.
The text was updated successfully, but these errors were encountered: