Slicing data to a time window#
M3Resp can slice your data to a time window, for example to analyse one ventilator setting of a protocol, or to leave out a period with interference from another device. This page lists all ways to slice and says which one to use.
Slice a recording or a signal#
First decide what you want to slice:
A recording is all data from one file: for an EIT
.binfile, the pixel data, the global impedance, the other channels in the file (airway pressure, flow, CO2, pod pressures) and the markers. A recording has its own clock and a start time insession.start_times(see Synchronization and breath timing). The slice cannot be undone: the samples outside the time window are removed from the loaded recording, and M3Resp moves the start time, so the recording stays in line with the other recordings. To get the removed samples back, load the file again.A signal is one quantity over time, for example the global impedance or an EMG envelope. One recording can give many signals. A slice of a signal is a copy of the selected segment, available to the next workflow steps. The signal and the recording do not change, and no samples are removed.
The step names show this: *.slice_recording slices a recording, and *.slice_signal slices one signal.
All ways to slice#
# |
Call |
What it slices |
Time window given as |
Alignment with other recordings |
|---|---|---|---|---|
1 |
|
The EMG recording, and the ventilator channels in the same file (for example the airway pressure in a Biopac export) |
Seconds from the first sample |
Yes: the EMG start time moves later |
2 |
|
The EIT recording (pixel data, global impedance, other channels, markers), and the ventilator data in the same |
Seconds from the first image |
Yes: the EIT start time moves later |
3 |
|
The separate ventilator recordings (loaded with |
Seconds from the first sample |
Yes: the start time of each sliced recording moves later |
4 |
Step |
One signal in a workflow: an M3Resp |
Sample numbers ( |
No |
5 |
|
Reads only a part of the EIT file |
Image numbers |
Not needed: it happens before the synchronization |
Ways 1 to 4 keep the samples from
startup to the sample beforeend.Ways 1 to 3 keep all samples from
startto the end of the recording if you leave outend.eit.slice_signalalways needsend.Way 5 takes the number of the first image and the number of images.
slice_eituseseitprocessing(Sequence.select_by_index).eit.slice_signaluseseitprocessingfor its data and M3Resp for aSignal. The other ways are part of M3Resp.
Slice ventilator data#
The file of the ventilator data gives its clock, so it also gives the way to slice it:
Ventilator data from |
Slice it with |
|---|---|
The EMG file, for example the airway pressure in a Biopac export |
1, |
The EIT |
2, |
Its own file, loaded with |
3, |
slice_ventilator refuses ventilator data from the EIT or EMG file, because a separate slice would move it out of line with its recording. Each separate ventilator recording can have its own start time ("ventilator:<name>"), so slice_ventilator can slice one of them and leave the others.
Rules#
Slice the recordings before the preprocessing.
slice_eitandslice_ventilatorrefuse to run after the preprocessing of that modality, because the preprocessed results cover the whole recording.slice_emgruns, but it slices only the loaded EMG: the filtered EMG and the envelope insession.signalskeep their full length.A slice removes the samples outside the time window from the loaded recording. Load the file again to get them back.
In a workflow, the steps after a slice use the sliced recording.
eit.slice_recordinggives it under the names ofeit.load(raw_eit,raw_global_impedance,eit_sequenceand the two raw signals).emg.slice_recordinggives it under the names ofemg.load(emg_recording,raw_emg_signals). The raw signals of the sliced recording replace the full ones insession.signals.eit.slice_signalwithmode: timeuses the time values of the signal. An EIT file can have the time of day as its times: a Dräger file can start at 36528.6 s. Theslice_recordingsteps always use seconds from the start.slice_eitselects the images by their times. The times of a device can be a little uneven, so 100 s can hold a slightly different number of images than the image rate × 100 s.The older step names still work:
emg.slicerunsemg.slice_recording, andeit.slicerunseit.slice_signal.
Example: slice two recordings to the same time#
Put an EIT recording and a separate ventilator file on the shared clock, then slice both to the same period:
session.load_eit("recording.bin", vendor="draeger")
session.load_ventilator("ventilator.txt", source="ventilator")
# The ventilator started 40 s before the EIT.
session.synchronize_raw_modalities(offset_seconds={"eit": 0.0, "ventilator": -40.0}, reference_modality="eit")
session.slice_eit(600.0, 900.0) # 10 to 15 minutes into the EIT file
session.slice_ventilator(640.0, 940.0) # the same period on the clock of the ventilator
# Both sliced recordings now start at 600 s on the shared clock.
The same in a workflow file:
- uses: eit.load
with: { file_path: "@eit_file", vendor: draeger }
- uses: eit.slice_recording
with: { start_seconds: 600.0, end_seconds: 900.0 }
- uses: ventilator.load
with: { file_path: "@ventilator_file", source: ventilator }
- uses: ventilator.slice_recording
with: { start_seconds: 640.0, end_seconds: 940.0 }
Example: slice one signal#
Slice the global impedance for a breath detection window, and keep the recording whole:
- id: detection_window
uses: eit.slice_signal
in: { signal: global_impedance }
with: { start: 0, end: 1550, mode: index }
out: { result: detection_signal }
Where the code is#
What |
File |
|---|---|
The session methods |
|
The slice of one recording |
|
The |
|
The slice of one signal |
|
The workflow steps |
|
Start times |
|
Continue with Provenance and processing history.