Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yehaojie
plugin-GUI
Commits
97d5a603
Commit
97d5a603
authored
10 years ago
by
jsiegle
Browse files
Options
Downloads
Patches
Plain Diff
Allow spikes to be inverted in the Spike Display
parent
fa4b2a30
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Processors/Visualization/SpikeDisplayCanvas.cpp
+103
-14
103 additions, 14 deletions
Source/Processors/Visualization/SpikeDisplayCanvas.cpp
Source/Processors/Visualization/SpikeDisplayCanvas.h
+18
-0
18 additions, 0 deletions
Source/Processors/Visualization/SpikeDisplayCanvas.h
with
121 additions
and
14 deletions
Source/Processors/Visualization/SpikeDisplayCanvas.cpp
+
103
−
14
View file @
97d5a603
...
...
@@ -49,6 +49,13 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) :
lockThresholdsButton
->
setClickingTogglesState
(
true
);
addAndMakeVisible
(
lockThresholdsButton
);
invertSpikesButton
=
new
UtilityButton
(
"Invert Spikes"
,
Font
(
"Small Text"
,
13
,
Font
::
plain
));
invertSpikesButton
->
setRadius
(
3.0
f
);
invertSpikesButton
->
addListener
(
this
);
invertSpikesButton
->
setClickingTogglesState
(
true
);
invertSpikesButton
->
setToggleState
(
false
,
true
);
addAndMakeVisible
(
invertSpikesButton
);
addAndMakeVisible
(
viewport
);
setWantsKeyboardFocus
(
true
);
...
...
@@ -113,6 +120,8 @@ void SpikeDisplayCanvas::resized()
lockThresholdsButton
->
setBounds
(
130
,
getHeight
()
-
40
,
130
,
20
);
invertSpikesButton
->
setBounds
(
270
,
getHeight
()
-
40
,
130
,
20
);
}
void
SpikeDisplayCanvas
::
paint
(
Graphics
&
g
)
...
...
@@ -164,15 +173,40 @@ void SpikeDisplayCanvas::buttonClicked(Button* button)
else
if
(
button
==
lockThresholdsButton
)
{
thresholdCoordinator
->
setLockThresholds
(
button
->
getToggleState
());
}
}
else
if
(
button
==
invertSpikesButton
)
{
spikeDisplay
->
invertSpikes
(
button
->
getToggleState
());
}
}
void
SpikeDisplayCanvas
::
saveVisualizerParameters
(
XmlElement
*
xml
)
{
XmlElement
*
xmlNode
=
xml
->
createNewChildElement
(
"SPIKEDISPLAY"
);
xmlNode
->
setAttribute
(
"LockThresholds"
,
lockThresholdsButton
->
getToggleState
());
xmlNode
->
setAttribute
(
"InvertSpikes"
,
invertSpikesButton
->
getToggleState
());
}
void
SpikeDisplayCanvas
::
loadVisualizerParameters
(
XmlElement
*
xml
)
{
forEachXmlChildElement
(
*
xml
,
xmlNode
)
{
if
(
xmlNode
->
hasTagName
(
"SPIKEDISPLAY"
))
{
spikeDisplay
->
invertSpikes
(
xmlNode
->
getBoolAttribute
(
"InvertSpikes"
));
invertSpikesButton
->
setToggleState
(
xmlNode
->
getBoolAttribute
(
"InvertSpikes"
),
false
);
lockThresholdsButton
->
setToggleState
(
xmlNode
->
getBoolAttribute
(
"LockThresholds"
),
true
);
}
}
}
// ----------------------------------------------------------------
SpikeDisplay
::
SpikeDisplay
(
SpikeDisplayCanvas
*
sdc
,
Viewport
*
v
)
:
canvas
(
sdc
),
viewport
(
v
),
thresholdCoordinator
(
nullptr
)
canvas
(
sdc
),
viewport
(
v
),
thresholdCoordinator
(
nullptr
)
,
shouldInvert
(
false
)
{
totalHeight
=
1000
;
...
...
@@ -211,6 +245,7 @@ SpikePlot* SpikeDisplay::addSpikePlot(int numChannels, int electrodeNum, String
SpikePlot
*
spikePlot
=
new
SpikePlot
(
canvas
,
electrodeNum
,
1000
+
numChannels
,
name_
);
spikePlots
.
add
(
spikePlot
);
addAndMakeVisible
(
spikePlot
);
spikePlot
->
invertSpikes
(
shouldInvert
);
if
(
thresholdCoordinator
)
{
spikePlot
->
registerThresholdCoordinator
(
thresholdCoordinator
);
...
...
@@ -335,6 +370,19 @@ void SpikeDisplay::mouseDown(const MouseEvent& event)
}
void
SpikeDisplay
::
invertSpikes
(
bool
shouldInvert_
)
{
for
(
int
i
=
0
;
i
<
spikePlots
.
size
();
i
++
)
{
spikePlots
[
i
]
->
invertSpikes
(
shouldInvert
);
}
//std::cout << "Invert spikes? " << shouldInvert_ << std::endl;
shouldInvert
=
shouldInvert_
;
}
void
SpikeDisplay
::
plotSpike
(
const
SpikeObject
&
spike
,
int
electrodeNum
)
{
spikePlots
[
electrodeNum
]
->
processSpikeObject
(
spike
);
...
...
@@ -684,6 +732,14 @@ void SpikePlot::setAllThresholds(float displayThreshold, float range)
setLimitsOnAxes
();
}
void
SpikePlot
::
invertSpikes
(
bool
shouldInvert
)
{
for
(
int
i
=
0
;
i
<
nWaveAx
;
i
++
)
{
wAxes
[
i
]
->
invertSpikes
(
shouldInvert
);
}
}
// --------------------------------------------------
...
...
@@ -697,7 +753,8 @@ WaveAxes::WaveAxes(int channel) : GenericAxes(channel),
range
(
250.0
f
),
isOverThresholdSlider
(
false
),
isDraggingThresholdSlider
(
false
),
thresholdCoordinator
(
nullptr
)
thresholdCoordinator
(
nullptr
),
spikesInverted
(
false
)
{
...
...
@@ -790,9 +847,18 @@ void WaveAxes::plotSpike(const SpikeObject& s, Graphics& g)
if
(
*
s
.
gain
!=
0
)
{
float
s1
=
h
/
2
+
float
(
s
.
data
[
sampIdx
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
float
s
2
=
h
/
2
+
float
(
s
.
data
[
sampIdx
+
1
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
float
s
1
,
s2
;
if
(
!
spikesInverted
)
{
s1
=
h
/
2
+
float
(
s
.
data
[
sampIdx
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
s2
=
h
/
2
+
float
(
s
.
data
[
sampIdx
+
1
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
}
else
{
s1
=
h
/
2
-
float
(
s
.
data
[
sampIdx
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
s2
=
h
/
2
-
float
(
s
.
data
[
sampIdx
+
1
]
-
32768
)
/
float
(
*
s
.
gain
)
*
1000.0
f
/
range
*
h
;
}
g
.
drawLine
(
x
,
s1
,
x
+
dx
,
...
...
@@ -811,14 +877,23 @@ void WaveAxes::drawThresholdSlider(Graphics& g)
{
// draw display threshold (editable)
float
h
=
getHeight
()
*
(
0.5
f
-
displayThresholdLevel
/
range
);
float
h
;
if
(
!
spikesInverted
)
h
=
getHeight
()
*
(
0.5
f
-
displayThresholdLevel
/
range
);
else
h
=
getHeight
()
*
(
0.5
f
+
displayThresholdLevel
/
range
);
g
.
setColour
(
thresholdColour
);
g
.
drawLine
(
0
,
h
,
getWidth
(),
h
);
g
.
drawText
(
String
(
roundFloatToInt
(
displayThresholdLevel
)),
2
,
h
,
25
,
10
,
Justification
::
left
,
false
);
// draw detector threshold (not editable)
h
=
getHeight
()
*
(
0.5
f
-
detectorThresholdLevel
/
range
);
if
(
!
spikesInverted
)
h
=
getHeight
()
*
(
0.5
f
-
detectorThresholdLevel
/
range
);
else
h
=
getHeight
()
*
(
0.5
f
+
detectorThresholdLevel
/
range
);
g
.
setColour
(
Colours
::
orange
);
g
.
drawLine
(
0
,
h
,
getWidth
(),
h
);
...
...
@@ -912,6 +987,11 @@ void WaveAxes::mouseMove(const MouseEvent& event)
float
h
=
getHeight
()
*
(
0.5
f
-
displayThresholdLevel
/
range
);
if
(
!
spikesInverted
)
h
=
getHeight
()
*
(
0.5
f
-
displayThresholdLevel
/
range
);
else
h
=
getHeight
()
*
(
0.5
f
+
displayThresholdLevel
/
range
);
// std::cout << y << " " << h << std::endl;
if
(
y
>
h
-
10.0
f
&&
y
<
h
+
10.0
f
&&
!
isOverThresholdSlider
)
...
...
@@ -957,13 +1037,22 @@ void WaveAxes::mouseDrag(const MouseEvent& event)
float
thresholdSliderPosition
=
float
(
event
.
y
)
/
float
(
getHeight
());
if
(
thresholdSliderPosition
>
0.5
f
)
thresholdSliderPosition
=
0.5
f
;
else
if
(
thresholdSliderPosition
<
0.0
f
)
thresholdSliderPosition
=
0.0
f
;
displayThresholdLevel
=
(
0.5
f
-
thresholdSliderPosition
)
*
range
;
if
(
!
spikesInverted
)
{
if
(
thresholdSliderPosition
>
0.5
f
)
thresholdSliderPosition
=
0.5
f
;
else
if
(
thresholdSliderPosition
<
0.0
f
)
thresholdSliderPosition
=
0.0
f
;
displayThresholdLevel
=
(
0.5
f
-
thresholdSliderPosition
)
*
range
;
}
else
{
if
(
thresholdSliderPosition
<
0.5
f
)
thresholdSliderPosition
=
0.5
f
;
else
if
(
thresholdSliderPosition
>
1.0
f
)
thresholdSliderPosition
=
1.0
f
;
displayThresholdLevel
=
(
thresholdSliderPosition
-
0.5
f
)
*
range
;
}
//std::cout << "Threshold = " << thresholdLevel << std::endl;
...
...
This diff is collapsed.
Click to expand it.
Source/Processors/Visualization/SpikeDisplayCanvas.h
+
18
−
0
View file @
97d5a603
...
...
@@ -102,6 +102,10 @@ public:
SpikeDisplayNode
*
processor
;
void
saveVisualizerParameters
(
XmlElement
*
xml
);
void
loadVisualizerParameters
(
XmlElement
*
xml
);
private
:
ScopedPointer
<
SpikeDisplay
>
spikeDisplay
;
...
...
@@ -116,6 +120,7 @@ private:
ScopedPointer
<
SpikeThresholdCoordinator
>
thresholdCoordinator
;
ScopedPointer
<
UtilityButton
>
lockThresholdsButton
;
ScopedPointer
<
UtilityButton
>
invertSpikesButton
;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
(
SpikeDisplayCanvas
);
...
...
@@ -139,6 +144,8 @@ public:
void
plotSpike
(
const
SpikeObject
&
spike
,
int
electrodeNum
);
void
invertSpikes
(
bool
);
int
getTotalHeight
()
{
return
totalHeight
;
...
...
@@ -161,6 +168,8 @@ private:
OwnedArray
<
SpikePlot
>
spikePlots
;
bool
shouldInvert
;
// float tetrodePlotMinWidth, stereotrodePlotMinWidth, singleElectrodePlotMinWidth;
// float tetrodePlotRatio, stereotrodePlotRatio, singleElectrodePlotRatio;
...
...
@@ -203,6 +212,8 @@ public:
void
clear
();
void
invertSpikes
(
bool
);
float
minWidth
;
float
aspectRatio
;
...
...
@@ -331,6 +342,11 @@ public:
void
registerThresholdCoordinator
(
SpikeThresholdCoordinator
*
stc
);
void
setDisplaythreshold
(
float
threshold
);
void
invertSpikes
(
bool
shouldInvert
)
{
spikesInverted
=
shouldInvert
;
}
private
:
Colour
waveColour
;
...
...
@@ -363,6 +379,8 @@ private:
MouseCursor
::
StandardCursorType
cursorType
;
SpikeThresholdCoordinator
*
thresholdCoordinator
;
bool
spikesInverted
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment