Skip to content

Commit 40a8c2e

Browse files
committed
Fix event triggered averager crashing when coupled with a channel mapper
1 parent fd8df25 commit 40a8c2e

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

Source/Plugins/EvntTrigAvg/EvntTrigAvg.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ void EvntTrigAvg::updateSettings()
8181
clearHistogramArray();
8282
initializeHistogramArray();
8383
initializeMinMaxMean();
84-
electrodeMap.clear();
85-
electrodeMap = createElectrodeMap();
84+
// electrodeMap.clear();
85+
// electrodeMap = createElectrodeMap();
8686
electrodeLabels.clear();
8787
electrodeLabels = createElectrodeLabels();
8888
if(spikeData.size()!=getTotalSpikeChannels())
@@ -201,7 +201,7 @@ void EvntTrigAvg::handleSpike(const SpikeChannel* spikeInfo, const MidiMessage&
201201
int electrode = getSpikeChannelIndex(newSpike);
202202
//std::cout<<"chanIDX: " << chanIDX << "\n";
203203
int sortedID = newSpike->getSortedID();
204-
//int electrode = electrodeMap[chanIDX];
204+
//int electrode = electrodeMap[chanInfo];
205205
if(sortedID!=0 && sortedID>idIndex.size()){ // respond to new sortedID
206206
idIndex.push_back(spikeData[electrode].size());// update map of what sorted ID is on what electrode
207207
}
@@ -299,23 +299,25 @@ int EvntTrigAvg::getLastTTLCalculated()
299299
}
300300

301301
/** creates map to convert channelIDX to electrode number */
302-
std::vector<int> EvntTrigAvg::createElectrodeMap()
302+
/*
303+
std::map<SourceChannelInfo, int> EvntTrigAvg::createElectrodeMap()
303304
{
304-
std::vector<int> map;
305+
std::map<SourceChannelInfo,int> map;
305306
int numSpikeChannels = getTotalSpikeChannels();
306307
int electrodeCounter=0;
307308
for (int chanIt = 0 ; chanIt < numSpikeChannels ; chanIt++){
308309
const SpikeChannel* chan = getSpikeChannel(chanIt);
309310
// add to running count of each electrode
310-
map.resize(map.size()+chan->getNumChannels());
311+
311312
Array<SourceChannelInfo> chanInfo = chan->getSourceChannelInfo();
312313
for (int subChanIt = 0 ; subChanIt < chan->getNumChannels() ; subChanIt++){
313-
map[chanInfo[subChanIt].channelIDX]=electrodeCounter;
314+
315+
map[chanInfo[subChanIt]]=electrodeCounter;
314316
}
315317
electrodeCounter+=1;
316318
}
317319
return map;
318-
}
320+
}*/
319321

320322
std::vector<String> EvntTrigAvg::createElectrodeLabels()
321323
{

Source/Plugins/EvntTrigAvg/EvntTrigAvg.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <ProcessorHeaders.h>
2828
#include "EvntTrigAvgEditor.h"
2929
#include <vector>
30+
#include <map>
3031

3132
class EvntTrigAvgEditor;
3233

@@ -90,8 +91,8 @@ class EvntTrigAvg : public GenericProcessor
9091
float findMax(uint64* data_);
9192
float findMean(uint64* data_); // TODO make running
9293

93-
94-
std::vector<int> createElectrodeMap();
94+
//TODO electrodeMap is not being used right now, fix it to actually work with SourceInfo instead of just indexes
95+
//std::map<SourceChannelInfo,int> createElectrodeMap();
9596
std::vector<String> createElectrodeLabels();
9697

9798
void saveCustomParametersToXml (XmlElement* parentElement) override;
@@ -120,7 +121,7 @@ class EvntTrigAvg : public GenericProcessor
120121
void clearHistogramData(uint64 * const);
121122
Array<uint64*> histogramData; // shared data
122123
Array<float*> minMaxMean; // shared data
123-
std::vector<int> electrodeMap; // Used to identify what electrode a spike came from
124+
//std::map<SourceChannelInfo,int> electrodeMap; // Used to identify what electrode a spike came from
124125
std::vector<String> electrodeLabels;
125126
std::vector<int> idIndex; //sorted ID, electrode. used to match a sortedID with its electrode
126127
std::vector<std::vector<int>> electrodeSortedId;

0 commit comments

Comments
 (0)