.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/descriptors_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_descriptors_example.py: Minimal descriptors example with explicit NumPy inputs. .. GENERATED FROM PYTHON SOURCE LINES 4-71 .. rst-class:: sphx-glr-script-out .. code-block:: none Descriptor matrix shape: (12, 14) First five names: ['band_abs_delta_chgrp-all', 'band_abs_theta_chgrp-all', 'band_abs_alpha_chgrp-all', 'band_abs_beta_chgrp-all', 'band_abs_gamma_chgrp-all'] Failure count: 0 Grouped descriptor shape: (2, 2, 14) Grouped dims: ('obs', 'stat', 'feature') Grouped stats: ['mean', 'std'] | .. code-block:: Python from __future__ import annotations import numpy as np from coco_pipe.descriptors import DescriptorPipeline from coco_pipe.io import DataContainer def main() -> None: rng = np.random.default_rng(42) X = rng.normal(size=(12, 3, 256)) t = np.linspace(0, 1, 256, endpoint=False) X[:, 0, :] += np.sin(2 * np.pi * 10 * t) X[:, 1, :] += np.sin(2 * np.pi * 6 * t) ids = np.asarray([f"obs-{idx:02d}" for idx in range(12)]) config = { "families": { "bands": { "enabled": True, "outputs": ["absolute_power", "corrected_absolute_power"], }, "parametric": { "enabled": True, "outputs": ["aperiodic"], }, "complexity": { "enabled": True, "measures": ["sample_entropy", "hjorth_mobility"], }, }, } channels = ["Fz", "Cz", "Pz"] pipe = DescriptorPipeline(config) result = pipe.extract( X=X, ids=ids, sfreq=256.0, channel_names=channels, ) # Apply pooling after extraction result = pipe.pool_channels(result, {"all": channels}) print("Descriptor matrix shape:", result["X"].shape) print("First five names:", result["descriptor_names"][:5]) print("Failure count:", len(result["failures"])) container = DataContainer( X=result["X"], dims=("obs", "feature"), coords={"feature": result["descriptor_names"]}, ) grouped = container.aggregate( by=["sub-01"] * 6 + ["sub-02"] * 6, stats=["mean", "std"], ) print("Grouped descriptor shape:", grouped.X.shape) print("Grouped dims:", grouped.dims) print("Grouped stats:", grouped.coords["stat"].tolist()) if __name__ == "__main__": main() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.582 seconds) .. _sphx_glr_download_auto_examples_descriptors_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: descriptors_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: descriptors_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: descriptors_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_