#include <CDespike.h>
Collaboration diagram for CDespike:

Public Member Functions | |
| void | Restart () |
| void | FindNextSpike () |
| void | FindNextSpike (const titdata begin, const titdata end) |
| int | StackSpikes () |
| int | StackSpikes (const titdata begin, const titdata end) |
| void | RemoveSpikes () |
| void | RemoveSpikes (const titdata begin, const titdata end) |
| void | FindAllSpikes () |
| int | WriteSpikeForm (std::string filename) |
| CDespike () | |
| ~CDespike () | |
Public Attributes | |
| titdata | CurrentSpike |
| titdata | CurrentTime |
| tvspikeindex | SpikeIndices |
| int | CurrentIndex |
| ptsdata | Data |
| TimeSeries::ttimedata * | Time |
| double | samplerate |
| double | SpikeMax |
| int | AverageLength |
| ttsdata | RunningAverage |
| ttsdata | SpikeForm |
| int | SpikeLength |
| int | TrailPoints |
| double | HeightThreshold |
| double | TimeThreshold |
| bool | ReachedEnd |
Definition at line 6 of file CDespike.h.
| CDespike::CDespike | ( | ) |
Definition at line 9 of file CDespike.cpp.
References CurrentIndex, and ReachedEnd.
00010 { 00011 ReachedEnd = false; 00012 CurrentIndex = 0; 00013 }
| CDespike::~CDespike | ( | ) |
| void CDespike::Restart | ( | ) |
Definition at line 20 of file CDespike.cpp.
References CurrentIndex, CurrentSpike, CurrentTime, Data, ReachedEnd, and Time.
Referenced by FindAllSpikes().
00021 { 00022 ReachedEnd = false; 00023 CurrentTime = Time->begin(); 00024 CurrentSpike = Data->begin(); 00025 CurrentIndex = 0; 00026 }
| void CDespike::FindNextSpike | ( | ) |
Definition at line 206 of file CDespike.cpp.
References Data.
Referenced by FindAllSpikes(), RemoveSpikes(), and StackSpikes().
00207 { 00208 FindNextSpike(Data->begin(),Data->end()); 00209 }
| void CDespike::FindNextSpike | ( | const titdata | begin, | |
| const titdata | end | |||
| ) |
Definition at line 211 of file CDespike.cpp.
References CurrentIndex, CurrentSpike, CurrentTime, HeightThreshold, IsSpikePreRel(), and ReachedEnd.
00212 { 00213 titdata next; 00214 titdata last; 00215 double prediff, postdiff; 00216 00217 next = CurrentSpike; 00218 last = CurrentSpike; 00219 next++; 00220 last--; 00221 00222 do 00223 { 00224 CurrentIndex++; 00225 CurrentSpike++; 00226 CurrentTime++; 00227 next++; 00228 last++; 00229 prediff = *CurrentSpike - *last; 00230 postdiff = *next - *CurrentSpike; 00231 00232 } 00233 while ( (next < end)&& !(IsSpikePreRel(prediff,postdiff,*CurrentSpike,HeightThreshold))); 00234 if (next >= end) 00235 ReachedEnd = true; 00236 }
Here is the call graph for this function:

| int CDespike::StackSpikes | ( | ) |
Definition at line 117 of file CDespike.cpp.
References Data.
Referenced by ApplyFilter(), and CleanComponent().
00118 { 00119 return StackSpikes(Data->begin(),Data->end()); 00120 }
| int CDespike::StackSpikes | ( | const titdata | begin, | |
| const titdata | end | |||
| ) |
Definition at line 137 of file CDespike.cpp.
References CurrentIndex, CurrentSpike, CurrentTime, Data, FindNextSpike(), ReachedEnd, SpikeForm, SpikeIndices, SpikeLength, SpikeMax, Time, and TrailPoints.
00138 { 00139 int NoEstimates = 0; 00140 titdata StackStart; 00141 titdata AvgStart; 00142 double SpikeMean = 0; 00143 00144 CurrentSpike = begin; 00145 CurrentIndex = distance(Data->begin(),begin); 00146 CurrentTime = Time->begin() + distance(Data->begin(),begin); 00147 ReachedEnd = false; 00148 SpikeIndices.clear(); 00149 SpikeForm.assign(SpikeLength,0); 00150 SpikeMax = 0; 00151 00152 00153 while (ReachedEnd == false) 00154 { 00155 FindNextSpike(begin,end); 00156 SpikeIndices.push_back(CurrentIndex); 00157 if ( (distance(begin,CurrentSpike) > TrailPoints) && 00158 (distance(CurrentSpike,end) > (SpikeLength - TrailPoints)) ) 00159 { 00160 AvgStart = CurrentSpike; 00161 advance(AvgStart, -TrailPoints); 00162 StackStart = SpikeForm.begin(); 00163 for (int j = 0; j < SpikeLength; ++j) 00164 { 00165 *(StackStart) += *(AvgStart); 00166 StackStart++; 00167 AvgStart++; 00168 } 00169 NoEstimates++; 00170 CurrentSpike += SpikeLength; 00171 CurrentIndex += SpikeLength; 00172 CurrentTime += SpikeLength; 00173 if (CurrentSpike > end) 00174 ReachedEnd = true; 00175 } 00176 } 00177 00178 for (StackStart = SpikeForm.begin(); StackStart != SpikeForm.end(); ++StackStart) 00179 { 00180 *(StackStart) /= NoEstimates; 00181 SpikeMean += *(StackStart); 00182 if (*StackStart > SpikeMax) 00183 SpikeMax = *StackStart; 00184 } 00185 SpikeMean /= SpikeLength; 00186 for (StackStart = SpikeForm.begin(); StackStart != SpikeForm.end(); ++StackStart) 00187 { 00188 *(StackStart) -= SpikeMean; 00189 } 00190 cout << "Stacked Estimates :" << NoEstimates << endl; 00191 return NoEstimates; 00192 }
Here is the call graph for this function:

