nigsp.operations.timeseries.normalise_ts

nigsp.operations.timeseries.normalise_ts(timeseries, globally=False)[source]

Normalise given timeseries (i.e. mean=0, std=1).

It is assumed that time is encoded in the second dimension (axis 1), e.g. for 90 voxels and 300 timepoints, shape is [90, 300].

Any timeseries with std == 0 is returned as a series of 0s.

Parameters:
timeseriesnumpy.ndarray

The input timeseries. It is assumed that the second dimension is time.

globallybool, optional

If True, normalise timeseries across the first two axes.

Returns:
numpy.ndarray

The normalised timeseries (mean=0 std=1) if timeseries is not a 1D array. If timeseries is a 1D array, it is returned as is.