MNE-CPP  0.1.9
A Framework for Electrophysiology
Public Types | Public Member Functions | Static Public Member Functions | List of all members
UTILSLIB::MNEMath Class Reference

Math methods. More...

#include <mnemath.h>

Public Types

typedef std::pair< int, int > IdxIntValue
 

Public Member Functions

virtual ~MNEMath ()
 

Static Public Member Functions

static int gcd (int iA, int iB)
 
static Eigen::VectorXd * combine_xyz (const Eigen::VectorXd &vec)
 
static double getConditionNumber (const Eigen::MatrixXd &A, Eigen::VectorXd &s)
 
static double getConditionSlope (const Eigen::MatrixXd &A, Eigen::VectorXd &s)
 
static void get_whitener (Eigen::MatrixXd &A, bool pca, QString ch_type, Eigen::VectorXd &eig, Eigen::MatrixXd &eigvec)
 
static void get_whitener (Eigen::MatrixXd &A, bool pca, const std::string &ch_type, Eigen::VectorXd &eig, Eigen::MatrixXd &eigvec)
 
static Eigen::VectorXi intersect (const Eigen::VectorXi &v1, const Eigen::VectorXi &v2, Eigen::VectorXi &idx_sel)
 
static bool issparse (Eigen::VectorXd &v)
 
static Eigen::MatrixXd legendre (qint32 n, const Eigen::VectorXd &X, QString normalize=QString("unnorm"))
 
static Eigen::MatrixXd legendre (qint32 n, const Eigen::VectorXd &X, std::string normalize="unnorm")
 
static Eigen::SparseMatrix< double > * make_block_diag (const Eigen::MatrixXd &A, qint32 n)
 
static int nchoose2 (int n)
 
static qint32 rank (const Eigen::MatrixXd &A, double tol=1e-8)
 
static Eigen::MatrixXd rescale (const Eigen::MatrixXd &data, const Eigen::RowVectorXf &times, const QPair< float, float > &baseline, QString mode)
 
static Eigen::MatrixXd rescale (const Eigen::MatrixXd &data, const Eigen::RowVectorXf &times, const std::pair< float, float > &baseline, const std::string &mode)
 
template<typename T >
static Eigen::VectorXi sort (Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, bool desc=true)
 
template<typename T >
static Eigen::VectorXi sort (Eigen::Matrix< T, Eigen::Dynamic, 1 > &v_prime, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat, bool desc=true)
 
template<typename T >
static std::vector< Eigen::Triplet< T > > sortrows (const std::vector< Eigen::Triplet< T > > &A, qint32 column=0)
 
template<typename T >
static bool compareIdxValuePairBiggerThan (const std::pair< int, T > &lhs, const std::pair< int, T > &rhs)
 
template<typename T >
static bool compareIdxValuePairSmallerThan (const std::pair< int, T > &lhs, const std::pair< int, T > &rhs)
 
template<typename T >
static bool compareTripletFirstEntry (const Eigen::Triplet< T > &lhs, const Eigen::Triplet< T > &rhs)
 
template<typename T >
static bool compareTripletSecondEntry (const Eigen::Triplet< T > &lhs, const Eigen::Triplet< T > &rhs)
 
template<typename T >
static double log2 (const T d)
 
template<typename T >
static void histcounts (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &matRawData, bool bMakeSymmetrical, int iClassAmount, Eigen::VectorXd &vecResultClassLimits, Eigen::VectorXi &vecResultFrequency, double dGlobalMin=0.0, double dGlobalMax=0.0)
 
template<typename T >
static void histcounts (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &matRawData, bool bMakeSymmetrical, int iClassAmount, Eigen::VectorXd &vecResultClassLimits, Eigen::VectorXi &vecResultFrequency, double dGlobalMin=0.0, double dGlobalMax=0.0)
 
template<typename T >
static void histcounts (const Eigen::Matrix< T, 1, Eigen::Dynamic > &matRawData, bool bMakeSymmetrical, int iClassAmount, Eigen::VectorXd &vecResultClassLimits, Eigen::VectorXi &vecResultFrequency, double dGlobalMin=0.0, double dGlobalMax=0.0)
 
template<typename T >
static Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > pinv (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &a)
 
static bool compareTransformation (const Eigen::MatrixX4f &mDevHeadT, const Eigen::MatrixX4f &mDevHeadTNew, const float &fThreshRot, const float &fThreshTrans)
 

Detailed Description

Math methods.

ToDo make this a template class Generalized math methods used by mne methods

Definition at line 87 of file mnemath.h.

Member Typedef Documentation

◆ IdxIntValue

