How to export the results of a session#
Write all results to a folder#
To write all results of a session to files, call export_summary with the path of your results folder:
session.export_summary("results")
M3Resp makes the folder if it does not exist. Files with the same names in the folder are replaced. M3Resp writes a file only when the session has the results for it.
Files in the results folder#
File |
Contents |
|---|---|
|
The session metadata, the quality flags, |
|
One file for each list of events in |
|
The values in |
|
The session metadata. |
|
The list of processing steps that made the results (see Provenance and processing history). |
|
One row per signal in |
|
One row per parameter in |
|
The parameters with an array as value, for example the ECG gate mask of the EMG. The row in |
|
One row per breath for each value per breath, for example the TIV and EELI of the EIT: the start time, the end time and the value (see Events, intervals and breaths). |
|
The name, unit, method and settings of each value per breath. The |
|
The values per breath that are arrays, for example a pixel TIV map per breath. The first axis of each array is the breath. The columns |
|
One row per pixel mask in |
|
The pixel grid of each mask, under the |
|
One row per quality flag in |
|
One row per linked breath in |
Write only some of the files#
To select the files, use m3resp.export.export_session_summary(). Set a file group to False to leave it out:
from m3resp.export import export_session_summary
export_session_summary(
session,
"results",
summary_json=True, # summary.json
event_csvs=True, # one CSV file per event list
parameters_csv=True, # parameters.csv
postprocessing=True, # the postprocess_emg results in summary.json and parameters.csv
structured_export=False, # all other files in the table above
)
Link the array files to a workflow run#
If the session has a DataModelRecorder (see Provenance and processing history), give the identifier of the workflow run. M3Resp then links the .npz files to that ProcessingRun:
session.export_summary("results", processing_run_id=result.processing_run_id)
Here result is the WorkflowResult from m3resp.run_workflow().
Export the data model#
export_summary does not write the data model of a DataModelRecorder. To write it, use m3resp.export_store(). It writes one JSON file per table, for example cases.json, sessions.json and processing_runs.json:
from m3resp import export_store
export_store(session.datamodel.store, "results/datamodel")
export_store checks the store first. If a check fails, it writes no file and raises DataModelValidationError with the list of problems.
Call |
What it does |
|---|---|
|
Checks that every record points to records that exist, and that no time window ends before it starts. Then it writes the files. A store recorded from a session passes these checks. |
|
Also checks that every record has the details of a finished analysis: units, sampling rate, start time and file checksums. During processing, some of these details are not known yet, so a store recorded from a session usually fails this check. |
|
Writes the files with no checks. |
To get the list of problems with no export, call m3resp.validate_store().
Export from a workflow file#
In a workflow file, the outputs: section writes the same files at the end of the run. See Workflows.