seg1d.processing.Features.center

static Features.center(ref_data)[source]

subtract the mean of each feature from itself

Parameters:
ref_dataDict{trial:Dict{feature:val}} or List[Dict{feature:val}]

dictionary of 1d features that will be centered (mean subtracted)

Returns:
cent_dictDict{trial:Dict{feature:val}} or List[Dict{feature:val}]

centered features

Examples

>>> import numpy as np
>>> import seg1d.processing as process
>>> s20 = np.linspace(-np.pi*2, np.pi*2, 10)
>>> s30 = np.linspace(-np.pi*2, np.pi*2, 20) 
>>> s1 = np.sin(s20)
>>> c2 = np.cos(s30)
>>> a1 = {'s1':s1+3, 'c1':np.cos(s20)+10}
>>> a2 = {'s2':np.sin(s30)+15, 'c2':c2+15}
>>> d = [a1, a2]
>>> r = process.Features.center(d)
>>> print( np.allclose(r[0]['s1'], (s1+3)- np.mean(s1+3), atol=1e-05) )
True
>>> print( np.allclose(r[1]['c2'], (c2+15)- np.mean(c2+15), atol=1e-05) )
True