Functions

src/averaging.c File Reference

#include "averaging.h"
#include "clustering.h"
#include "eeg.h"
#include "linalg.h"

Go to the source code of this file.

Functions

Arrayaverage_example (const Array *data, uint idx[2], double weights[2], OptArgList *optargs)
 example function to pass as SignalAverageFunction doing a pointwise average.
Arrayaverage_warpmarkers (const Array *data, uint idx[2], double weights[2], OptArgList *optargs)
EEGeeg_simple_average (const EEG *eeg)
Arrayhierarchical_average (const Array *data, const Array *distmat, SignalAverageFunction avgfct, OptArgList *optargs)
 Calculate a hierarchical average based on a cluster-analysis.

Detailed Description

STATUS: stable Averaging functions.

Definition in file averaging.c.


Function Documentation

Array* average_example ( const Array data,
uint  idx[2],
double  weights[2],
OptArgList optargs 
)

example function to pass as SignalAverageFunction doing a pointwise average.

This function is only for testing purposes. The "hierarchically" computed pointwise average should be the same as the normal average.

Parameters:
input data (N x C x n)
index average data[idx[0]] and data[idx[1]]
weights number of trials "behind" each average
optional arguments
Returns:
the average

Definition at line 40 of file averaging.c.

Array* average_warpmarkers ( const Array data,
uint  idx[2],
double  weights[2],
OptArgList optargs 
)

Definition at line 61 of file averaging.c.

EEG* eeg_simple_average ( const EEG eeg  ) 

Calculate a simple, pointwise average across trials

\[ \hat{s}(t) = \frac{1}{N}\sum_{i=1}^{N}s_i(t) \]

Parameters:
eeg input
Returns:
freshly allocate EEG-struct

Definition at line 189 of file averaging.c.

Array* hierarchical_average ( const Array data,
const Array distmat,
SignalAverageFunction  avgfct,
OptArgList optargs 
)

Calculate a hierarchical average based on a cluster-analysis.

The data is average based on the first dimension of the data. I.e., the output is C x n dimensional.

A cluster analysis is carried out using the distance-matrix and the resulting dendrogram is followed to average two trials at a time:

dendrogram.jpg

The averaging uses a callback-function to calculate the average of two signals at a time. This function must be passed by the use of a SignalAverageFunction .

Parameters:
data 2D or 3D double-array containing:

  • N trials (dimension 1)
    • of dimensionality C (dimension 2); e.g. channels
    • and n time-points (dimension 3) if the data is 2D, we assume C=1
distmat a distance matrix (N x N) given distances between trials in data
avgfct a callback-function to calculate the average of two Cxn signals at a time
optargs may contain:

  • Directly used by this function:
  • linkage=void* rule for building the dendrogram, default=dgram_dist_completelinkage
  • progress=void* progress-bar function, called every now and then.
  • You might want to pass additional optargs for the SignalAverageFunction and the linkage function
Returns:
pointer to final average (Cxn)

Definition at line 92 of file averaging.c.