I can't open dcm file

112 views Asked by At

Please tell me, when I try to open a dcm file, an error occurs, I use the pydicom library, how can I fix it?

base = r"D:\fff"
pass_dicom = "dd.dcm" 
  
# enter DICOM image name for pattern 
# result is a list of 1 element 
filename = pydicom.data.data_manager.get_files(base, pass_dicom)
  
ds = pydicom.dcmread(filename) 

Gives this error: No tag to read at file position 3AC03D2

I found a piece of code that throws an error, it throws an error if bytes_read = b''

def read_sequence_item(
    fp: BinaryIO,
    is_implicit_VR: bool,
    is_little_endian: bool,
    encoding: Union[str, MutableSequence[str]],
    offset: int = 0
) -> Optional[Dataset]:
    """Read and return a single :class:`~pydicom.sequence.Sequence` item, i.e.
    a :class:`~pydicom.dataset.Dataset`.
    """
    seq_item_tell = fp.tell() + offset
    if is_little_endian:
        tag_length_format = "<HHL"
    else:
        tag_length_format = ">HHL"
    try:
        bytes_read = fp.read(8)
        group, element, length = unpack(tag_length_format, bytes_read)
    except BaseException:
        raise IOError(
            f"No tag to read at file position {fp.tell() + offset:X}"
        )

Is there any way to fix this?

0

There are 0 answers