typedef std::pair<int,int> UTILSLIB::MNEMath::IdxIntValue

Typedef of a pair of ints.

Definition at line 90 of file mnemath.h.

Constructor & Destructor Documentation

◆ ~MNEMath()

virtual UTILSLIB::MNEMath::~MNEMath ( )
inlinevirtual

Destroys the MNEMath object

Definition at line 96 of file mnemath.h.

Member Function Documentation

◆ combine_xyz()

VectorXd * MNEMath::combine_xyz ( const Eigen::VectorXd &  vec)
static

ToDo make this a template function

mne_combine_xyz

MNE toolbox root function

Compute the three Cartesian components of a vector together

Parameters
[in]vecInput row vector [ x1 y1 z1 ... x_n y_n z_n ].
Returns
Output vector [x1^2+y1^2+z1^2 ... x_n^2+y_n^2+z_n^2 ].

Definition at line 81 of file mnemath.cpp.

◆ compareIdxValuePairBiggerThan()

template<typename T >
bool UTILSLIB::MNEMath::compareIdxValuePairBiggerThan ( const std::pair< int, T > &  lhs,
const std::pair< int, T > &  rhs 
)
inlinestatic

Compares two index-value-pairs.

Parameters
[in]lhsleft hand side of the comparison.
[in]rhsright hand side of the comparison.
Returns
true if value of lhs is bigger than value of rhs.

Definition at line 571 of file mnemath.h.

◆ compareIdxValuePairSmallerThan()

template<typename T >
bool UTILSLIB::MNEMath::compareIdxValuePairSmallerThan ( const std::pair< int, T > &  lhs,
const std::pair< int, T > &  rhs 
)
inlinestatic

Compares two index-value-pairs.

Parameters
[in]lhsleft hand side of the comparison.
[in]rhsright hand side of the comparison.
Returns
true if value of lhs is smaller than value of rhs.

Definition at line 580 of file mnemath.h.

◆ compareTransformation()

bool MNEMath::compareTransformation ( const Eigen::MatrixX4f &  mDevHeadT,
const Eigen::MatrixX4f &  mDevHeadTNew,
const float &  fThreshRot,
const float &  fThreshTrans 
)
static

Compare new head position with current head position and update dev_head_t if big displacement occured

Parameters
[in]mDevHeadTransThe device to head transformation matrix to compare to.
[in]mDevHeadTransNewThe device to head transformation matrix to be compared.
[in]fTreshRotThe threshold for big head rotation in degree.
[in]fThreshTransThe threshold for big head movement in m.
Returns
bState The status that shows if devHead is updated or not.

Definition at line 572 of file mnemath.cpp.

◆ compareTripletFirstEntry()

template<typename T >
bool UTILSLIB::MNEMath::compareTripletFirstEntry ( const Eigen::Triplet< T > &  lhs,
const Eigen::Triplet< T > &  rhs 
)
inlinestatic

Compares triplet first entry

Parameters
[in]lhsleft hand side of the comparison.
[in]rhsright hand side of the comparison.
Returns
true if value of lhs is smaller than value of rhs.

Definition at line 589 of file mnemath.h.

◆ compareTripletSecondEntry()

template<typename T >
bool UTILSLIB::MNEMath::compareTripletSecondEntry ( const Eigen::Triplet< T > &  lhs,
const Eigen::Triplet< T > &  rhs 
)
inlinestatic

Compares triplet second entry

Parameters
[in]lhsleft hand side of the comparison.
[in]rhsright hand side of the comparison.
Returns
true if value of lhs is smaller than value of rhs.

Definition at line 598 of file mnemath.h.

◆ gcd()

int MNEMath::gcd ( int  iA,
int  iB 
)
static

Finds the Greatest Common Divisor (GCD) of two integer values

Parameters
[in]aFirst input integer.
[in]bSecond input integer.
Returns
The Greatest Common Divisor (GCD) of a and b.

Definition at line 70 of file mnemath.cpp.

◆ get_whitener() [1/2]

static void UTILSLIB::MNEMath::get_whitener ( Eigen::MatrixXd &  A,
bool  pca,
QString  ch_type,
Eigen::VectorXd &  eig,
Eigen::MatrixXd &  eigvec 
)
static

Returns the whitener of a given matrix.

Parameters
[in]AMatrix to compute the whitener from.
[in]pcaperform a pca.
Returns
rank of matrix A.

◆ get_whitener() [2/2]

static void UTILSLIB::MNEMath::get_whitener ( Eigen::MatrixXd &  A,
bool  pca,
const std::string &  ch_type,
Eigen::VectorXd &  eig,
Eigen::MatrixXd &  eigvec 
)
static

