Public API#

This page lists the classes and functions that you import from m3resp. Each name links to a page with its arguments, its return value and the units. The page of a class or function also lists the tutorials that use it.

See the Concepts for what the objects mean.

Sessions and workflows#

An M3Session holds the recordings and the results of one analysis. The presets and the workflow functions run the processing steps.

m3resp.M3Session

Recordings, processing results and provenance for a multimodal study session.

m3resp.Preset

A named preset that runs a fixed sequence of M3Session methods.

m3resp.EITPreset

Preprocess loaded EIT data and store its detected breaths.

m3resp.EMGPreset

Preprocess loaded EMG, remove ECG, detect breaths and calculate features.

m3resp.MultimodalPreset

Set recording start times and align detected breaths across modalities.

m3resp.WorkflowResult

Results, timing and execution records for one workflow run.

m3resp.available_presets

Return the names of all registered presets, sorted.

m3resp.get_preset

Return the Preset class registered under name.

m3resp.register_preset

Store preset_cls under name, replacing any existing registration.

m3resp.load_spec

Load a workflow from an object, dictionary or YAML/JSON file.

m3resp.run_workflow

Run a workflow's ordered steps and return their results and records.

m3resp.run_spec

Run a workflow file, write its manifest and apply its export settings.

m3resp.available_steps

Return a mapping of registered step name -> one-line summary.

m3resp.register_step

Register a function and its workflow inputs, outputs and descriptions.

m3resp.workflows.WorkflowSpec

An ordered workflow description with inputs, settings and export options.

m3resp.workflows.StepSpec

One operation and its input, parameter and output bindings.

m3resp.workflows.ValidationReport

Structural diagnostics and optional checks for running a workflow locally.

m3resp.workflows.CompiledWorkflow

An ordered description of workflow steps with resolved settings.

m3resp.workflows.WorkflowService

Discover workflow steps, inspect specs and run workflows for an application.

m3resp.workflows.collect_diagnostics

Collect structural errors and warnings for all resolvable workflow steps.

m3resp.workflows.compile_workflow

Validate a workflow and resolve the settings needed to run its steps.

m3resp.workflows.validate_workflow

Check workflow structure and optionally its readiness on this machine.

m3resp.workflows.validate_spec

Check workflow structure and raise for its first error.

Signals, results and quality#

These objects hold the processed signals, the calculated parameters, the quality checks and the record of each processing step.

m3resp.TimeSeries

A value array paired with its time axis.

m3resp.Signal

A TimeSeries tagged with modality and provenance context.

m3resp.SignalCollection

An ordered collection of Signal objects, queryable by modality.

m3resp.interpolate_to_time

Return a copy of signal with its values at the time points time.

m3resp.ParameterResult

A named, unit-tagged metric produced by a processing step.

m3resp.ParameterResultCollection

An ordered collection of ParameterResult objects.

m3resp.QualityFlag

The outcome of one quality check against a signal, breath, or run.

m3resp.QualityReport

An ordered collection of QualityFlag results.

m3resp.ProcessingStep

A record of one executed processing operation.

m3resp.ProcessingHistory

An ordered log of ProcessingStep entries for one session or run.

Events and synchronization#

These objects and functions hold breaths, events and values per breath, and put the recordings on one clock.

m3resp.Event

A timestamped event from one modality.

m3resp.Interval

A stretch of time from one modality, with a start and an end.

m3resp.BreathEvent

One breath from one modality, with a signal turning point.

m3resp.EventData

One value for each event, in the same order as the events.

m3resp.IntervalData

One value for each interval, in the same order as the intervals.

m3resp.IntervalDataCollection

An ordered collection of results with values per interval or breath.

m3resp.PixelMap

One number for each pixel of an EIT image.

m3resp.PixelMask

Which pixels of an EIT image belong to a region.

m3resp.PixelMaskCollection

An ordered collection of pixel masks, such as lung-space masks.

m3resp.pixel_breath_events

Return the breaths of one pixel as BreathEvent objects.

