spine.io.parse.data

Data structures used as canonical outputs of IO parsers.

Classes

ParserEdgeIndex(features, span)

Container describing one edge-index payload.

ParserIndex(features, span)

Container describing one flat index payload.

ParserIndexList(features, span[, single_counts])

Container describing one jagged index-list payload.

ParserObjectList(object_list, default[, ...])

Object list with index shifting instructions.

ParserTensor(features[, coords, meta, ...])

Container describing a parsed tensor-like payload.

class spine.io.parse.data.ParserTensor(features: ndarray, coords: ndarray | None = None, meta: ImageMeta3D | None = None, index_shifts: ndarray | None = None, index_cols: ndarray | None = None, remove_duplicates: bool = False, sum_cols: ndarray | None = None, avg_cols: ndarray | None = None, prec_col: int | None = None, precedence: ndarray | None = None, feats_only: bool = False, overlay_reference: str | None = None)[source]

Container describing a parsed tensor-like payload.

features

Feature matrix associated with the parsed tensor.

Type:

np.ndarray

coords

Sparse tensor coordinates, typically with shape (N, 3).

Type:

np.ndarray, optional

meta

Geometry metadata used to convert voxel indices into detector coordinates.

Type:

Meta, optional

index_shifts

Shifts applied to index-bearing feature columns during batching.

Type:

np.ndarray, optional

index_cols

Feature columns that store indices.

Type:

np.ndarray, optional

remove_duplicates

If True, drop duplicate coordinates during collation.

Type:

bool, default False

sum_cols

Feature columns that should be summed when duplicates are merged.

Type:

np.ndarray, optional

avg_cols

Feature columns that should be averaged when duplicates are merged.

Type:

np.ndarray, optional

prec_col

Feature column used to break duplicate-coordinate ties.

Type:

int, optional

precedence

Precedence ordering used with prec_col.

Type:

np.ndarray, optional

feats_only

If True, the payload is feature-only and has no associated coordinate tensor.

Type:

bool, default False

overlay_reference

Product key whose duplicate-cleaning row selection should be applied to this tensor during overlay.

Type:

str, optional

Attributes:
avg_cols
coords
feat_avg_cols

Return duplicate-averaged columns in feature-only coordinates.

feat_index_cols

Return index-bearing columns expressed in feature-only coordinates.

feat_prec_col

Return the precedence column in feature-only coordinates.

feat_sum_cols

Return duplicate-summed columns in feature-only coordinates.

index_cols
index_shifts
meta
overlay_reference
prec_col
precedence
sum_cols
features: ndarray
coords: ndarray | None = None
meta: ImageMeta3D | None = None
index_shifts: ndarray | None = None
index_cols: ndarray | None = None
remove_duplicates: bool = False
sum_cols: ndarray | None = None
avg_cols: ndarray | None = None
prec_col: int | None = None
precedence: ndarray | None = None
feats_only: bool = False
overlay_reference: str | None = None
property feat_index_cols: ndarray | None

Return index-bearing columns expressed in feature-only coordinates.

Returns:

Feature-column indices corresponding to index_cols.

Return type:

np.ndarray, optional

property feat_sum_cols: ndarray | None

Return duplicate-summed columns in feature-only coordinates.

Returns:

Feature-column indices corresponding to sum_cols.

Return type:

np.ndarray, optional

property feat_avg_cols: ndarray | None

Return duplicate-averaged columns in feature-only coordinates.

Returns:

Feature-column indices corresponding to avg_cols.

Return type:

np.ndarray, optional

property feat_prec_col: int | None

Return the precedence column in feature-only coordinates.

Returns:

Feature-column index corresponding to prec_col.

Return type:

int, optional

class spine.io.parse.data.ParserIndex(features: ndarray, span: int)[source]

Container describing one flat index payload.

features

One-dimensional index array.

Type:

np.ndarray

span

Parent-entry span used when batching entries.

Type:

int

features: ndarray
span: int
class spine.io.parse.data.ParserIndexList(features: list[ndarray], span: int, single_counts: ndarray | None = None)[source]

Container describing one jagged index-list payload.

features

List of one-dimensional index arrays.

Type:

list[np.ndarray]

span

Parent-entry span used when batching entries.

Type:

int

single_counts

Per-index sizes used to restore jagged list structure after batching.

Type:

np.ndarray, optional

Attributes:
single_counts
features: list[ndarray]
span: int
single_counts: ndarray | None = None
class spine.io.parse.data.ParserEdgeIndex(features: ndarray, span: int)[source]

Container describing one edge-index payload.

features

Two-dimensional edge-index array with shape (2, E).

Type:

np.ndarray

span

Parent-entry node span used when batching entries.

Type:

int

features: ndarray
span: int
class spine.io.parse.data.ParserObjectList(object_list: list[Any], default: Any, index_shifts: int | dict[str, int] | None = None)[source]

Object list with index shifting instructions.

index_shifts

Shift(s) to apply to object index attributes during collation.

Type:

int or dict[str, int]

Attributes:
to_object_list

Drop parser-specific batching metadata and return a plain ObjectList.

Methods

append(object, /)

Append object to the end of the list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse(/)

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

property to_object_list: ObjectList

Drop parser-specific batching metadata and return a plain ObjectList.

Returns:

Underlying object list without index_shifts metadata.

Return type:

ObjectList