wonambi.trans.baseline module

wonambi.trans.baseline.apply_baseline(data, baseline='ratio', **axis_to_select)[source]

Apply baseline correction to ChanTime or ChanFreqTime data.

Parameters:
  • data (instance of ChanTime or ChanFreqTime or ChanFreq) – one of the datatypes

  • baseline (str) – type of baseline to apply. One of ‘diff’, ‘ratio’, ‘dB’, ‘relchange’, ‘percent’, ‘normchange’, ‘zscore’

  • axis_to_select (dict) – Specify the subset of data to use as baseline. Examples are: “time=(-0.3, -0.1)” or “freq=(50, 60)” You can specify only one dimension at the time. Values will be passed to wonambi.trans.select.select

Returns:

instance, same class as input – data where baseline has been applied.

Notes

The values of baseline can be (where bl_mean is the mean of the baseline selection and bl_std is the standard deviation of the baseline selection): - diff : data - bl_mean - ratio : data / bl_mean - relchange : (data - bl_mean) / bl_mean - percent : 100 * (data - bl_mean) / bl_mean - normchange : (data - bl_mean) / (data + bl_mean) - zscore : (data - bl_mean) / bl_std

Note that ‘dB’ uses the geometric mean instead of the arithmetic mean, so that the arithmetic mean of the baseline period is then 0 - dB : 10 * log10 (data / bl_mean)

For this reason, you should not take the logarithm of the ‘ratio’, but use ‘dB’ instead.

Furthermore, ‘dB’ and ‘normchange’ are only meaningful for positive-only data. dB will return NaN for negative values and normchange will return incorrect values.