Skip to content

Commit ae52b3b

Browse files
committed
Store and re-apply spike viewer params after updating
1 parent 79488fc commit ae52b3b

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ void SpikeDisplayCanvas::update()
127127
SpikePlot* sp = spikeDisplay->addSpikePlot(processor->getNumberOfChannelsForElectrode(i), i,
128128
processor->getNameForElectrode(i));
129129
processor->addSpikePlotForElectrode(sp, i);
130+
131+
if (shouldApplySavedParams)
132+
{
133+
for (int j = 0; j < processor->getNumberOfChannelsForElectrode(i); j++)
134+
{
135+
spikeDisplay->setThresholdForWaveAxis(i,j,thresholds[i][j]);
136+
spikeDisplay->setRangeForWaveAxis(i,j,ranges[i][j]);
137+
}
138+
}
130139
}
131140

132141
spikeDisplay->resized();
@@ -218,6 +227,10 @@ void SpikeDisplayCanvas::saveCustomParametersToXml(XmlElement* xml)
218227

219228
void SpikeDisplayCanvas::loadCustomParametersFromXml(XmlElement* xml)
220229
{
230+
231+
thresholds.clear();
232+
ranges.clear();
233+
221234
for (auto* xmlNode : xml->getChildIterator())
222235
{
223236
if (xmlNode->hasTagName("SPIKEDISPLAY"))
@@ -241,28 +254,17 @@ void SpikeDisplayCanvas::loadCustomParametersFromXml(XmlElement* xml)
241254

242255
for (auto* channelNode : plotNode->getChildIterator())
243256
{
244-
245257
if (channelNode->hasTagName("AXIS"))
246258
{
247259
channelIndex++;
248-
249-
//std::cout << "CHANNEL NUMBER " << channelIndex << std::endl;
250-
251-
spikeDisplay->setThresholdForWaveAxis(plotIndex,
252-
channelIndex,
253-
channelNode->getDoubleAttribute("thresh"));
254-
255-
spikeDisplay->setRangeForWaveAxis(plotIndex,
256-
channelIndex,
257-
channelNode->getDoubleAttribute("range"));
258-
260+
thresholds[plotIndex][channelIndex] = channelNode->getDoubleAttribute("thresh");
261+
ranges[plotIndex][channelIndex] = channelNode->getDoubleAttribute("range");
259262
}
260263
}
261-
262-
263264
}
264265
}
265-
266266
}
267267
}
268+
269+
shouldApplySavedParams = true;
268270
}

Plugins/BasicSpikeDisplay/SpikeDisplayNode/SpikeDisplayCanvas.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ class SpikeDisplayCanvas : public Visualizer,
139139
std::unique_ptr<UtilityButton> lockThresholdsButton;
140140
std::unique_ptr<UtilityButton> invertSpikesButton;
141141

142+
std::map<int, std::map<int, double>> ranges;
143+
std::map<int, std::map<int, double>> thresholds;
144+
bool shouldApplySavedParams = false;
145+
142146
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeDisplayCanvas);
143147

144148
};

0 commit comments

Comments
 (0)