Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "tools.h"
00022 #include "eeg.h"
00023 #include "mathadd.h"
00024
00033 EEG* eeg_remove_baseline( EEG *eeg, double win_from, double win_to, bool alloc ){
00034 #ifdef FIXEEG
00035 int lim[2], c, i;
00036 double mean;
00037 EEG *eeg_out;
00038
00039 if( !eeg->times ){
00040 errprintf("Need times-array, aborting...\n");
00041 return NULL;
00042 }
00043
00044 if( alloc ){
00045 eeg_out = eeg_clone( eeg, EEG_CLONE_ALL );
00046 } else {
00047 eeg_out = eeg;
00048 }
00049
00050 lim[0] = closest_index( eeg->times, eeg->n, win_from );
00051 lim[1] = closest_index( eeg->times, eeg->n, win_to );
00052 if( lim[1]<=lim[0] ){
00053 errprintf( "The specified limits are funny: %.2f-%.2f (results in %i-%i)\n",
00054 win_from, win_to, lim[0], lim[1] );
00055 }
00056 for( c=0; c<eeg->nbchan; c++ ){
00057 for( i=0; i<eeg->ntrials; i++ ){
00058 mean=dblp_mean( eeg->data[c][i]+lim[0], lim[1]-lim[0] );
00059
00060 dblp_minus_scalar( eeg->data[c][i], eeg->n, mean );
00061 }
00062 }
00063
00064 return eeg_out;
00065 #endif
00066 }