eelbrain.NDVar
- class eelbrain.NDVar(x, dims, name=None, info=None)
Container for n-dimensional data.
- Parameters
x (array_like) – The data.
dims (Union[Dimension, Sequence[Dimension]]) – The dimensions characterizing the axes of the data. If present,
Case
should always occupy the first position.name (str) – Name for the NDVar.
info (dict) – A dictionary with data properties (can contain arbitrary information that will be accessible in the info attribute).
Notes
An
NDVar
consists of the following components:A
numpy.ndarray
, stored in thex
attribute.Meta-information describing each axis of the array using a
Dimension
object (for example,UTS
for uniform time series, orSensor
for a sensor array). These dimensions are stored in thedims
attribute, with the ith element ofdims
describing the ith axis ofx
.A dictionary containing other meta-information stored in the
info
attribute.A name stored in the
name
attribute.
NDVar
objects support the nativeabs()
andround()
functions.Indexing: For classical indexing, indexes need to be provided in the correct sequence. For example, assuming
ndvar
’s first axis is time,ndvar[0.1]
retrieves a slice at time = 0.1 s. If time is the second axis, the same can be achieved withndvar[:, 0.1]
. InNDVar.sub()
, dimensions can be specified as keywords, for example,ndvar.sub(time=0.1)
, regardless of which axis represents the time dimension.Shallow copies: When generating a derived NDVars,
x
anddims
are generated without copying data whenever possible. A shallow copy ofinfo
is stored. This means that modifying a derived NDVar in place can affect the NDVar it was derived from. When indexing an NDVar, the new NDVar will contain a view on the data whenever possible based on the underlying array (See NumPy Indexing). This only matters when explicitly modifying an NDVar in place (e.g.,ndvar += 1
) because NDVar methods that return NDVars never implicitly modify the original NDVars in place (see this note).Examples
Generating
NDVar
: Creating NDVars, EEG speech envelope TRFConvert
NDVar
to univariateVar
: Compare topographies
Methods
|
Compute the absolute values |
|
Summarize data in each cell of |
|
Whether all values are nonzero over given dimensions |
|
Compute presence of any value other than zero over given dimensions |
|
Find the index of the largest value |
|
Find the index of the smallest value |
|
|
|
Copy of the NDVar with data cast to the specified type |
|
Bin the data along a given dimension (default |
|
Clip data (see |
|
A deep copy of the NDVar's data |
|
Discrete difference |
|
Dot product |
|
Compute the Hilbert envelope of a signal |
|
Extrema (value farthest away from 0) over given dimensions |
|
Fast fourier transform |
Return indices where a 1-d NDVar is non-zero |
|
|
Return the data axis for a given dimension name |
|
Retrieve the NDVar's data with a specific axes order. |
|
Return the Dimension object named |
|
Fill in a partially specified tuple of Dimension names |
|
Return a tuple with the requested Dimension objects |
|
Retriev the mask as |
|
|
|
Find and label clusters of values exceeding a threshold |
|
Element-wise log |
|
Create a masked version of this NDVar (see |
|
Compute the maximum over given dimensions |
|
Compute the mean over given dimensions |
|
Compute the minimum over given dimensions |
|
Return indices where the NDVar is non-zero |
|
Norm over |
|
Sample-wise ordinary least squares regressions |
|
Compute T-values for sample-wise ordinary least squares regressions |
|
The value such that q of the NDVar's values are lower |
|
Rename one of the dimensions |
|
Repeat slices of the NDVar along the case dimension |
|
The residuals of sample-wise ordinary least squares regressions |
|
Compute the root mean square over given dimensions |
|
Element-wise indication of the sign |
|
Smooth data by convolving it with a window |
|
Compute the standard deviation over given dimensions |
|
Retrieve a slice through the NDVar. |
|
Compute the sum over given dimensions |
|
Aggregate specified dimensions. |
|
Set all values below a threshold to 0. |
|
Remove mask from a masked |
|
Compute the variance over given dimensions |
|
A new |