neurotools.spatial.phase module

Statistics routines to examine population statistics of phases and complex-valued (phase,amplitude) analytic signals.

neurotools.spatial.phase.population_kuramoto(pop, axis=0)[source]

Compute the Kuramoto order parameter of a population of complex- valued phase oscillators.

If an array is provided, the average is taken over the first array dimension unless otherwise specified.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Kuramotor order parameter of the population

Return type:

float or np.array

neurotools.spatial.phase.population_synchrony(pop, axis=0)[source]

Estimate phase-oscillator population synchrony. This is similar to the Kuramoto order parameter, but weights each oscillator by its amplitude. Since signal measurements typically have nonzero noise, phase estimates from low-amplitude oscillators are less reliable.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Oscillator synchrony over the population

Return type:

float or np.array

neurotools.spatial.phase.population_polar_std(pop, axis=0)[source]

The circular standard deviation of a collection of phase oscillators. This is a transformation of population_synchrony with units of radians, which is easier to interpret.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Circular standard deviation over the population

Return type:

float or np.array

neurotools.spatial.phase.population_average_amplitude(pop, axis=0)[source]

Compute the average absolute amplitude of a population of complex- valued phase oscillators.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Average amplitude over the population

Return type:

float or np.array

neurotools.spatial.phase.population_signal_dispersion(pop, axis=0)[source]

A standardized measure of the dispersion of a population of complex- valued phase oscillators. Computes the determinant of the covariance matrix describing the 2D distribution of (phases, amplitudes) in the complex plane, raised to the 1/4th power. This has the same units as the linear dimension of the signal. For example, if the underlying signals are in mV, then this is a standard measure of how dispersed the analytic signals are in the complex plane, also in mV.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed Standardized measure of dispersion

Return type:

float or np.array

neurotools.spatial.phase.population_signal_concentration(pop, axis=0)[source]

Returns a standardized, unitless measure of the concentration of a population of complex-valued (phase,amplitude) oscillators. This is analagous to the reciprocal of the coefficient of variation for univariate data. Larger values indicate more precise distributions.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed Standardized measure of concentration

Return type:

float or np.array

neurotools.spatial.phase.population_signal_precision(pop, axis=0)[source]

Returns 1/σ where σ=population_signal_dispersion is a standardized measure of the dispersion in the population.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed Standardized measure of precision

Return type:

float or np.array

neurotools.spatial.phase.population_signal_phase_dispersion(pop, axis=0)[source]

Coefficient of variation of phases, estimated using a local linearization around the mean phase.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_phase_std(pop, axis=0)[source]

Standard deviation of phases locally linearized around the mean phase

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_amplitude_std(pop, axis=0)[source]

Standard deviation of amplitudes locally linearized around the mean phase

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_amplitude_dispersion(pop, axis=0)[source]

Coefficient of variation of amplitudes, locally linearized around the mean phase

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_phase_precision(pop, axis=0)[source]

Inverse coefficient of variation of phases, estimated using a local linearization around the mean phase.

Parameters:
  • pop (pop of oscillator phases; 1D np.complex array)

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_amplitude_precision(pop, axis=0)[source]

Inverse coefficient of variation of amplitudes, estimated using a local linearization around the mean phase.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

Depending on whether a 1D or ND array was passed

Return type:

float or np.array

neurotools.spatial.phase.population_signal_description(pop, axis=0)[source]

Returns a statistical of a population of complex-valued phase oscillators.

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

  • z (complex) – Average analytic signals

  • a (float) – Magnitude of average analytic signal

  • h (float) – Mean phase

  • s1 – Standard deviation of linearized phases

  • s2 – Standard deviation of linearized amplitudes

neurotools.spatial.phase.population_synchrony_linear(pop, axis=0)[source]

Transformed population synchrony score

Parameters:
  • pop (np.array) – Array of complex-valued phases of a population of phase oscillators. Expectations are taken over the first dimension only unless otherwise specified.

  • axis (int, default 0) – Axis over which to operate

Returns:

1/(1-population_synchrony(pop))

Return type:

np.array

neurotools.spatial.phase.population_phase_coherence(data)[source]

