nirs4all.data.multimodal module
Adapt IO-owned multimodal cohorts to the Python DAG scientific host.
The adapter keeps raw source buffers in IO. It reuses the existing target, metadata and observation index interfaces, without inventing dense features.
- class nirs4all.data.multimodal.MultimodalSpectroDataset(cohort: Any)[source]
Bases:
SpectroDatasetDAG host view of a
nirs4all_io.MultimodalDataset.- content_hash(source_index: int | None = None, sample_rows: list[int] | None = None) str[source]
Fingerprint typed source buffers, optionally restricted to a cohort’s rows.
- data_schema(source_ids: list[str], sample_ids: list[str]) dict[str, Any][source]
Translate the IO descriptors into DAG-ML-Data’s typed source schema.
- property independent_unit_ids: tuple[str, ...] | None
The copied explicit unit labels, independently of split groups.
- property num_features: list[int]
Fixed raw dimensions; variable-length series contribute channel counts.
- property repetition_ids: tuple[str, ...] | None
The copied explicit repetition labels, independently of observations.
- split_features(splitter: Any, pool: list[int]) ndarray[source]
Expose row indices only to explicitly index/label/group-based splitters.
- x(selector: Any, layout: Any = '2d', concat_source: bool = True, include_augmented: bool = True, include_excluded: bool = False) Any[source]
Get feature data with automatic augmented sample aggregation.
- Parameters:
selector – Filter criteria (partition, group, branch, etc.)
layout – Output layout (“2d” or “3d”)
concat_source – If True, concatenate multiple sources along feature axis
include_augmented – If True, include augmented versions of selected samples. If False, return only base samples (origin=null). Default True for backward compatibility.
include_excluded – If True, include samples marked as excluded. If False (default), exclude samples marked as excluded=True. Use True when transforming ALL features (e.g., preprocessing).
- Returns:
Feature data array(s)
Example
>>> # Get all train samples (base + augmented) >>> X_train = dataset.x({"partition": "train"}) >>> # Get only base train samples (for splitting) >>> X_base = dataset.x({"partition": "train"}, include_augmented=False) >>> # Get all features including excluded (for transformations) >>> X_all = dataset.x({"partition": "train"}, include_excluded=True)
- x_rows(sample_ints: list[int], layout: Any = '2d', concat_source: bool = True) Any[source]
Get feature data for an EXACT set of stored rows, addressed by their own sample int.
Unlike
x(), this bypasses the two-phase base-keyed selection: each sample int (base OR augmented) addresses its own storage row directly, and rows are returned in request order. The dag-ml resolver uses it to materialize a view whose ids may include augmented children, which the base-keyedxpath filters out.- Parameters:
sample_ints – Stored-row sample ints to retrieve, in the desired output order.
layout – Output layout (“2d” or “3d”).
concat_source – If True, concatenate multiple sources along the feature axis.
- Returns:
Feature data array(s), one row per requested sample int, in request order.
Example
>>> # Materialize a train view containing base + augmented rows, in a given order >>> X = dataset.x_rows([0, 6, 7, 1, 8, 9])