pydicom.fileset.RecordNode

class pydicom.fileset.RecordNode(record: Optional[pydicom.dataset.Dataset] = 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: Optional[pydicom.dataset.Dataset] = 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: pydicom.fileset.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

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

property component

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

property depth

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

property file_set

Return the tree’s FileSet.

property has_instance

Return True if the current node corresponds to an instance.

property index

Return the index of the current node amongst its siblings.

property is_root

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

property key

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

property next

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

property parent

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

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

property record_type

Return the record’s Directory Record Type as str.

remove(node: pydicom.fileset.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() → Generator[pydicom.fileset.RecordNode, None, None][source]

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

property root

Return the tree’s root node.