pydicom.filereader.read_partial

pydicom.filereader.read_partial(fileobj: BinaryIO, stop_when: Callable[[BaseTag, str | None, int], bool] | None = None, defer_size: int | float | str | None = None, force: bool = False, specific_tags: List[BaseTag] | None = None) FileDataset | DicomDir[source]

Parse a DICOM file until a condition is met.

Parameters:
  • fileobj (a file-like object) – Note that the file will not close when the function returns.

  • stop_when – Stop condition. See read_dataset() for more info.

  • defer_size (int, str or float, optional) – See dcmread() for parameter info.

  • force (bool) – See dcmread() for parameter info.

  • specific_tags (list or None) – See dcmread() for parameter info.

Notes

Use dcmread() unless you need to stop on some condition other than reaching pixel data.

Returns:

The read dataset.

Return type:

dataset.FileDataset or dicomdir.DicomDir

See also

dcmread

More generic file reading function.