nigsp.operations.timeseries.rescale_ts

nigsp.operations.timeseries.rescale_ts(timeseries, vmin=0, vmax=1, globally=False)[source]

Rescale given timeseries between given max and min value.

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.

vminfloat, optional

The minimum value to scale between.

vmaxfloat, optional

The maximum value to scale between.

globallybool, optional

If True, rescale 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.