Skip to content

Commit 31f7c38

Browse files
committed
Show continuous channel name in spike plots
1 parent 2668810 commit 31f7c38

7 files changed

Lines changed: 125 additions & 46 deletions

File tree

Plugins/SpikeViewer/SpikeDisplay.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ void SpikeDisplay::clear()
6363

6464
}
6565

66-
SpikePlot* SpikeDisplay::addSpikePlot (int numChannels, int electrodeNum, String name_, std::string identifier_)
66+
SpikePlot* SpikeDisplay::addSpikePlot (int numChannels, int electrodeNum, String name_, Array<String> channelNames, std::string identifier_)
6767
{
6868
LOGD ("Adding spike plot for electrode: ", electrodeNum, " named: ", name_, " with ", numChannels, " channels");
6969

70-
SpikePlot* spikePlot = new SpikePlot (canvas, electrodeNum, 1000 + numChannels, name_, identifier_);
70+
SpikePlot* spikePlot = new SpikePlot (canvas, electrodeNum, 1000 + numChannels, name_, channelNames, identifier_);
7171

7272
if (numChannels == 1)
7373
singleElectrodePlots.add (spikePlot);
@@ -320,4 +320,4 @@ void SpikeDisplay::setMonitorStateForPlot (int plotNum, bool state)
320320
{
321321
if (spikePlots.size() > plotNum)
322322
spikePlots[plotNum]->setMonitorState (state);
323-
}
323+
}

Plugins/SpikeViewer/SpikeDisplay.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class SpikeDisplay : public Component
5151
/** Clears spike plots*/
5252
void clear();
5353

54-
/** Adds a spike plot with 1, 2, or 3 channels*/
55-
SpikePlot* addSpikePlot (int numChannels, int electrodeNum, String name, std::string identifier);
54+
/** Adds a spike plot with 1, 2, or 4 channels*/
55+
SpikePlot* addSpikePlot (int numChannels, int electrodeNum, String name, Array<String> channelNames, std::string identifier);
5656

5757
/** Returns a spike plot based on index*/
5858
SpikePlot* getSpikePlot (int numChannels, int index);

Plugins/SpikeViewer/SpikeDisplayCanvas.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ void SpikeDisplayCanvas::updateSettings()
158158

159159
for (int i = 0; i < nPlots; i++)
160160
{
161-
SpikePlot* sp = spikeDisplay->addSpikePlot (processor->getNumberOfChannelsForElectrode (i), i, processor->getNameForElectrode (i), processor->getSpikeChannel (i)->getIdentifier().toStdString());
161+
SpikePlot* sp = spikeDisplay->addSpikePlot (processor->getNumberOfChannelsForElectrode (i),
162+
i,
163+
processor->getNameForElectrode (i),
164+
processor->getChannelNamesForElectrode(i),
165+
processor->getSpikeChannel (i)->getIdentifier().toStdString());
162166

163167
processor->addSpikePlotForElectrode (sp, i);
164168

Plugins/SpikeViewer/SpikeDisplayNode.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ int SpikeDisplayNode::getNumberOfChannelsForElectrode (int i) const
129129
}
130130
}
131131