Extracts median frequency. Uses this to unwrap array phases. Applies a per-channel phase shift to zero mean phase.

Parameters:

data (array-like) – No. of channels × No. of timepoints

Return type:

np.array

Example

s,a,tr = ('SPK120918', 'M1', 16)
pop  = get_all_analytic_pop(s,a,tr,epoch=(6,-1000,2001),fa=10,fb=45)
data = pop[:,500:600]
sliding = np.array([population_phase_coherence(pop[:,i:i+100]) for i in range(shape(pop)[1]-100)])
neurotools.spatial.phase.analytic_signal_coherence(data, window=<function hanning>)[source]

Extracts median frequency. Uses this to unwrap array phases. Applies a per-channel phase shift to zero mean phase.

Parameters:
  • data (array-like) – K x N K = No. of channels N = No. of timepoints

  • L – Window length in samples, optional, default is 100

  • window (function) – windowing function, optional, default is np.hanning

  • axis (int, default 0) – Axis over which to operate

Return type:

np.array

Example

s,a,tr = ('SPK120918', 'M1', 16)
pop = get_all_analytic_pop(s,a,tr,epoch=(6,-1000,2001),fa=10,fb=45)
data = pop[:,500:600]
sliding = np.array([population_signal_coherence(pop[:,i:i+100]) for i in range(shape(pop)[1]-100)])
neurotools.spatial.phase.population_sliding_signal_coherence(data, L=100, window=<function hanning>)[source]

Extracts median frequency. Uses this to unwrap array phases. Applies a per-channel phase shift to zero mean phase.

Parameters:
  • data (array-like) – K x N K = No. of channels N = No. of timepoints

  • axis (int, default 0) – Axis over which to operate

  • L – Window length in samples, optional, default is 100

  • window (function) – windowing function, optional, default is np.hanning

Returns:

Sliding-window Kuramoto order parameter over data

Return type:

np.array

neurotools.spatial.phase.sliding_population_signal_coherence(data, L=100, window=<function hanning>)

Extracts median frequency. Uses this to unwrap array phases. Applies a per-channel phase shift to zero mean phase.

Parameters:
  • data (array-like) – K x N K = No. of channels N = No. of timepoints

  • axis (int, default 0) – Axis over which to operate

  • L – Window length in samples, optional, default is 100

  • window (function) – windowing function, optional, default is np.hanning

Returns:

Sliding-window Kuramoto order parameter over data

Return type:

np.array

neurotools.spatial.phase.population_normalized_sliding_signal_coherence(data, L=100, window=<function hanning>)[source]

Extracts median frequency. Uses this to unwrap array phases. Applies a per-channel phase shift to zero mean phase.

Parameters:
  • data (array-like) – K x N K = No. of channels N = No. of timepoints

  • L – Window length in samples, optional, default is 100

  • window (function) – windowing function, optional, default is np.hanning

  • axis (int, default 0) – Axis over which to operate

Return type:

np.array

neurotools.spatial.phase.population_phase_relative_sliding_kuramoto(data, L=100, window=<function hanning>)[source]

Uses the phase of each channel in the middle of each block as a reference point. Separates coherent wave activity from synchrony.

\[\textrm{kuramoto order} = \left\langle z/|z| \right\rangle\]

Assumes constant phase velocity, and a constant per-channel phase shift, and then computes the order. This is a notion of relative phase stability.

Parameters:
  • data (np.array) – Phase data as np.complex

  • L (int, default is 100) – Window length in samples

  • window (function, default is np.hanning) – windowing function, optional

Return type:

np.array

neurotools.spatial.phase.population_median_phase_velocity(data)[source]

median phase velocity.

Parameters:

data (np.array) – 2D array of phases; Nchannels x Ntimes

Returns:

medv – Median phase velocity within the population for every time point

Return type:

np.array

neurotools.spatial.phase.population_median_frequency(data, Fs=1000)[source]

Convert from phase in radians/frame to Frequency in cycles/s

Parameters:
  • data (np.complex array) – Phase array data

  • Fs (int, default 1000) – Sampling rate in Hz

Return type:

np.array