TimeSeries

class nidmd.TimeSeries(data=None, filenames=None, sampling_time=None)[source]

Representation of time-series data.

Constructor

TimeSeries.__init__(data=None, filenames=None, sampling_time=None)[source]

TimeSeries Constructor.

Parameters
  • data (Array-like, optional) – Preprocessed time-series fMRI data. Can be a list of Array-like.

  • filenames (str, optional) – Filenames of .mat files containing data. Can be a list of str

  • sampling_time (float, optional) – Sampling time of time-series recording.

Methods

TimeSeries.add(data)

Add data

TimeSeries.extract(filename)

Extracts fMRI data from file.

TimeSeries.split(data[, normalize])

Split time-series into X: [1->T] and Y:[0->T-1].

TimeSeries.normalize(data[, direction, …])

Normalize a matrix

TimeSeries.dmd([normalize])

Returns a dictionary-like object containing Dynamic Mode Decomposition elements.

TimeSeries.get_decomposition(x, y)

Get dynamic modes by Least Squares optimization of Auto-regressive model.

TimeSeries.match_modes(tc, s, m)

Match modes using Time Series data of match group and eigenvectors of reference group.

API reference

class nidmd.TimeSeries(data=None, filenames=None, sampling_time=None)[source]

Representation of time-series data.

add(data)[source]

Add data

Parameters

data (Array-like) – Time-series data.

static adjust_phase(x)[source]

Adjust phase of matrix for orthogonalization of columns.

Parameters

x (Array-like) – data matrix

Returns

ox – data matrix with orthogonalized columns

Return type

Array-like

dmd(normalize=True)[source]

Returns a dictionary-like object containing Dynamic Mode Decomposition elements.

Parameters

normalize (boolean) – Normalize data before decomposition (default True)

Returns

dmd – Dynamic Mode Decomposition elements with keys: {values, vectors, indices, A, activity}

Return type

Dictionary-like

extract(filename)[source]

Extracts fMRI data from file. Supported formats are: { code:.mat }

Parameters

filename (str) – Path to file containing time-series data.

Raises

ImportError – If file does not contain matrix

get_decomposition(x, y)[source]

Get dynamic modes by Least Squares optimization of Auto-regressive model.

Parameters
  • x (Array-like) – data for t (1->T)

  • y (Array-like) – data for t (0->T-1)

Returns

  • eig_val (Array-like) – Eigenvalues of the eigen-decomposition of the Auto-regressive matrix

  • eig_vec (Array-like) – Eigenvectors of the eigen-decomposition of the Auto-regressive matrix

  • eig_idx (Array-like) – Indices that sort the eigenvalues in descending order

  • A (Array-like) – The Auto-regressive matrix.

static match_modes(tc, s, m)[source]

Match modes using Time Series data of match group and eigenvectors of reference group.

Parameters
  • tc (Array-like) – Raw time-series data from match group

  • s (Array-like) – Eigenvectors from the eigen-decomposition of the auto-regressive model of the reference group.

  • m (int) – number of modes analyzed for approximation

Returns

d – Approximation of the m first modes matched to the Reference group.

Return type

Array-like

Raises

AtlasError – If cortical parcellation is not supported.

static normalize(data, direction=1, demean=True, destandard=True)[source]

Normalize a matrix

Parameters
  • data (Array-like) – data matrix

  • direction (int, optional) – 0 for columns, 1 for rows (default), None for global

  • demean (boolean, optional) – Normalize mean (default true)

  • destandard (boolean, optional) – Normalize standard-deviation (default true)

Returns

  • x (Array-like) – Normalized matrix

  • mean (float) – Mean of original data.

  • std (float) – Standard deviation of original data.

static split(data, normalize=True)[source]

Split time-series into X: [1->T] and Y:[0->T-1].

Parameters
  • data (Array-like) – Time-series data. Can be list of Array-like.

  • normalize (boolean) – For normalization of the input data.

Returns

  • x (Array-like) – Time-series data from t:1->T

  • y (Array-like) – Time-series data from t:0->T-1

Raises

ValueError – If input is invalid