Example #1
0
def absorb_delimiter_item(fp, is_little_endian, delimiter):
    """Read (and ignore) undefined length sequence or item terminators."""
    if is_little_endian:
        struct_format = "<HHL"
    else:
        struct_format = ">HHL"
    group, elem, length = unpack(struct_format, fp.read(8))
    tag = TupleTag((group, elem))
    if tag != delimiter:
        msg = "Did not find expected delimiter '%s'" % dictionary_description(delimiter)
        msg += ", instead found %s at file position 0x%x" %(str(tag), fp.tell()-8)
        logger.warn(msg)    
        fp.seek(fp.tell()-8)
        return 
    logger.debug("%04x: Found Delimiter '%s'", fp.tell()-8, dictionary_description(delimiter))
    if length == 0:
        logger.debug("%04x: Read 0 bytes after delimiter", fp.tell()-4)
    else:
        logger.debug("%04x: Expected 0x00000000 after delimiter, found 0x%x", fp.tell()-4, length)
def absorb_delimiter_item(fp, is_little_endian, delimiter):
    """Read (and ignore) undefined length sequence or item terminators."""
    if is_little_endian:
        struct_format = "<HHL"
    else:
        struct_format = ">HHL"
    group, elem, length = unpack(struct_format, fp.read(8))
    tag = TupleTag((group, elem))
    if tag != delimiter:
        msg = "Did not find expected delimiter '%s'" % dictionary_description(
            delimiter)
        msg += ", instead found %s at file position 0x%x" % (str(tag),
                                                             fp.tell() - 8)
        logger.warn(msg)
        fp.seek(fp.tell() - 8)
        return
    logger.debug("%04x: Found Delimiter '%s'",
                 fp.tell() - 8, dictionary_description(delimiter))
    if length == 0:
        logger.debug("%04x: Read 0 bytes after delimiter", fp.tell() - 4)
    else:
        logger.debug("%04x: Expected 0x00000000 after delimiter, found 0x%x",
                     fp.tell() - 4, length)
Example #3
0
 def description(self):
     """Return the DICOM dictionary description for this dicom tag."""
     if dictionary_has_tag(self.tag):
         name = dictionary_description(self.tag)
     elif self.tag.is_private:
         name = "Private tag data"  # default
         if hasattr(self, 'private_creator'):
             try:
                 # If have name from private dictionary, use it, but
                 #   but put in square brackets so is differentiated,
                 #   and clear that cannot access it by name
                 name = "[" + private_dictionary_description(self.tag, self.private_creator) + "]"
             except KeyError:
                 pass
         elif self.tag.elem >> 8 == 0:
             name = "Private Creator"
     elif self.tag.element == 0:  # implied Group Length dicom versions < 3
         name = "Group Length"
     else:
         name = ""
     return name
Example #4
0
 def description(self):
     """Return the DICOM dictionary description for this dicom tag."""
     if dictionary_has_tag(self.tag):
         name = dictionary_description(self.tag)
     elif self.tag.is_private:
         name = "Private tag data"  # default
         if hasattr(self, 'private_creator'):
             try:
                 # If have name from private dictionary, use it, but
                 #   but put in square brackets so is differentiated,
                 #   and clear that cannot access it by name
                 name = "[" + private_dictionary_description(self.tag, self.private_creator) + "]"
             except KeyError:
                 pass
         elif self.tag.elem >> 8 == 0:
             name = "Private Creator"
     elif self.tag.element == 0:  # implied Group Length dicom versions < 3
         name = "Group Length"
     else:
         name = ""
     return name
Example #5
0
 def testRepeaters(self):
     """dicom_dictionary: Tags with "x" return correct dict info........"""
     self.assertEqual(dictionary_description(0x280400), 'Transform Label')
     self.assertEqual(dictionary_description(0x280410),
                      'Rows For Nth Order Coefficients')
Example #6
0
 def testRepeaters(self):
     """dicom_dictionary: Tags with "x" return correct dict info........"""
     self.assertEqual(dictionary_description(0x280400), 'Transform Label')
     self.assertEqual(dictionary_description(0x280410), 'Rows For Nth Order Coefficients')