m3resp.LinkedBreath

One physiological breath, matched across any number of modalities.

m3resp.coerce_event

Convert one timestamped event into an Event.

m3resp.coerce_events

Convert an iterable of events into a list of Event objects.

m3resp.coerce_interval

Convert one timed interval into an Interval.

m3resp.coerce_intervals

Convert an iterable of intervals into a list of Interval objects.

m3resp.coerce_breath_event

Convert one detected breath into a BreathEvent.

m3resp.coerce_breath_events

Convert an iterable of breaths into a list of BreathEvent objects.

m3resp.event_to_dict

Return the fields of an event, interval or breath as a dictionary.

m3resp.compute_offsets_from_timestamps

Convert absolute per-device start timestamps into manual offsets (plan_stage2.md Sec 20, "timestamp alignment").

m3resp.link_breaths_by_time

Group breaths across modalities by their timing in seconds.

Data model#

The data model is a set of checked records of a finished analysis. See Provenance and processing history.

m3resp.Case

Opaque grouping of sessions belonging to one external study subject.

m3resp.ClinicalEvent

Time-stamped intervention or notable occurrence (doc Sec 7.9).

m3resp.DataFile

A physical file holding raw/processed/derived data (doc Sec 8.1).

m3resp.DataModelRecorder

Store a session's recordings, results and processing provenance.

m3resp.DataModelStore

A dict-of-id-to-entity table per entity type, plus relational lookups.

m3resp.DerivedFeature

A quantitative result computed from one or more source streams (doc Sec 7.11).

m3resp.Device

Physical or software system that produces data (doc Sec 7.3).

m3resp.ProcessingRun

A stored record of a workflow, processing step or session action.

m3resp.QualityAnnotation

Polymorphic quality label (doc Sec 11).

m3resp.RecordingSession

One continuous acquisition period (doc Sec 7.2).

m3resp.SignalStream

Base type for every continuous signal (doc Sec 7.4).

m3resp.export_store

Write one JSON file per table to out_dir.

m3resp.validate_store

Return a list of readable problem descriptions (empty if none found).

Export#

This function writes the results of a session to CSV, JSON and array files.

m3resp.export.export_session_summary

Write session summaries, result tables and array archives.

Load a recording#

These functions load one recording without a session.

m3resp.io.load_eit

Load an EIT recording through the EIT adapter.

m3resp.io.load_emg

Load an EMG recording through the EMG adapter (ReSurfEMGAdapter by default).

Plots#

These functions make figures with Matplotlib.

m3resp.visualization.plot_eit_processing_summary

Plot the results of the EIT processing of a session.

m3resp.visualization.plot_session_overview

Plot the loaded EIT signal and the processed EMG signals of a session.

m3resp.visualization.plot_synchronization_comparison

Plot each signal before and after synchronization.

Synthetic data#

These classes and functions make synthetic EIT, EMG and ventilator recordings for tests and examples.

m3resp.synthetic.SyntheticGeneratorConfig

Top-level configuration for a synthetic multimodal dataset.

m3resp.synthetic.SyntheticDataset

Generated multimodal dataset.

m3resp.synthetic.SyntheticRecord

Generated signal plus metadata and export paths.

m3resp.synthetic.RespiratoryPatternConfig

Shared respiratory timing and occlusion settings.

m3resp.synthetic.EITGeneratorConfig

Synthetic EIT signal and Draeger export settings.

m3resp.synthetic.EMGGeneratorConfig

Synthetic EMG settings passed to ReSurfEMG.

m3resp.synthetic.VentilatorGeneratorConfig

Synthetic ventilator settings passed to ReSurfEMG.

m3resp.synthetic.generate_synthetic_dataset

Generate synthetic EIT, EMG, and ventilator data from one configuration.

m3resp.synthetic.generate_realistic_eit_signal

Generate a realistic synthetic breathing-related impedance waveform.

m3resp.synthetic.load_synthetic_generator_config

Load a synthetic generator configuration from a YAML file.