132+
Array<String> SpikeDisplayNode::getChannelNamesForElectrode (int i) const
133+
{
134+
135+
Array<String> channelNames;
136+
137+
if (i > -1 && i < electrodes.size())
138+
{
139+
for (int j = 0; j < electrodes[i]->numChannels; j++)
140+
{
141+
channelNames.add(electrodes[i]->spikeChannel->getSourceChannels()[j]->getName());
142+
}
143+
}
144+
145+
return channelNames;
146+
147+
}
148+
132149
String SpikeDisplayNode::getNameForElectrode (int i) const
133150
{
134151
if (i > -1 && i < electrodes.size())

Plugins/SpikeViewer/SpikeDisplayNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class SpikeDisplayNode : public GenericProcessor
6969

7070
/** Returns the channel count for an electrode*/
7171
int getNumberOfChannelsForElectrode (int i) const;
72+
73+
/** Returns channel names for an electrode*/
74+
Array<String> getChannelNamesForElectrode (int i) const;
7275

7376
/** Returns the total number of available electrodes*/
7477
int getNumElectrodes() const;

Plugins/SpikeViewer/SpikePlots.cpp

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ SpikePlot::SpikePlot (SpikeDisplayCanvas* sdc,
3131
int elecNum,
3232
int p,
3333
String name_,
34-
std::string identifier_) : canvas (sdc),
35-
electrodeNumber (elecNum),
36-
plotType (p),
37-
limitsChanged (true),
38-
name (name_),
39-
identifier (identifier_)
34+
Array<String> continuousChannelNames_,
35+
std::string identifier_) :
36+
canvas (sdc),
37+
electrodeNumber (elecNum),
38+
plotType (p),
39+
limitsChanged (true),
40+
name (name_),
41+
continuousChannelNames(continuousChannelNames_),
42+
identifier (identifier_)
4043
{
4144
font = FontOptions ("Inter", "Medium", 16.0f);
4245

@@ -172,7 +175,7 @@ void SpikePlot::initAxes()
172175

173176
for (int i = 0; i < nWaveAx; i++)
174177
{
175-
WaveAxes* wAx = new WaveAxes (canvas, electrodeNumber, WAVE1 + i, identifier);
178+
WaveAxes* wAx = new WaveAxes (canvas, electrodeNumber, WAVE1 + i, continuousChannelNames[i], identifier);
176179
waveAxes.add (wAx);
177180
addAndMakeVisible (wAx);
178181
ranges.add (250.0f); // default range is 250 microvolts
@@ -181,7 +184,21 @@ void SpikePlot::initAxes()
181184
for (int i = 0; i < nProjAx; i++)
182185
{
183186
Projection proj = Projection (int (PROJ1x2) + i);
184-
ProjectionAxes* pAx = new ProjectionAxes (canvas, proj);
187+
String channelComparison;
188+
if (i == 0)
189+
channelComparison = continuousChannelNames[0] + " vs " + continuousChannelNames[1];
190+
else if (i == 1)
191+
channelComparison = continuousChannelNames[0] + " vs " + continuousChannelNames[2];
192+
else if (i == 2)
193+
channelComparison = continuousChannelNames[0] + " vs " + continuousChannelNames[3];
194+
else if (i == 3)
195+
channelComparison = continuousChannelNames[1] + " vs " + continuousChannelNames[2];
196+
else if (i == 4)
197+
channelComparison = continuousChannelNames[1] + " vs " + continuousChannelNames[3];
198+
else if (i == 5)
199+
channelComparison = continuousChannelNames[2] + " vs " + continuousChannelNames[3];
200+
201+
ProjectionAxes* pAx = new ProjectionAxes (canvas, proj, channelComparison);
185202
projectionAxes.add (pAx);
186203
addAndMakeVisible (pAx);
187204
}
@@ -458,9 +475,13 @@ void SpikePlot::invertSpikes (bool shouldInvert)
458475
}
459476
}
460477

461-
GenericAxes::GenericAxes (SpikeDisplayCanvas* canvas, SpikePlotType type_) : canvas (canvas),
462-
type (type_),
463-
gotFirstSpike (false)
478+
GenericAxes::GenericAxes (SpikeDisplayCanvas* canvas,
479+
SpikePlotType type_,
480+
String channelName_) :
481+
canvas (canvas),
482+
type (type_),
483+
channelName(channelName_),
484+
gotFirstSpike (false)
464485
{
465486
ylims[0] = 0;
466487
ylims[1] = 1;
@@ -548,21 +569,26 @@ double GenericAxes::ad16ToUv (int x, int gain)
548569
return result;
549570
}
550571