| void CDespike::RemoveSpikes | ( | ) |
Referenced by CleanComponent().
| void CDespike::RemoveSpikes | ( | const titdata | begin, | |
| const titdata | end | |||
| ) |
Definition at line 28 of file CDespike.cpp.
References CurrentIndex, CurrentSpike, CurrentTime, Data, FindNextSpike(), ReachedEnd, SpikeForm, SpikeLength, Time, and TrailPoints.
00029 { 00030 CurrentSpike = begin; 00031 CurrentIndex = begin - Data->begin(); 00032 CurrentTime = Time->begin() + (begin - Data->begin()); 00033 ReachedEnd = false; 00034 00035 vector<double>::iterator datait; 00036 vector<double>::iterator stackit; 00037 00038 //copy(Data->begin(),Data->end(),back_insert_iterator<vector<double> > (CleanData)); 00039 //Data = &CleanData; 00040 while (ReachedEnd == false) 00041 { 00042 FindNextSpike(begin,end); 00043 if ( (distance(begin,CurrentSpike) > TrailPoints) && 00044 (distance(CurrentSpike,end) > (SpikeLength - TrailPoints)) ) 00045 { 00046 datait = CurrentSpike; 00047 advance(datait, -TrailPoints); 00048 stackit = SpikeForm.begin(); 00049 for (int j = 0; j < SpikeLength; ++j) 00050 { 00051 *(datait) -= *(stackit); 00052 //*(datait) += mean; 00053 datait++; 00054 stackit++; 00055 } 00056 } 00057 } 00058 }
Here is the call graph for this function:

| void CDespike::FindAllSpikes | ( | ) |
Definition at line 194 of file CDespike.cpp.
References CurrentIndex, FindNextSpike(), ReachedEnd, Restart(), and SpikeIndices.
00195 { 00196 SpikeIndices.clear(); 00197 Restart(); 00198 while (ReachedEnd == false) 00199 { 00200 FindNextSpike(); 00201 SpikeIndices.push_back(CurrentIndex); 00202 } 00203 00204 }
Here is the call graph for this function:

| int CDespike::WriteSpikeForm | ( | std::string | filename | ) |
Definition at line 122 of file CDespike.cpp.
References SpikeForm.
Referenced by main().
00123 { 00124 ofstream outfile; 00125 00126 outfile.open((filename+".spikeform").c_str()); 00127 for (int i = 0; i < SpikeForm.size(); ++i) 00128 { 00129 outfile.precision(5); 00130 outfile << setw(15) << setfill(' ') << i; 00131 outfile << setw(15) << setfill(' ') << SpikeForm.at(i); 00132 } 00133 outfile.close(); 00134 return 0; 00135 }
| titdata CDespike::CurrentSpike |
Definition at line 11 of file CDespike.h.
Referenced by FindNextSpike(), RemoveSpikes(), Restart(), and StackSpikes().
| titdata CDespike::CurrentTime |
Definition at line 12 of file CDespike.h.
Referenced by FindNextSpike(), RemoveSpikes(), Restart(), and StackSpikes().
| tvspikeindex CDespike::SpikeIndices |
Definition at line 13 of file CDespike.h.
Referenced by CleanComponent(), FindAllSpikes(), and StackSpikes().
Definition at line 14 of file CDespike.h.
Referenced by CDespike(), FindAllSpikes(), FindNextSpike(), RemoveSpikes(), Restart(), and StackSpikes().
| ptsdata CDespike::Data |
Definition at line 24 of file CDespike.h.
Referenced by ApplyFilter(), CleanComponent(), FindNextSpike(), RemoveSpikes(), Restart(), StackSpikes(), and ~CDespike().
Definition at line 25 of file CDespike.h.
Referenced by ApplyFilter(), main(), RemoveSpikes(), Restart(), StackSpikes(), and ~CDespike().
| double CDespike::samplerate |
| double CDespike::SpikeMax |
Definition at line 28 of file CDespike.h.
| ttsdata CDespike::RunningAverage |
Definition at line 29 of file CDespike.h.
| ttsdata CDespike::SpikeForm |
Definition at line 30 of file CDespike.h.
Referenced by ApplyFilter(), CleanComponent(), RemoveSpikes(), StackSpikes(), and WriteSpikeForm().
Definition at line 31 of file CDespike.h.
Referenced by ApplyFilter(), main(), RemoveSpikes(), and StackSpikes().
Definition at line 32 of file CDespike.h.
Referenced by ApplyFilter(), main(), RemoveSpikes(), and StackSpikes().
| double CDespike::HeightThreshold |
Definition at line 33 of file CDespike.h.
Referenced by ApplyFilter(), CleanComponent(), and FindNextSpike().
| double CDespike::TimeThreshold |
Definition at line 34 of file CDespike.h.
| bool CDespike::ReachedEnd |
Definition at line 36 of file CDespike.h.
Referenced by CDespike(), FindAllSpikes(), FindNextSpike(), RemoveSpikes(), Restart(), and StackSpikes().
1.5.1