예제 #1
0
 def add_graphical_layer(self,
                         layer_name,
                         layer_order,
                         recommended_grayscale_value=None,
                         recommended_cielab_value=None,
                         layer_description=None):
     """Add graphical layer
     
     Arguments:
         layer_name {str} -- Name of layer
         layer_order {int} -- Order of layer
     
     Keyword Arguments:
         recommended_grayscale_value {[type]} -- [description] (default: {None})
         recommended_cielab_value {[type]} -- [description] (default: {None})
         layer_description {[type]} -- [description] (default: {None})
     """
     ds = Dataset()
     ds.GraphicLayer = layer_name
     ds.GraphicLayerOrder = layer_order
     if recommended_grayscale_value is not None:
         ds.GraphicLayerRecommendedDisplayGrayscaleValue = recommended_grayscale_value
     if recommended_cielab_value is not None:
         ds.GraphicLayerRecommendedDisplayCIELabValue = recommended_cielab_value
     if layer_description is not None:
         ds.GraphicLayerDescription = layer_description
     if "GraphicLayerSequence" not in self.dataset:
         self.dataset.GraphicLayerSequence = generate_sequence(
             "GraphicLayerSequence", [{}])
     self.dataset.GraphicLayerSequence.append(ds)
예제 #2
0
 def add_text_object(self,
                     referenced_dcm_file,
                     layer_name,
                     text_value,
                     anchor_point,
                     cielab_value=None,
                     shadow_style=None):
     """Add text object
     
     Arguments:
         referenced_dcm_file {[type]} -- [description]
         layer_name {[type]} -- [description]
         text_value {[type]} -- [description]
         anchor_point {[type]} -- [description]
     
     Keyword Arguments:
         cielab_value {[type]} -- [description] (default: {None})
         shadow_style {[type]} -- [description] (default: {None})
     """
     ds = Dataset()
     ds_ref = read_file(referenced_dcm_file)
     ds.ReferencedImageSequence = generate_sequence(
         "ReferencedImageSequence",
         [{
             "ReferencedSOPClassUID": ds_ref.SOPClassUID,
             "ReferencedSOPInstanceUID": ds_ref.SOPInstanceUID
         }])
     ds.GraphicLayer = layer_name
     ds.TextObjectSequence = generate_sequence(
         "TextObjectSequence", [{
             "AnchorPointAnnotationUnits": "PIXEL",
             "UnformattedTextValue": text_value,
             "AnchorPoint": anchor_point,
             "AnchorPointVisibility": "N",
         }])
     if cielab_value or shadow_style:
         ds.TextObjectSequence[0].TextStyleSequence = generate_sequence(
             "TextStyleSequence", [{}])
         if cielab_value:
             ds.TextObjectSequence[0].TextStyleSequence[
                 0].TextColorCIELabValue = cielab_value
         if shadow_style:
             ds.TextObjectSequence[0].TextStyleSequence[
                 0].ShadowStyle = shadow_style
     if "GraphicAnnotationSequence" not in self.dataset:
         self.dataset.GraphicAnnotationSequence = generate_sequence(
             "GraphicAnnotationSequence", [{}])
     self.dataset.GraphicAnnotationSequence.append(ds)
예제 #3
0
 def __init__(self, sequence_data):
     """Object initialization
     Parameters
     ----------
     sequence_data : List of items with data to generate each sequence item,
                     in the format of a list with a dictionary for each item,
                     which in turn can contain a sequence, e.g. list of dictionaries
     """
     super().__init__()
     for sequence_item in sequence_data:
         # Initiate dataset
         ds = Dataset()
         # Set required DICOM attributes
         ds.GraphicLayer = "DEFAULT"
         # Update and insert additional DICOM attributes as available
         ds = update_and_insert_additional_DICOM_attributes_in_ds(
             ds, sequence_item)
         # Add dataset to sequence
         self.sequence.append(ds)
예제 #4
0
 def add_graphic_object(self,
                        referenced_dcm_file,
                        layer_name,
                        graphic_data,
                        graphic_type,
                        graphic_filled=None,
                        cielab_value=None,
                        shadow_style=None,
                        line_thickness=None):
     """Add graphical object
     
     Arguments:
         referenced_dcm_file {[type]} -- [description]
         layer_name {[type]} -- [description]
         graphic_data {[type]} -- [description]
         graphic_type {[type]} -- [description]
     
     Keyword Arguments:
         graphic_filled {[type]} -- [description] (default: {None})
         cielab_value {[type]} -- [description] (default: {None})
         shadow_style {[type]} -- [description] (default: {None})
         line_thickness {[type]} -- [description] (default: {None})
     """
     ds = Dataset()
     ds_ref = read_file(referenced_dcm_file)
     ds.ReferencedImageSequence = generate_sequence(
         "ReferencedImageSequence",
         [{
             "ReferencedSOPClassUID": ds_ref.SOPClassUID,
             "ReferencedSOPInstanceUID": ds_ref.SOPInstanceUID
         }])
     ds.GraphicLayer = layer_name
     ds.GraphicObjectSequence = generate_sequence(
         "GraphicObjectSequence",
         [{
             "GraphicAnnotationUnits": "PIXEL",
             "GraphicDimensions": 2,
             "NumberOfGraphicPoints": int(len(graphic_data) / 2),
             "GraphicData": graphic_data,
             "GraphicType": graphic_type,
         }])
     if graphic_filled:
         ds.GraphicObjectSequence[0].GraphicFilled = graphic_filled
     if cielab_value or shadow_style or line_thickness:
         ds.GraphicObjectSequence[0].LineStyleSequence = generate_sequence(
             "LineStyleSequence", [{}])
         if cielab_value:
             ds.GraphicObjectSequence[0].LineStyleSequence[
                 0].PatternOnColorCIELabValue = cielab_value
         if shadow_style:
             ds.GraphicObjectSequence[0].LineStyleSequence[
                 0].ShadowStyle = shadow_style
         if line_thickness:
             ds.GraphicObjectSequence[0].LineStyleSequence[
                 0].LineThickness = line_thickness
     if graphic_filled and cielab_value:
         ds.GraphicObjectSequence[0].FillStyleSequence = generate_sequence(
             "FillStyleSequence", [{}])
         if cielab_value:
             ds.GraphicObjectSequence[0].FillStyleSequence[
                 0].PatternOnColorCIELabValue = cielab_value
     if "GraphicAnnotationSequence" not in self.dataset:
         self.dataset.GraphicAnnotationSequence = generate_sequence(
             "GraphicAnnotationSequence", [{}])
     self.dataset.GraphicAnnotationSequence.append(ds)