A Python library for the analysis of experimental data.
Copyright 2011-2014 Sebastiaan MathĂ´t
- class DataMatrix
- function DataMatrix.__add__(dm, cautious=False)
- function DataMatrix.__getitem__(key)
- function DataMatrix.__init__(a, structured=False)
- function DataMatrix.__iter__()
- function DataMatrix.__len__()
- function DataMatrix.__setitem__(key, val)
- function DataMatrix.addField(key, default=None, dtype=<type 'numpy.int32'>)
- function DataMatrix.asArray()
- function DataMatrix.balance(key, maxErr, ref=0, verbose=False)
- function DataMatrix.calcPerc(vName, targetVName, keys=None, nBin=None)
- function DataMatrix.collapse(keys, vName)
- function DataMatrix.columns(dtype=False)
- function DataMatrix.count(key)
- function DataMatrix.explode(N)
- function DataMatrix.group(keys, _sort=True)
- function DataMatrix.intertrialer(keys, dv, _range=[1])
- function DataMatrix.range()
- function DataMatrix.recode(key, coding)
- function DataMatrix.removeField(key)
- function DataMatrix.removeNan(key)
- function DataMatrix.rename(oldKey, newKey)
- function DataMatrix.select(query, verbose=True)
- function DataMatrix.selectByStdDev(keys, dv, thr=2.5, verbose=False)
- function DataMatrix.selectColumns(keys)
- function DataMatrix.shuffle()
- function DataMatrix.sort(keys, ascending=True)
- function DataMatrix.split(key)
- function DataMatrix.ttest(keys, dv, paired=True, collapse=None)
- function DataMatrix.unique(key)
- function DataMatrix.where(query)
- function DataMatrix.withinize(vName, targetVName, key, verbose=True, whiten=False)
Provides functionality for convenient processing of experimental data.
Concatenates two DataMatrices. Implements the + operator.
Example:
dm3 = dm1 + dm2
Arguments:
dm
-- The DataMatrix to be appended.- Type: DataMatrix
Keywords:
cautious
-- DEPRECATED- Default: False
Returns:
The concatenation of the current and the passed DataMatrix.
- Type: DataMatrix
Returns a column, index, or slice. Note that some operations return a copy of the DataMatrix, so they cannot be used to modify the contents of the DataMatrix.
Example:
dm['rt'] # returns column 'rt' as numpy array
dm[0] # returns first row as DataMatrix
dm[0:2] # returns first two rows as DataMatrix
dm[0]['rt'] = 1 # This doesn't alter the original DataMatrix
dm['rt'][0] = 1 # This does!
Arguments:
key
-- A column name or index.- Type: int, str, unicode
Returns:
A DataMatrix or NumPy array corresponding to a slice or column from this DataMatrix.
- Type: DataMatrix, ndarray
Creates a new DataMatrix object.
Arguments:
a
-- A NumPy array, list, or filename. For unstructured NumPy arrays or lists, the first row is assumed to contain column names. Filenames are assumed to refer to a.npy
file.- Type: ndarray, list, str, unicode
Keywords:
structured
-- Indicates whethera
is a structured NumPy array.- Default: False
- Type: bool
Implements an iterator for 'for' loops to walk through a DataMatrix row by row.
Example:
for rowDm in dm:
print rowDm
Returns:
No description
- Type: DataMatrixIterator
No description specified.
Returns:
The number of rows.
- Type: int
Set a certain variable. Implements assigment.
Example:
dm['rt'] = 100
Arguments:
key
-- The name of a key.- Type: str, unicode
val
-- An array with the new values, or a single new value to use for the entire column.
Creates a new DataMatrix that is a copy of the current DataMatrix with an additional field.
Example:
dm = dm.addField('rt', dtype=float, default=-1000)
Source(s):
-
-
<:>
-
</>
-
</>
-
-
<.>
-
</>
-
-
-
-
</>
-
<1>
-
<2>
-
<0>
-
<1>
-
<8>
-
<1>
-
<7>
-
</>
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
< >
-
<->
-
<->
-
<->
-
<->
-
<->
-
-
<->
-
-
<->
-
<>> Arguments:
-
key
-- The name of the new field.- Type: str, unicode
Keywords:
default
-- The default value orNone
for no default.- Default: None
dtype
-- The dtype for the new field.- Default: <type 'numpy.int32'>
Returns:
No description
- Type: DataMatrix.
No description specified.
Returns:
An array representation of the current DataMatrix.
- Type: ndarray
Filters the data such that a given column is on average close to a reference value, and is symetrically distributed.
Arguments:
maxErr
-- The maximum mean error relative to the reference value.- Type: int, float
key
-- The key to balance. It must have a numeric dtype.- Type: str, unicode
Keywords:
ref
-- The reference value.- Default: 0
- Type: int, float
verbose
-- Indicates whether verbose output is printed.- Default: False
- Type: bool
Returns:
A balanced copy of the current DataMatrix.
- Type: DataMatrix
Calculates percentile scores for a variable.
Arguments:
targetVName
-- The variable to store the percentile scores in. This variable must exist, it is not created.- Type: str, unicode
vName
-- The variable to calculate percentile scores for.- Type: str, unicode
Keywords:
keys
-- A key or list of keys to split the data by, before calculating percentile scores, so you can calculate scores individually per subject, condition, etc.- Default: None
- Type: list, str, unicode
nBin
-- The number of bins or None for continuous scores.- Default: None
- Type: int, NoneType
Returns:
No description
- Type: DataMatrix
Collapse the data by a (list of) keys and get statistics on a dependent variable.
Arguments:
keys
-- A key or list of keys to collapse the data on.- Type: list, str, unicode
vName
-- The dependent variable to collapse. Alternative, you can specifiy a function, in which case the error will be 0.- Type: str, unicode, function
Returns:
A DataMatrix with the collapsed data, with the descriptives statistics on vName
.
- Type: DataMatrix
Returns a list of the columns.
Keywords:
dtype
-- Indicates whether the dtype for each column should be returned as well.- Default: False
- Type: bool
Returns:
If dtype == False: A list of names If dtype == True: A list of (name, dtype) tuples
- Type: list
Returns the number of different values for a given variable.
Arguments:
key
-- The variable to count.- Type: str, unicode
Returns:
The number of different values for 'key'.
- Type: int
Break up the DataMatrix in N smaller DataMatrices. For splitting a DataMatrix based on column values, see DataMatrix.split.
Arguments:
N
-- The number of DataMatrices to explode in.- Type: int
Returns:
A list of DataMatrices.
- Type: list
Split the data into different groups based on unique values for the key variables.
Arguments:
keys
-- A key or list of keys to split the data on.- Type: str, unicode, list
Keywords:
_sort
-- Indicates whether the groups should be sorted by values.- Default: True
- Type: bool
Returns:
A list of DataMatrices.
- Type: list
Adds columns that contain values from the previous or next trial. These columns are called '[dv]_p1' for the next value, '[dv]_m1' for the previous one, etc.
Arguments:
keys
-- A key or list of keys that define the trial order.- Type: list, str, unicode
dv
-- The dependent variable.- Type: str, unicode
Keywords:
_range
-- A list of integers that specifies the range for which the operation should be executed.- Default: [1]
- Type: list
Returns:
No description
- Type: DataMatrix
Gives a list of indices to walk through the current DataMatrix.
Returns:
A list of indices.
Recodes values (i.e. changes one value into another for a given set of columns).
Arguments:
coding
-- An (oldValue, newValue) tuple, a list of tuples to handle multiple recodings in one go, or a function that takes a value and returns the recoded value.- Type: tuple, list, function
key
-- The name of the variable to recode, or a list of names to recode multiple variables in one go.- Type: str, unicode, list
Return a DataMatrix that is a copy of the current DataMatrix without the specified field.
Arguments:
key
-- The name of the field to be removed.- Type: str, unicode
Returns:
No description
- Type: DataMatrix
Remove all rows where the specified key is nan.
Arguments:
key
-- A key that should not have any nan values.- Type: str, unicode
Returns:
No description
- Type: DataMatrix
Renames a column. This function operates in place, so it modifies the current dataMatrix.
Arguments:
newKey
-- The new name.- Type: str, unicode
oldKey
-- The old name.- Type: str, unicode
Returns:
No description
- Type: DataMatrix
Select a subset of the data.
Arguments:
query
-- A query, e.g. 'rt > 1000'.- Type: str, unicode
Keywords:
verbose
-- Indicates if a summary should be printed.- Default: True
- Type: bool
Returns:
No description
- Type: DataMatrix
Select only those rows where the value of a given column is within a certain distance from the mean.
Arguments:
keys
-- A list of keys to create groups for which the deviation is calculated seperately.- Type: list
dv
-- The dependent variable.- Type: str, unicode
Keywords:
thr
-- The stddev threshold.- Default: 2.5
- Type: float, int
verbose
-- Indicates whether detailed output should be provided.- Default: False
- Type: bool
Returns:
No description
- Type: DataMatrix
Creates a new DataMatrix with only the specified columns.
Arguments:
keys
-- A column or list of columns to select.- Type: list, str, unicode
Returns:
No description
- Type: DataMatrix
Shuffles the DataMatrix in place.
Sorts the DataMatrix in place.
Arguments:
keys
-- A key or list of keys to use for sorting. The first key is dominant, the second key is next-to-dominant, etc.- Type: str, unicode, list
Keywords:
ascending
-- Indicates whether the sorting should occur in ascending (True) or descending (False) order.- Default: True
- Type: bool
Splits the DataMatrix in chunks such that each chunk only has the same value for the specified column. For splitting a DataMatrix into equally sized parts, see DataMatrix.explode.
Arguments:
key
-- A key to split by.- Type: str, unicode
Returns:
A list of DataMatrices.
- Type: list
Performs t-tests between groups defined by a list of keys.
Arguments:
keys
-- A list of keys to define the groups.- Type: list
dv
-- The dependent variable.- Type: str, unicode
Keywords:
paired
-- Determines whether a paired-samples t-test or an independent samples t-test should be conducted.- Default: True
- Type: bool
collapse
-- A key to collapse the data on, so that you can do t-tests on (subject) means.- Default: None
- Type: str, unicode, NoneType
Returns:
A list of (desc, t, p) tuples.
- Type: list
Gives all unique values for a particular key.
Arguments:
key
-- A column name.- Type: str, unicode
Returns:
A list of unique values.
- Type: list
Return indices corresponding to the query.
Arguments:
query
-- A query, e.g. 'rt > 1000'.- Type: str, unicode
Returns:
Indices.
- Type: ndarray
Removes the between factor variance for a given key (such as subject or file) for a given dependent variable. This operation acts in place.
Arguments:
targetVName
-- The target variable to store withinized values. This variable should exist.- Type: str, unicode
vName
-- The dependent variable to withinize.- Type: str, unicode
key
-- The key that defines the group.- Type: str, unicode
Keywords:
verbose
-- Indicates whether the results should be printed.- Default: True
- Type: bool
whiten
-- Indicates whether the data should be whitened so that the standard deviation is 1 and the mean 0.- Default: False
- Type: bool
Returns:
No description
- Type: DataMatrix