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

Create a generator to efficiently return the raw data elements.


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.

  • 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 (str | MutableSequence[str]) – Encoding scheme

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


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