Exemple #1
0
    def test_read_invalid_length_non_ascii_text(self):
        fp = DicomBytesIO()
        ds = Dataset()
        ds.is_implicit_VR = True
        ds.is_little_endian = True
        ds.SpecificCharacterSet = "ISO_IR 192"  # UTF-8
        ds.add(DataElement(0x00080050, "SH", "洪^吉洞=홍^길동"))
        # disable value validation to write an invalid value
        with config.disable_value_validation():
            ds.save_as(fp)

        # no warning will be issued during reading, as only RawDataElement
        # objects are read
        ds = dcmread(fp, force=True)
Exemple #2
0
def disable_value_validation():
    with config.disable_value_validation():
        yield
Exemple #3
0
    def is_private(self) -> bool:
        """Return ``True`` if the UID isn't an officially registered DICOM
        UID.
        """
        return self[:14] != "1.2.840.10008."

    @property
    def is_valid(self) -> bool:
        """Return ``True`` if `self` is a valid UID, ``False`` otherwise."""
        if len(self) <= 64 and re.match(RE_VALID_UID, self):
            return True

        return False


with disable_value_validation():
    # Pre-defined Transfer Syntax UIDs (for convenience)
    ImplicitVRLittleEndian = UID("1.2.840.10008.1.2")
    """1.2.840.10008.1.2"""
    ExplicitVRLittleEndian = UID("1.2.840.10008.1.2.1")
    """1.2.840.10008.1.2.1"""
    DeflatedExplicitVRLittleEndian = UID("1.2.840.10008.1.2.1.99")
    """1.2.840.10008.1.2.1.99"""
    ExplicitVRBigEndian = UID("1.2.840.10008.1.2.2")
    """1.2.840.10008.1.2.2"""
    JPEGBaseline8Bit = UID("1.2.840.10008.1.2.4.50")
    """1.2.840.10008.1.2.4.50"""
    JPEGExtended12Bit = UID("1.2.840.10008.1.2.4.51")
    """1.2.840.10008.1.2.4.51"""
    JPEGLosslessP14 = UID("1.2.840.10008.1.2.4.57")  # needs to be updated
    """1.2.840.10008.1.2.4.57"""