551-
WaveAxes::WaveAxes (SpikeDisplayCanvas* canvas, int electrodeIndex, int channel_, std::string identifier_) : GenericAxes (canvas, WAVE_AXES),
552-
electrodeIndex (electrodeIndex),
553-
drawGrid (true),
554-
displayThresholdLevel (0.0f),
555-
detectorThresholdLevel (0.0f),
556-
spikesReceivedSinceLastRedraw (0),
557-
spikeIndex (0),
558-
bufferSize (5),
559-
range (250.0f),
560-
isOverThresholdSlider (false),
561-
isDraggingThresholdSlider (false),
562-
thresholdCoordinator (nullptr),
563-
spikesInverted (false),
564-
channel (channel_),
565-
identifier (identifier_)
572+
WaveAxes::WaveAxes (SpikeDisplayCanvas* canvas,
573+
int electrodeIndex,
574+
int channel_,
575+
String channelName,
576+
std::string identifier_) :
577+
GenericAxes (canvas, WAVE_AXES, channelName),
578+
electrodeIndex (electrodeIndex),
579+
drawGrid (true),
580+
displayThresholdLevel (0.0f),
581+
detectorThresholdLevel (0.0f),
582+
spikesReceivedSinceLastRedraw (0),
583+
spikeIndex (0),
584+
bufferSize (5),
585+
range (250.0f),
586+
isOverThresholdSlider (false),
587+
isDraggingThresholdSlider (false),
588+
thresholdCoordinator (nullptr),
589+
spikesInverted (false),
590+
channel (channel_),
591+
identifier (identifier_)
566592
{
567593
addMouseListener (this, true);
568594

@@ -601,6 +627,11 @@ void WaveAxes::paint (Graphics& g)
601627

602628
// draw the threshold line and labels
603629
drawThresholdSlider (g);
630+
631+
// draw underlying channel name
632+
g.setColour(Colours::white.withAlpha(0.5f));
633+
g.setFont(13);
634+
g.drawText(channelName, getWidth()-44, 5, 40, 13, Justification::right);
604635

605636
// if no spikes have been received then don't plot anything
606637
if (! gotFirstSpike)
@@ -612,16 +643,17 @@ void WaveAxes::paint (Graphics& g)
612643
{
613644
if (spikeNum != spikeIndex)
614645
{
615-
plotSpike (spikeBuffer[spikeNum], g);
646+
plotSpike (spikeBuffer[spikeNum], g, false);
616647
}
617648
}
618649

619650
plotSpike (spikeBuffer[spikeIndex], g);
620651

621652
spikesReceivedSinceLastRedraw = 0;
653+
622654
}
623655

624-
void WaveAxes::plotSpike (const Spike* s, Graphics& g)
656+
void WaveAxes::plotSpike (const Spike* s, Graphics& g, bool latestSpike)
625657
{
626658
if (! s)
627659
return;
@@ -640,7 +672,13 @@ void WaveAxes::plotSpike (const Spike* s, Graphics& g)
640672
if (s->getSortedId() > 0)
641673
g.setColour (colours[(s->getSortedId() - 1) % 8]);
642674
else
643-
g.setColour (Colours::white);
675+
{
676+
if (latestSpike)
677+
g.setColour (Colours::white);
678+
else
679+
g.setColour(Colours::white.withAlpha(0.4f));
680+
}
681+
644682

645683
// type corresponds to channel so we need to calculate the starting
646684
// sample based upon which channel is getting plotted
@@ -914,12 +952,15 @@ void WaveAxes::setDisplayThreshold (float threshold)
914952

915953
// --------------------------------------------------
916954

917-
ProjectionAxes::ProjectionAxes (SpikeDisplayCanvas* canvas, Projection proj_) : GenericAxes (canvas, PROJECTION_AXES),
918-
imageDim (500),
919-
rangeX (250),
920-
rangeY (250),
921-
spikesReceivedSinceLastRedraw (0),
922-
proj (proj_)
955+
ProjectionAxes::ProjectionAxes (SpikeDisplayCanvas* canvas,
956+
Projection proj_,
957+
String channelNames) :
958+
GenericAxes (canvas, PROJECTION_AXES, channelNames),
959+
imageDim (500),
960+
rangeX (250),
961+
rangeY (250),
962+
spikesReceivedSinceLastRedraw (0),
963+
proj (proj_)
923964
{
924965
projectionImage = Image (Image::RGB, imageDim, imageDim, true, SoftwareImageType());
925966

@@ -947,6 +988,10 @@ void ProjectionAxes::paint (Graphics& g)
947988
imageDim - rangeY,
948989
rangeX,
949990
rangeY);
991+
992+
g.setColour(Colours::white.withAlpha(0.3f));
993+
g.setFont(13);
994+
g.drawText(channelName, 4, 5, 100, 13, Justification::left);
950995
}
951996

