ehrapy.preprocessing.offset_negative_values#
- ehrapy.preprocessing.offset_negative_values(edata, layer=None, copy=False)[source]#
Offsets negative values into positive ones with the lowest negative value becoming 0.
This is primarily used to enable the usage of functions such as log_norm that do not allow negative values for mathematical or technical reasons.
Supports both 2D and 3D data:
2D data: Standard offset across observations
3D data: Applied to all elements across samples and timestamps
- Parameters:
- Return type:
- Returns:
None if copy=False and modifies the passed edata, else returns an updated object.
Examples
>>> import ehrdata as ed >>> import ehrapy as ep >>> import numpy as np >>> edata = ed.dt.physionet2012(layer="tem_data") >>> np.nanmin(edata.layers["tem_data"]) -17.8 >>> ep.pp.offset_negative_values(edata, layer="tem_data") >>> np.nanmin(edata.layers["tem_data"]) 0.0