How to use the pydicom.valuerep function in pydicom

To help you get started, we’ve selected a few pydicom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testTime(self):
        """TM conversion to datetime.time ......................................."""
        dicom_time = "2359"
        tm = valuerep.TM(dicom_time)
        datetime_time = time(23, 59)
        self.assertEqual(tm, datetime_time,
                         "TM {0} not equal to time {1}".format(dicom_time, datetime_time))

        dicom_time = "235900.123"
        tm = valuerep.TM(dicom_time)
        datetime_time = time(23, 59, 00, 123000)
        self.assertEqual(tm, datetime_time,
                         "TM {0} not equal to time {1}".format(dicom_time, datetime_time))

        dicom_time = ""
        tm = valuerep.TM(dicom_time)
        self.assertEqual(tm, None, "TM {0} not None".format(dicom_time))
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testPickling(self):
        # Check that a pickled TM is read back properly
        x = pydicom.valuerep.TM("212223")
        x.original_string = 'hello'
        self.assertEqual(x.original_string, 'hello')
        self.assertEqual(x, time(21, 22, 23))
        data1_string = pickle.dumps(x)
        x2 = pickle.loads(data1_string)
        self.assertEqual(x, x2)
        self.assertEqual(x.original_string, x2.original_string)
        self.assertEqual(str(x), str(x2))
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testPickling(self):
        # Check that a pickled DA is read back properly
        x = pydicom.valuerep.DA("19111213")
        x.original_string = 'hello'
        data1_string = pickle.dumps(x)
        x2 = pickle.loads(data1_string)
        self.assertEqual(x, x2)
        self.assertEqual(x.original_string, x2.original_string)
        self.assertEqual(str(x), str(x2))
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testDate(self):
        """DA conversion to datetime.date ......................................."""
        dicom_date = "19610804"
        da = valuerep.DA(dicom_date)
        datetime_date = date(1961, 8, 4)
        self.assertEqual(da, datetime_date,
                         "DA {0} not equal to date {1}".format(dicom_date, datetime_date))

        dicom_date = "1961.08.04"  # ACR-NEMA Standard 300
        da = valuerep.DA(dicom_date)
        datetime_date = date(1961, 8, 4)
        self.assertEqual(da, datetime_date,
                         "DA {0} not equal to date {1}".format(dicom_date, datetime_date))

        dicom_date = ""
        da = valuerep.DA(dicom_date)
        self.assertEqual(da, None, "DA {0} not None".format(dicom_date))
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testInvalidDecimalStrings(self):
        # Now the input string truly is invalid
        invalid_string = '-9.813386743e-006'
        self.assertRaises(OverflowError, valuerep.DS, invalid_string)
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testPickling(self):
        # Check that a pickled IS is read back properly
        x = pydicom.valuerep.IS(921)
        x.original_string = 'hello'
        data1_string = pickle.dumps(x)
        x2 = pickle.loads(data1_string)
        self.assertEqual(x.real, x2.real)
        self.assertEqual(x.original_string, x2.original_string)
github pydicom / pydicom / tests / test_valuerep.py View on Github external
def testPickling(self):
        # Check that a pickled DSFloat is read back properly
        x = pydicom.valuerep.DSfloat(9.0)
        x.original_string = 'hello'
        data1_string = pickle.dumps(x)
        x2 = pickle.loads(data1_string)
        self.assertEqual(x.real, x2.real)
        self.assertEqual(x.original_string, x2.original_string)
github darraghdog / rsna / scripts / prepare_meta_dicom.py View on Github external
def cast(value):
    if type(value) is pydicom.valuerep.MultiValue:
        return tuple(value)
    return value
github darraghdog / rsna / eda / window_v2.py View on Github external
def cast(value):
    if type(value) is pydicom.valuerep.MultiValue:
        return tuple(value)
    return value
github darraghdog / rsna / eda / window_v1.py View on Github external
def cast(value):
    if type(value) is pydicom.valuerep.MultiValue:
        return tuple(value)
    return value