952997
bool ProjectionAxes::updateSpikeData (const Spike* s)
@@ -1095,4 +1140,4 @@ void MonitorButton::paintButton (Graphics& g, bool isMouseOverButton, bool isBut
10951140
headphoneIcon->drawWithin (g, getLocalBounds().toFloat(), RectanglePlacement::centred, 1.0f);
10961141

10971142
headphoneIcon->replaceColour (buttonColour, Colours::black);
1098-
}
1143+
}

Plugins/SpikeViewer/SpikePlots.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class SpikePlot : public Component,
100100
int elecNum,
101101
int plotType,
102102
String name_,
103+
Array<String> continuousChannelNames,
103104
std::string identifier_);
104105

105106
/** Destructor */
@@ -208,6 +209,7 @@ class SpikePlot : public Component,
208209
void updateAxesPositions();
209210

210211
String name;
212+
Array<String> continuousChannelNames;
211213
FontOptions font;
212214

213215
CriticalSection spikeArrayLock;
@@ -227,7 +229,7 @@ class GenericAxes : public Component
227229
{
228230
public:
229231
/** Constructor */
230-
GenericAxes (SpikeDisplayCanvas* canvas, SpikePlotType type);
232+
GenericAxes (SpikeDisplayCanvas* canvas, SpikePlotType type, String channelName);
231233

232234
/** Destructor */
233235
virtual ~GenericAxes() {}
@@ -260,6 +262,8 @@ class GenericAxes : public Component
260262
FontOptions font;
261263

262264
Array<Colour> colours;
265+
266+
String channelName;
263267

264268
double ad16ToUv (int x, int gain);
265269
};
@@ -274,7 +278,11 @@ class WaveAxes : public GenericAxes
274278
{
275279
public:
276280
/** Constructor*/
277-
WaveAxes (SpikeDisplayCanvas* canvas, int electrodeIndex, int channel, std::string identifier);
281+
WaveAxes (SpikeDisplayCanvas* canvas,
282+
int electrodeIndex,
283+
int channel,
284+
String channelName,
285+
std::string identifier);
278286

279287
/** Destructor*/
280288
~WaveAxes() {}
@@ -289,7 +297,7 @@ class WaveAxes : public GenericAxes
289297
void paint (Graphics& g);
290298

291299
/** Draws a single spike */
292-
void plotSpike (const Spike* s, Graphics& g);
300+
void plotSpike (const Spike* s, Graphics& g, bool latestSpike = true);
293301

294302
/** Removes spikes that have been previously drawn*/
295303
void clear();
@@ -370,7 +378,9 @@ class ProjectionAxes : public GenericAxes
370378
{
371379
public:
372380
/** Constructor */
373-
ProjectionAxes (SpikeDisplayCanvas* canvas, Projection proj);
381+
ProjectionAxes (SpikeDisplayCanvas* canvas,
382+
Projection proj,
383+
String channelName);
374384

375385
/** Destructor*/
376386
~ProjectionAxes() {}

0 commit comments

Comments
 (0)