coco_pipe.io.units#
Analysis-unit enumeration for multi-mode EEG pipelines.
An analysis unit is a (container-slice, metadata) pair that feeds one independent analysis run (dim-reduction, decoding, connectivity, …). The supported modes are:
flatOne unit per scope — the entire container is used as-is.
sensorOne unit per sensor/channel. For raw inputs the channel dimension is sliced; for descriptor inputs each sensor’s columns are selected and flattened.
familyOne unit per descriptor feature family (descriptor inputs only).
subfamilyOne unit per descriptor sub-family — the output type within a family, e.g. band
log_abs/relor paramaperiodic/peaks(descriptor inputs only; requires afeature_subfamilycoord).sensor_within_familyOne unit per (sensor, family) combination (descriptor inputs only).
sensor_within_subfamilyOne unit per (sensor, sub-family) combination (descriptor inputs only; requires a
feature_subfamilycoord).featureOne unit per descriptor feature across all sensors.
feature_within_familyOne unit per (feature, family) combination across all sensors.
descriptorOne unit per descriptor across all sensors — all aggregation-stat columns of a descriptor (e.g. mean + iqr of alpha) kept together (requires a
feature_descriptorcoord).descriptor_sensorOne unit per (descriptor, sensor) — one descriptor’s stats at a single sensor (requires a
feature_descriptorcoord).
Functions#
|
Enumerate analysis units from container according to analysis_mode. |
Module Contents#
- coco_pipe.io.units.iter_analysis_units(container, analysis_mode, input_mode, descriptor_families=None)#
Enumerate analysis units from container according to analysis_mode.
Each returned dict has the keys:
unit_type— one of"global","sensor","family","subfamily","feature", or"descriptor"unit_name— human-readable identifier (e.g."Fz","band")unit_key— filesystem-safe unique key (e.g."band_Fz")family— descriptor family name, orNonesubfamily— descriptor sub-family name, orNonecontainer— the sliced/flattenedDataContainerfor this unit
The container’s
metadict is also updated in-place with theunit_type/unit_name/unit_key/family/subfamilyfields so that downstream functions can read the unit context from the container without needing to carry the dict separately.- Parameters:
container (coco_pipe.io.structures.DataContainer) – Full data container for one analysis scope/condition.
analysis_mode (str) –
The unit granularity.
"flat"and"sensor"work for both input modes; the remaining modes require descriptor inputs:"flat"— one unit for the whole container."sensor"— one unit per sensor/channel."family"— one unit per descriptor feature family."subfamily"— one unit per sub-family (needs afeature_subfamilycoord)."sensor_within_family"— one unit per (sensor, family)."sensor_within_subfamily"— one unit per (sensor, sub-family) (needs afeature_subfamilycoord)."feature"— one unit per feature across all sensors."feature_within_family"— one unit per (feature, family)."descriptor"— one unit per descriptor across all sensors (needs afeature_descriptorcoord)."descriptor_sensor"— one unit per (descriptor, sensor) (needs afeature_descriptorcoord).
input_mode (str) –
"raw"or"descriptors". Controls which container dimension is sliced for the"sensor"mode.descriptor_families (list[str] | None) – Ordered list of feature families to include.
Nonemeans all families present in the container.
- Returns:
One entry per analysis unit in the order they should be processed.
- Return type:
- Raises:
ValueError – On unsupported analysis_mode / input_mode combinations, or when no features match the requested families.
RuntimeError – When no features match in sensor mode.