Returns the whitener of a given matrix.

Parameters
[in]AMatrix to compute the whitener from.
[in]pcaperform a pca.
Returns
rank of matrix A.

◆ getConditionNumber()

double MNEMath::getConditionNumber ( const Eigen::MatrixXd &  A,
Eigen::VectorXd &  s 
)
static

MNE toolbox root function ###: Definition of the mne_block_diag function - decoding part

Returns the condition number of a given matrix.

Parameters
[in]AMatrix to compute the condition number from.
Returns
the condition number.

Definition at line 104 of file mnemath.cpp.

◆ getConditionSlope()

double MNEMath::getConditionSlope ( const Eigen::MatrixXd &  A,
Eigen::VectorXd &  s 
)
static

Returns the condition slope of a given matrix.

Parameters
[in]AMatrix to compute the condition number from.
Returns
the condition slope.

Definition at line 117 of file mnemath.cpp.

◆ histcounts()

template<typename T >
void UTILSLIB::MNEMath::histcounts ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  matRawData,
bool  bMakeSymmetrical,
int  iClassAmount,
Eigen::VectorXd &  vecResultClassLimits,
Eigen::VectorXi &  vecResultFrequency,
double  dGlobalMin = 0.0,
double  dGlobalMax = 0.0 
)
static

creates a class and frequency distribution from data matrix

Parameters
[in]matRawDataraw data matrix that needs to be analyzed.
[in]bMakeSymmetricaluser input to turn the x-axis symmetric.
[in]iClassCountuser input to determine the amount of classes in the histogram.
[out]vecResultClassLimitsthe upper limit of each individual class.
[out]vecResultFrequencythe amount of data that fits in the appropriate class ranges.
[in]dGlobalMinuser input to determine the maximum value allowed in the histogram.
[in]dGlobalMaxuser input to determine the minimum value allowed in the histogram.

Definition at line 647 of file mnemath.h.

◆ intersect()

VectorXi MNEMath::intersect ( const Eigen::VectorXi &  v1,
const Eigen::VectorXi &  v2,
Eigen::VectorXi &  idx_sel 
)
static

Find the intersection of two vectors

Parameters
[in]v1Input vector 1.
[in]v2Input vector 2.
[out]idx_selIndex of intersection based on v1.
Returns
the sorted, unique values that are in both of the input arrays.

Definition at line 194 of file mnemath.cpp.

◆ issparse()

bool MNEMath::issparse ( Eigen::VectorXd &  v)
static

Determines if a given data (stored as vector v) are representing a sparse matrix. ToDo: status is experimental -> needs to be increased in speed.

Parameters
[in]vdata to be tested.
Returns
true if sparse false otherwise;.

Definition at line 288 of file mnemath.cpp.

◆ legendre() [1/2]

static Eigen::MatrixXd UTILSLIB::MNEMath::legendre ( qint32  n,
const Eigen::VectorXd &  X,
QString  normalize = QString("unnorm") 
)
static

LEGENDRE Associated Legendre function.

P = LEGENDRE(N,X) computes the associated Legendre functions of degree N and order M = 0, 1, ..., N, evaluated for each element of X. N must be a scalar integer and X must contain real values between -1 <= X <= 1.

Returns
associated Legendre functions.

◆ legendre() [2/2]

static Eigen::MatrixXd UTILSLIB::MNEMath::legendre ( qint32  n,
const Eigen::VectorXd &  X,
std::string  normalize = "unnorm" 
)
static

LEGENDRE Associated Legendre function.

P = LEGENDRE(N,X) computes the associated Legendre functions of degree N and order M = 0, 1, ..., N, evaluated for each element of X. N must be a scalar integer and X must contain real values between -1 <= X <= 1.

Returns
associated Legendre functions.

◆ log2()

template<typename T >
double UTILSLIB::MNEMath::log2 ( const T  d)
inlinestatic

Compute log2 of given number

Parameters
[in]dinput value.
Returns
double result of log2 operation.

Definition at line 607 of file mnemath.h.

◆ make_block_diag()

SparseMatrix< double > * MNEMath::make_block_diag ( const Eigen::MatrixXd &  A,
qint32  n 
)
static

ToDo make this a template function

MNE toolbox root function ###: Definition of the mne_block_diag function - encoding part

Make a sparse block diagonal matrix

Returns a sparse block diagonal, diagonalized from the elements in "A". "A" is ma x na, comprising bdn=(na/"n") blocks of submatrices. Each submatrix is ma x "n", and these submatrices are placed down the diagonal of the matrix.

