Skip to content

Commit a34b3f7

Browse files
committed
Use similar stream + electrode names if no exact match
1 parent 62b6311 commit a34b3f7

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* processor_) :
112112
cache = std::make_unique<SpikeDisplayCache>();
113113
}
114114

115+
void SpikeDisplayCanvas::applyCachedDisplaySettings(int plotIdx, std::string key)
116+
{
117+
spikeDisplay->setMonitorStateForPlot(plotIdx, cache->isMonitored(key));
118+
119+
for (int j = 0; j < processor->getNumberOfChannelsForElectrode(plotIdx); j++)
120+
{
121+
spikeDisplay->setThresholdForWaveAxis(plotIdx,j,cache->getThreshold(key,j));
122+
spikeDisplay->setRangeForWaveAxis(plotIdx,j,cache->getRange(key, j));
123+
}
124+
}
125+
115126
void SpikeDisplayCanvas::update()
116127
{
117128

@@ -132,17 +143,16 @@ void SpikeDisplayCanvas::update()
132143

133144
std::string cacheKey = processor->getSpikeChannel(i)->getIdentifier().toStdString();
134145

135-
if (cache && cache->hasCachedDisplaySettings(cacheKey))
146+
if (cache)
136147
{
137-
138-
spikeDisplay->setMonitorStateForPlot(i, cache->isMonitored(cacheKey));
139-
140-
for (int j = 0; j < processor->getNumberOfChannelsForElectrode(i); j++)
148+
if (cache->hasCachedDisplaySettings(cacheKey))
141149
{
142-
spikeDisplay->setThresholdForWaveAxis(i,j,cache->getThreshold(cacheKey,j));
143-
spikeDisplay->setRangeForWaveAxis(i,j,cache->getRange(cacheKey, j));
150+
applyCachedDisplaySettings(i, cacheKey);
151+
}
152+
else if (cache->findSimilarKey(cacheKey).size() > 0)
153+
{
154+
applyCachedDisplaySettings(i, cache->findSimilarKey(cacheKey));
144155
}
145-
146156
}
147157

148158
}

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ class SpikeDisplayCache
8181
return thresholds.count(cacheKey) > 0;
8282
};
8383

84+
std::string findSimilarKey(std::string key)
85+
{
86+
std::vector<std::string> keys = extract_keys(ranges);
87+
for (int i = 0; i < keys.size(); i++)
88+
{
89+
std::string partToMatch = key.substr(3, key.length() - 3);
90+
std::string possibleMatch = keys[i].substr(3, keys[i].length() - 3);
91+
if (partToMatch.compare(possibleMatch) == 0)
92+
return keys[i];
93+
}
94+
return "";
95+
}
96+
8497
private:
8598

8699
std::map<std::string, std::map<int, double>> ranges;
@@ -178,6 +191,9 @@ class SpikeDisplayCanvas : public Visualizer,
178191
/** Loads display parameters */
179192
void loadCustomParametersFromXml(XmlElement* xml);
180193

194+
/** Apply cached settings */
195+
void applyCachedDisplaySettings(int plotIdx, std::string cacheKey);
196+
181197
/** Pointer to the underlying SpikeDisplayNode*/
182198
SpikeDisplayNode* processor;
183199

0 commit comments

Comments
 (0)