pydicom.filereader.data_element_generator

pydicom.filereader.data_element_generator(fp: BinaryIO, is_implicit_VR: bool, is_little_endian: bool, stop_when: Optional[Callable[[BaseTag, Optional[str], int], bool]] = None, defer_size: Optional[Union[int, float, str]] = None, encoding: Union[str, MutableSequence[str]] = 'iso8859', specific_tags: Optional[List[BaseTag]] = None) Iterator[Union[RawDataElement, DataElement]][source]

Create a generator to efficiently return the raw data elements.

Note

This function is used internally - usually there is no need to call it from user code. To read data from a DICOM file, dcmread() shall be used instead.

Parameters
  • fp (file-like) – The file-like to read from.

  • is_implicit_VR (bool) – True if the data is encoded as implicit VR, False otherwise.

  • is_little_endian (bool) – True if the data is encoded as little endian, False otherwise.

  • stop_when (None, callable, optional) – If None (default), then the whole file is read. A callable which takes tag, VR, length, and returns True or False. If it returns True, read_data_element will just return.

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

  • encoding (Union[str, MutableSequence[str]]) – Encoding scheme

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

Yields

RawDataElement or DataElement – Yields DataElement for undefined length UN or SQ, RawDataElement otherwise.