Beispiel #1
0
    def __init__(
            self,
            method: Union[Code, CodedConcept],
            parent_specimen_id: str,
            parent_specimen_type: Union[Code, CodedConcept],
            issuer_of_parent_specimen_id: Optional[IssuerOfIdentifier] = None
        ):
        """
        Parameters
        ----------
        method: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept]
            Method used to sample the examined specimen from a parent specimen
        parent_specimen_id: str
            Identifier of the parent specimen
        parent_specimen_type: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept]
            Type of the parent specimen
        issuer_of_parent_specimen_id: highdicom.content.IssuerOfIdentifier, optional
            Issuer who created the parent specimen

        """  # noqa
        super().__init__()
        # CID 8110
        method_item = CodeContentItem(
            name=codes.DCM.SamplingMethod,
            value=method
        )
        self.append(method_item)
        parent_specimen_identitier_item = TextContentItem(
            name=codes.DCM.ParentSpecimenIdentifier,
            value=parent_specimen_id
        )
        self.append(parent_specimen_identitier_item)
        if issuer_of_parent_specimen_id is not None:
            try:
                entity_id = issuer_of_parent_specimen_id.UniversalEntityID
            except AttributeError:
                entity_id = issuer_of_parent_specimen_id.LocalNamespaceEntityID
            issuer_of_parent_specimen_identitier_item = TextContentItem(
                name=codes.DCM.IssuerOfParentSpecimenIdentifier,
                value=entity_id
            )
            self.append(issuer_of_parent_specimen_identitier_item)
        # CID 8103
        parent_specimen_type_item = CodeContentItem(
            name=codes.DCM.ParentSpecimenType,
            value=parent_specimen_type
        )
        self.append(parent_specimen_type_item)
Beispiel #2
0
 def test_text_item_construction(self):
     name = codes.DCM.TrackingIdentifier
     value = '1234'
     i = TextContentItem(name=name, value=value)
     assert i.ValueType == 'TEXT'
     assert i.ConceptNameCodeSequence[0] == name
     assert i.TextValue == value
     with pytest.raises(AttributeError):
         assert i.RelationshipType
Beispiel #3
0
    def __init__(self,
                 specimen_id: str,
                 specimen_uid: str,
                 specimen_location: Optional[Union[str, Tuple[float, float,
                                                              float]]] = None,
                 specimen_preparation_steps: Optional[
                     Sequence[SpecimenPreparationStep]] = None,
                 issuer_of_specimen_id: Optional[IssuerOfIdentifier] = None):
        """
        Parameters
        ----------
        specimen_id: str
            Identifier of the examined specimen
        specimen_uid: str
            Unique identifier of the examined specimen
        specimen_location: Union[str, Tuple[float, float, float]], optional
            Location of the examined specimen relative to the container
            provided either in form of text or in form of spatial x, y, z
            coordinates specifying the position (offset) relative to the
            three-dimensional slide coordinate system
        specimen_preparation_steps: Sequence[highdicom.content.SpecimenPreparationStep], optional
            Steps that were applied during the preparation of the examined
            specimen in the laboratory prior to image acquisition
        issuer_of_specimen_id: highdicom.content.IssuerOfIdentifier, optional
            Description of the issuer of the specimen identifier

        """  # noqa
        super().__init__()
        self.SpecimenIdentifier = specimen_id
        self.SpecimenUID = specimen_uid
        self.SpecimenPreparationSequence: List[Dataset] = []
        if specimen_preparation_steps is not None:
            for step in specimen_preparation_steps:
                if not isinstance(step, ContentSequence):
                    raise TypeError(
                        'Each specimen preparation step must be provided as '
                        'a sequence of content items.')
                step_item = Dataset()
                step_item.SpecimenPreparationStepContentItemSequence = step
                self.SpecimenPreparationSequence.append(step_item)
        if specimen_location is not None:
            loc_seq = []
            if isinstance(specimen_location, str):
                loc_item = TextContentItem(name=codes.DCM.LocationOfSpecimen,
                                           value=specimen_location)
                loc_seq.append(loc_item)
            elif isinstance(specimen_location, tuple):
                names = (
                    codes.DCM.LocationOfSpecimenXOffset,
                    codes.DCM.LocationOfSpecimenYOffset,
                    codes.DCM.LocationOfSpecimenZOffset,
                )
                for i, coordinate in enumerate(specimen_location):
                    loc_item = NumContentItem(
                        name=names[i],
                        value=coordinate,
                    )
                    loc_seq.append(loc_item)
            self.SpecimenLocalizationContentItemSequence = loc_seq
        self.IssuerOfTheSpecimenIdentifierSequence: List[Dataset] = []
        if issuer_of_specimen_id is not None:
            self.IssuerOfTheSpecimenIdentifierSequence.append(
                issuer_of_specimen_id)
