eitprocessing.datahandling.continuousdata¶
Attributes¶
Classes¶
Container for data with a continuous time axis. |
Module Contents¶
- class eitprocessing.datahandling.continuousdata.ContinuousData[source]¶
Bases:
eitprocessing.datahandling.DataContainer
,eitprocessing.datahandling.mixins.slicing.SelectByTime
Container for data with a continuous time axis.
Continuous data is assumed to be sequential (i.e. a single data point at each time point, sorted by time) and continuously measured/created at a fixed sampling frequency. However, a fixed interval between consecutive time points is not enforced to account for floating point arithmetic, devices with imperfect sampling frequencies, and other sources of variation.
- Parameters:
label – Computer readable naming of the instance.
name – Human readable naming of the instance.
unit – Unit of the data, if applicable.
category – Category the data falls into, e.g. ‘airway pressure’.
description – Human readable extended description of the data.
parameters – Parameters used to derive this data.
derived_from – Traceback of intermediates from which the current data was derived.
values – Data points.
- copy(label: str, *, name: str | None = None, unit: str | None = None, description: str | None = None, parameters: dict | None = None) typing_extensions.Self [source]¶
Create a copy.
Whenever data is altered, it should probably be copied first. The alterations should then be made in the copy.
- derive(label: str, function: collections.abc.Callable, func_args: dict | None = None, **kwargs) typing_extensions.Self [source]¶
Create a copy deriving data from values attribute.
- Parameters:
label – New label for the derived object.
function – Function that takes the values and returns the derived values.
func_args – Arguments to pass to function, if any.
**kwargs – Values for changed attributes of derived object.
Example: ``` def convert_data(x, add=None, subtract=None, multiply=None, divide=None):
- if add:
x += add
- if subtract:
x -= subtract
- if multiply:
x *= multiply
- if divide:
x /= divide
return x
- data = ContinuousData(
name=”Lung volume (in mL)”, label=”volume_mL”, unit=”mL”, category=”volume”, values=some_loaded_data
) derived = data.derive(“volume_L”, convert_data, {“divide”: 1000}, name=”Lung volume (in L)”, unit=”L”) ```
- lock(*attr: str) None [source]¶
Lock attributes, essentially rendering them read-only.
Locked attributes cannot be overwritten. Attributes can be unlocked using unlock().
- Parameters:
*attr – any number of attributes can be passed here, all of which will be locked. Defaults to “values”.
Examples
>>> # lock the `values` attribute of `data` >>> data.lock() >>> data.values = [1, 2, 3] # will result in an AttributeError >>> data.values[0] = 1 # will result in a RuntimeError
- unlock(*attr: str) None [source]¶
Unlock attributes, rendering them editable.
Locked attributes cannot be overwritten, but can be unlocked with this function to make them editable.
- Parameters:
*attr – any number of attributes can be passed here, all of which will be unlocked. Defaults to “values”.
Examples
>>> # lock the `values` attribute of `data` >>> data.lock() >>> data.values = [1, 2, 3] # will result in an AttributeError >>> data.values[0] = 1 # will result in a RuntimeError >>> data.unlock() >>> data.values = [1, 2, 3] >>> print(data.values) [1,2,3] >>> data.values[0] = 1 # will result in a RuntimeError >>> print(data.values) 1