pydicom.dicomdir.DicomDir¶
- class pydicom.dicomdir.DicomDir(filename_or_obj: str | PathLike | BinaryIO, dataset: Dataset, preamble: bytes | None = None, file_meta: FileMetaDataset | None = None, is_implicit_VR: bool = True, is_little_endian: bool = True)[source]¶
Hold a DICOMDIR dataset read from file.
Derived from
FileDataset, but additional methods are available, specific to the Directory structureDeprecated since version 2.1:
DicomDiris deprecated and will be removed in pydicom v3.0, useFileSetinstead.- __init__(filename_or_obj: str | PathLike | BinaryIO, dataset: Dataset, preamble: bytes | None = None, file_meta: FileMetaDataset | None = None, is_implicit_VR: bool = True, is_little_endian: bool = True) None[source]¶
Initialize a DICOMDIR dataset read from a DICOM file.
Carries forward all the initialization from
FileDataset- Parameters:
filename_or_obj (str or PathLike or file-like or None) – Full path and filename to the file of
Noneifio.BytesIO.dataset (dataset.Dataset) – Some form of dictionary, usually a
FileDatasetfromdcmread().preamble (bytes) – The 128-byte DICOM preamble.
file_meta (dataset.Dataset) – The file meta
Dataset, such as the one returned byread_file_meta_info(), or an emptyDatasetif no file meta information is in the file.is_implicit_VR (bool) –
Trueif implicit VR transfer syntax used (default);Falseif explicit VR.is_little_endian (bool) –
Trueif little endian transfer syntax used (default);Falseif big endian.
- Raises:
InvalidDicomError – If the file transfer syntax is not Little Endian Explicit and
reading_validation_modeisRAISE.
Methods
__init__(filename_or_obj, dataset[, ...])Initialize a DICOMDIR dataset read from a DICOM file.
add(data_element)Add an element to the
Dataset.add_new(tag, VR, value)Create a new element and add it to the
Dataset.clear()Delete all the elements from the
Dataset.compress(transfer_syntax_uid[, arr, ...])Compress and update an uncompressed dataset in-place with the resulting encapsulated pixel data.
convert_pixel_data([handler_name])Convert pixel data to a
numpy.ndarrayinternally.copy()Return a shallow copy of the dataset.
data_element(name)Return the element corresponding to the element keyword name.
decode()Apply character set decoding to the elements in the
Dataset.decompress([handler_name])Decompresses Pixel Data and modifies the
Datasetin-place.dir(*filters)Return an alphabetical list of element keywords in the
Dataset.elements()Yield the top-level elements of the
Dataset.ensure_file_meta()Create an empty
Dataset.file_metaif none exists.fix_meta_info([enforce_standard])Ensure the file meta info exists and has the correct values for transfer syntax and media storage UIDs.
formatted_lines([element_format, ...])Iterate through the
Datasetyielding formattedstrfor each element.from_json(json_dataset[, bulk_data_uri_handler])Return a
Datasetfrom a DICOM JSON Model object.get(key[, default])Simulate
dict.get()to handle element tags and keywords.get_item(key)Return the raw data element if possible.
get_private_item(group, element_offset, ...)Return the data element for the given private tag group.
group_dataset(group)Return a
Datasetcontaining only elements of a certain group.items()Return the
Datasetitems to simulatedict.items().iterall()Iterate through the
Dataset, yielding all the elements.keys()Return the
Datasetkeys to simulatedict.keys().overlay_array(group)Return the Overlay Data in group as a
numpy.ndarray.Build the hierarchy of given directory records, and structure into Patient, Studies, Series, Images hierarchy.
pop(key, *args)Emulate
dict.pop()with support for tags and keywords.popitem()Emulate
dict.popitem().private_block(group, private_creator[, create])Return the block for the given tag group and private_creator.
private_creators(group)Return a list of private creator names in the given group.
remove_private_tags()Remove all private elements from the
Dataset.save_as(filename[, write_like_original])Write the
Datasetto filename.set_original_encoding(is_implicit_vr, ...)Set the values for the original transfer syntax and encoding.
setdefault(key[, default])Emulate
dict.setdefault()with support for tags and keywords.to_json([bulk_data_threshold, ...])Return a JSON representation of the
Dataset.to_json_dict([bulk_data_threshold, ...])Return a dictionary representation of the
Datasetconforming to the DICOM JSON Model as described in the DICOM Standard, Part 18, Annex F.top()Return a
strrepresentation of the top level elements.trait_names()Return a
listof valid names for auto-completion code.update(d)Extend
dict.update()to handle DICOM tags and keywords.values()Return the
Datasetvalues to simulatedict.values().walk(callback[, recursive])Iterate through the
Dataset'selements and run callback on each.waveform_array(index)Return an
ndarrayfor the multiplex group at index in the (5400,0100) Waveform Sequence.Attributes
default_element_formatdefault_sequence_element_formatindent_charsis_original_encodingReturn
Trueif the encoding to be used for writing is set and is the same as that used to originally encode theDataset.parentReturn a weak reference to the parent Sequence's parent Dataset.
parent_seqReturn a weak reference to the parent
Sequence.pixel_arrayReturn the pixel data as a
numpy.ndarray.