pydicom.filebase.DicomFileLike

class pydicom.filebase.DicomFileLike(buffer: ReadableBuffer | WriteableBuffer)[source]

Wrapper for file-likes to simplify encoding/decoding DICOM datasets.

See also

DicomIO, DicomBytesIO

__init__(buffer: ReadableBuffer | WriteableBuffer) None[source]

Create a new DicomIO instance.

Parameters:

buffer (buffer-like object) –

A buffer-like object that implements:

If buffer supports reading it can be used with dcmread() as the source to decode a DICOM dataset from, and if it supports writing it can be used with dcmwrite() as the destination for the encoded DICOM dataset.

Methods

__init__(buffer)

Create a new DicomIO instance.

close(*args, **kwargs)

Close the buffer (if possible)

read([size])

Read up to size bytes from the buffer and return them.

read_UL()

Return a UL value read from the buffer.

read_US()

Return a US value read from the buffer.

read_exact(length[, nr_retries])

Return length bytes read from the buffer.

read_tag()

Return a DICOM tag value read from the buffer.

seek(offset[, whence])

Change the buffer position to the given byte offset, relative to the position indicated by whence and return the new absolute position.

tell()

Return the current stream position of the buffer

write(b, /)

Write the bytes-like object b to the buffer and return the number of bytes written.

write_UL(val)

Write a UL value to the buffer.

write_US(val)

Write a US value to the buffer.

write_tag(tag)

Write a DICOM tag to the buffer.

Attributes

is_implicit_VR

Get/set the VR mode for encoding/decoding.

is_little_endian

Get/set the endianness for encoding/decoding, True for little endian and False for big endian.

name

Return the value of the parent's name attribute, or "<no filename>" if no such attribute.

parent

Return the buffer object being wrapped.