Beispiel #4
0
    def __init__(self,
                 specimen_id: str,
                 processing_type: Union[Code, CodedConcept],
                 processing_procedure: Union[SpecimenCollection,
                                             SpecimenSampling,
                                             SpecimenStaining, ],
                 processing_description: Optional[Union[str, Code,
                                                        CodedConcept]] = None,
                 processing_datetime: Optional[datetime.datetime] = None,
                 issuer_of_specimen_id: Optional[IssuerOfIdentifier] = None,
                 fixative: Optional[Union[Code, CodedConcept]] = None,
                 embedding_medium: Optional[Union[Code, CodedConcept]] = None):
        """
        Parameters
        ----------
        specimen_id: str
            Identifier of the processed specimen
        processing_type: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept]
            Type of processing
        processing_procedure: Union[highdicom.content.SpecimenCollection, highdicom.content.SpecimenSampling, highdicom.content.SpecimenStaining]
            Procedure used during processing
        processing_datetime: datetime.datetime, optional
            Datetime of processing
        processing_description: Union[str, pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional
            Description of processing
        issuer_of_specimen_id: highdicom.content.IssuerOfIdentifier, optional
        fixative: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional
            Fixative used during processing
        embedding_medium: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional
            Embedding medium used during processing

        """  # noqa
        super().__init__()
        specimen_identifier_item = TextContentItem(
            name=codes.DCM.SpecimenIdentifier, value=specimen_id)
        self.append(specimen_identifier_item)
        if issuer_of_specimen_id is not None:
            self.append(issuer_of_specimen_id)
        # CID 8111
        processing_type_item = CodeContentItem(name=codes.DCM.ProcessingType,
                                               value=processing_type)
        self.append(processing_type_item)
        if processing_datetime is not None:
            processing_datetime_item = DateTimeContentItem(
                name=codes.DCM.DateTimeOfProcessing, value=processing_datetime)
            self.append(processing_datetime_item)
        if processing_description is not None:
            if isinstance(processing_description, str):
                processing_description_item = TextContentItem(
                    name=codes.DCM.ProcessingStepDescription,
                    value=processing_description)
            else:
                processing_description_item = CodeContentItem(
                    name=codes.DCM.ProcessingStepDescription,
                    value=processing_description)
            self.append(processing_description_item)
        accepted_procedure_types = (
            SpecimenCollection,
            SpecimenSampling,
            SpecimenStaining,
        )
        if not isinstance(processing_procedure, accepted_procedure_types):
            raise TypeError('Unknown procedure of specimen preparation step.')
        self.extend(processing_procedure)
        if fixative is not None:
            tissue_fixative_item = CodeContentItem(
                name=codes.SCT.TissueFixative, value=fixative)
            self.append(tissue_fixative_item)
        if embedding_medium is not None:
            embedding_medium_item = CodeContentItem(
                name=codes.SCT.EmbeddingMedium, value=embedding_medium)
            self.append(embedding_medium_item)