pydicom.fileset.RecordNode

class pydicom.fileset.RecordNode(record: Dataset | None = None)[source]

Representation of a DICOMDIR’s directory record.

children

The current node’s child nodes (if any)

Type:

list of RecordNode

instance

If the current node is a leaf node, a FileInstance for the corresponding SOP Instance.

Type:

FileInstance or None

__init__(record: Dataset | None = None) None[source]

Create a new RecordNode.

Parameters:

record (pydicom.dataset.Dataset, optional) – A Directory Record Sequence’s directory record.

Methods

__init__([record])

Create a new RecordNode.

add(leaf)

Add a leaf to the tree.

prettify([indent_char])

Return the tree structure as a list of pretty strings, starting at the current node (unless the current node is the root node).

remove(node)

Remove a leaf from the tree

reverse()

Yield nodes up to the level below the tree's root node.

Attributes

ancestors

Return a list of the current node's ancestors, ordered from nearest to furthest.

component

Return a File ID component as str for the current node.

depth

Return the number of nodes to the level below the tree root

file_set

Return the tree's FileSet.

has_instance

Return True if the current node corresponds to an instance.

index

Return the index of the current node amongst its siblings.

is_root

Return True if the current node is the tree's root node.

key

Return a unique key for the node's record as str.

next

Return the node after the current one (if any), or None.

parent

Return the current node's parent (if it has one).

previous

Return the node before the current one (if any), or None.

record_type

Return the record's Directory Record Type as str.

root

Return the tree's root node.

add(leaf: RecordNode) None[source]

Add a leaf to the tree.

Parameters:

leaf (pydicom.fileset.RecordNode) – A leaf node (i.e. one with a FileInstance) to be added to the tree (if not already present).

property ancestors: List[RecordNode]

Return a list of the current node’s ancestors, ordered from nearest to furthest.

property component: str

Return a File ID component as str for the current node.

property depth: int

Return the number of nodes to the level below the tree root

property file_set: FileSet

Return the tree’s FileSet.

property has_instance: bool

Return True if the current node corresponds to an instance.

property index: int

Return the index of the current node amongst its siblings.

property is_root: bool

Return True if the current node is the tree’s root node.

property key: str

Return a unique key for the node’s record as str.

property next: RecordNode | None

Return the node after the current one (if any), or None.

property parent: RecordNode

Return the current node’s parent (if it has one).

prettify(indent_char: str = '  ') List[str][source]

Return the tree structure as a list of pretty strings, starting at the current node (unless the current node is the root node).

Parameters:

indent_char (str, optional) – The characters to use to indent each level of the tree.

property previous: RecordNode | None

Return the node before the current one (if any), or None.

property record_type: str

Return the record’s Directory Record Type as str.

remove(node: RecordNode) None[source]

Remove a leaf from the tree

Parameters:

node (pydicom.fileset.RecordNode) – The leaf node (i.e. one with a FileInstance) to remove.

reverse() Iterable[RecordNode][source]

Yield nodes up to the level below the tree’s root node.

property root: RecordNode

Return the tree’s root node.