ionique.datatypes

The datatypes module provides high-level data containers that build on the segment tree from core.

  • TraceFile — wraps a loaded nanopore recording (current, voltage, metadata) as a tree node at rank "file". Automatically creates voltage- step children when voltage boundaries are provided.

  • SessionFileManager — singleton root node that manages all loaded files in a session.

See Data Input for usage examples.

Data structure definitions and session file management for analysis.

class ionique.datatypes.SessionFileManager(*args, **kwargs)

Bases: MetaSegment

Singleton-based session manager for hierarchical data.

This class inherits from MetaSegment and uses the Singleton metaclass to ensure only one instance exists during a given session. It serves as the root segment for a data analysis session and is responsible for managing metadata and registered “affectors” (i.e., objects that modify or interact with the session).

rank

Fixed rank label "root" identifying this as the top of the hierarchy.

Type:

str

affector_table

Registry mapping UUID strings to metadata entries for each registered affector (class name, string representation, and timestamp).

Type:

dict

__init__() None

Initialize the session manager.

Sets the session start time and prepares the affector log structure.

add_child(child: AnySegment) None

Add a single child segment to the session’s hierarchy.

Parameters:

child (AnySegment) – The segment to be added as a child.

add_children(children: list[AnySegment]) None

Add multiple child segments to the session.

Parameters:

children (list of AnySegment) – A list of segments to be added as children.

rank: str = 'root'
register_affector(affector)

Register an affector object that influences the session data.

Records metadata including class name, string representation, and timestamp, and logs the event with a unique identifier.

Parameters:

affector (object) – An object that modifies or interacts with the session.

Returns:

A UUID string uniquely identifying the registered affector.

Return type:

str

unique_features
class ionique.datatypes.TraceFile(current: ndarray, voltage=None, rank='file', parent=None, unique_features: dict = {}, metadata: dict = {})

Bases: Segment

Data structure for representing a single trace file with current and optional voltage information.

This class inherits from Segment and encapsulates current and voltage data. It sets up segment metadata, defines parent-child hierarchy, and optionally initializes child segments based on voltage steps. If voltage steps are provided, corresponding child segments of rank "vstep" are created automatically.

Parameters:
  • current (numpy.ndarray) – Array of ionic current values.

  • voltage (list of tuple or None, optional) – List of ((start, end), voltage_value) tuples used to create child segments for each voltage step. Defaults to None.

  • rank (str, optional) – Segment rank label. Defaults to "file".

  • parent (Segment or None, optional) – Parent segment to which this trace belongs. Defaults to None.

  • unique_features (dict, optional) – Dictionary of metadata such as sampling frequency. Defaults to an empty dict.

  • metadata (dict, optional) – Additional metadata. Defaults to an empty dict.

__init__(current: ndarray, voltage=None, rank='file', parent=None, unique_features: dict = {}, metadata: dict = {})

Initialize the TraceFile and optionally create voltage-step child segments.

children: list[AnySegment]
delete()

Delete the current object, removing it from its parent

end: int | None
parent: AnySegment | None
plot(rank, axes, downsample_per_rank, color_per_rank)

Plot the trace data at a specified rank with per-rank styling options.

Parameters:
  • rank (str) – The segment rank at which to render the plot.

  • axes (object) – The axes or figure object to draw on.

  • downsample_per_rank (dict) – Mapping of rank label to downsampling factor for rendering.

  • color_per_rank (dict) – Mapping of rank label to color specification for rendering.

Notes

Not yet implemented.

rank: str
start: int | None