Parameters
[in,out]AMatrix which should be diagonlized.
[in,out]nColumns of the submatrices.
Returns
A sparse block diagonal, diagonalized from the elements in "A".

Definition at line 348 of file mnemath.cpp.

◆ nchoose2()

int MNEMath::nchoose2 ( int  n)
static

Calculates the combination of n over 2 (nchoosek(n,2))

Parameters
[in]nThe number of elements which should be combined with each other (n over 2).
Returns
The number of combinations.

Definition at line 388 of file mnemath.cpp.

◆ pinv()

template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > UTILSLIB::MNEMath::pinv ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  a)
static

Creates the pseudo inverse of a matrix.

Parameters
[in]araw data matrix that needs to be analyzed.

Definition at line 755 of file mnemath.h.

◆ rank()

qint32 MNEMath::rank ( const Eigen::MatrixXd &  A,
double  tol = 1e-8 
)
static

ToDo make this a template function

Returns the rank of a matrix A.

Parameters
[in]AMatrix to get the rank from.
[in]tolrealtive threshold: biggest singualr value multiplied with tol is smallest singular value considered non-zero.
Returns
rank of matrix A.

Definition at line 400 of file mnemath.cpp.

◆ rescale() [1/2]

static Eigen::MatrixXd UTILSLIB::MNEMath::rescale ( const Eigen::MatrixXd &  data,
const Eigen::RowVectorXf &  times,
const QPair< float, float > &  baseline,
QString  mode 
)
static

ToDo: Maybe new processing class

Rescale aka baseline correct data

Parameters
[in]dataData Matrix (m x n_time).
[in]timesTime instants is seconds.
[in]baselineIf baseline is (a, b) the interval is between "a (s)" and "b (s)". If a and b are equal use interval between the beginning of the data and the time point 0 (stimulus onset).
[in]modeDo baseline correction with ratio (power is divided by mean power during baseline) or zscore (power is divided by standard. deviatio of power during baseline after substracting the mean, power = [power - mean(power_baseline)] / std(power_baseline)). ("logratio" | "ratio" | "zscore" | "mean" | "percent")
Returns
rescaled data matrix rescaling.

◆ rescale() [2/2]

static Eigen::MatrixXd UTILSLIB::MNEMath::rescale ( const Eigen::MatrixXd &  data,
const Eigen::RowVectorXf &  times,
const std::pair< float, float > &  baseline,
const std::string &  mode 
)
static

ToDo: Maybe new processing class

Rescale aka baseline correct data

Parameters
[in]dataData Matrix (m x n_time).
[in]timesTime instants is seconds.
[in]baselineIf baseline is (a, b) the interval is between "a (s)" and "b (s)". If a and b are equal use interval between the beginning of the data and the time point 0 (stimulus onset).
[in]modeDo baseline correction with ratio (power is divided by mean power during baseline) or zscore (power is divided by standard. deviatio of power during baseline after substracting the mean, power = [power - mean(power_baseline)] / std(power_baseline)). ("logratio" | "ratio" | "zscore" | "mean" | "percent")
Returns
rescaled data matrix rescaling.

◆ sort() [1/2]

template<typename T >
Eigen::VectorXi UTILSLIB::MNEMath::sort ( Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v,
bool  desc = true 
)
static

Sorts a vector (ascending order) in place and returns the track of the original indeces

Parameters
[in,out]vvector to sort; it's sorted in place.
[in]descif true its sorted in a descending order, otherwise ascending (optional, default = true).
Returns
Vector of the original indeces in the new order.

Definition at line 499 of file mnemath.h.

◆ sort() [2/2]

template<typename T >
Eigen::VectorXi UTILSLIB::MNEMath::sort ( Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v_prime,
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  mat,
bool  desc = true 
)
static

Sorts a vector (ascending order) and a corresponding matrix in place and returns the track of the original indeces The matrix is sorted along the columns using the vector values for comparison.

Parameters
[in,out]v_primevector to sort (sorted in place).
[in,out]matmatrix to sort (sorted in place).
[in]descif true its sorted in a descending order, otherwise ascending (optional, default = true).
Returns
Vector of the original indeces in the new order.

Definition at line 531 of file mnemath.h.

◆ sortrows()

template<typename T >
std::vector< Eigen::Triplet< T > > UTILSLIB::MNEMath::sortrows ( const std::vector< Eigen::Triplet< T > > &  A,
qint32  column = 0 
)
static

Sort rows in ascending order

Parameters
[in]Atriplet vector to sort (sorted in place).
[in]columnsorts the triplet vector based on the column specified.
Returns
Vector of the original indeces in the new order.

Definition at line 552 of file mnemath.h.


The documentation for this class was generated from the following files: