Skip to content

Commit

Permalink
Merge branch 'Claybarn-development' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aacuevas committed Sep 17, 2018
2 parents 294aa10 + d1410df commit b699e61
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 15 deletions.
13 changes: 10 additions & 3 deletions Source/Plugins/SpikeSorter/SpikeSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ int SpikeSorter::getUniqueProbeID(String type)
return 1;
}

void SpikeSorter::setEditAllState(bool val){
editAll = val;
}

bool SpikeSorter::getEditAllState(){
return editAll;
}

void SpikeSorter::increaseUniqueProbeID(String type)
{
Expand Down Expand Up @@ -195,13 +202,15 @@ void SpikeSorter::updateSettings()
Array<const DataChannel*> chans;
for (int c = 0; c < nChans; c++)
{

const DataChannel* ch = getDataChannel(elec->channels[c]);
if (!ch)
{
//not enough channels for the electrodes
return;
}
chans.add(ch);

}

SpikeChannel* spk = new SpikeChannel(SpikeChannel::typeFromNumChannels(nChans), this, chans);
Expand Down Expand Up @@ -709,9 +718,9 @@ void SpikeSorter::addWaveformToSpikeObject(SpikeEvent::SpikeBuffer& s,
int spikeLength = electrodes[electrodeNumber]->prePeakSamples
+ electrodes[electrodeNumber]->postPeakSamples;


const int chan = *(electrodes[electrodeNumber]->channels + currentChannel);


if (isChannelActive(electrodeNumber, currentChannel))
{

Expand Down Expand Up @@ -1929,5 +1938,3 @@ int ContinuousCircularBuffer::GetPtr()

/************************************************************/



7 changes: 6 additions & 1 deletion Source/Plugins/SpikeSorter/SpikeSorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ class SpikeSorter : public GenericProcessor
const OwnedArray<Electrode>& getElectrodes();

std::vector<String> electrodeTypes;


void setEditAllState(bool val);
bool getEditAllState();

#if 0
/** sync PSTH : inform of a new electrode added */
void updateSinks(Electrode* newElectrode);
Expand Down Expand Up @@ -441,6 +444,8 @@ class SpikeSorter : public GenericProcessor

OwnedArray<Electrode> electrodes;
PCAcomputingThread computingThread;

bool editAll = false;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeSorter);

};
Expand Down
44 changes: 39 additions & 5 deletions Source/Plugins/SpikeSorter/SpikeSorterCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ SpikeSorterCanvas::SpikeSorterCanvas(SpikeSorter* n) :
prevElectrode->setRadius(3.0f);
prevElectrode->addListener(this);
addAndMakeVisible(prevElectrode);


editAllThresholds = new UtilityButton("Edit All Thresholds",Font("Small Text", 13, Font::plain));
editAllThresholds->addListener(this);
editAllThresholds->setBounds(140,30,60,20);
editAllThresholds->setClickingTogglesState(true);
addAndMakeVisible(editAllThresholds);
//

addAndMakeVisible(viewport);

setWantsKeyboardFocus(true);
Expand Down Expand Up @@ -159,6 +166,8 @@ void SpikeSorterCanvas::resized()

newIDbuttons->setBounds(0, 270, 120,20);
deleteAllUnits->setBounds(0, 300, 120,20);

editAllThresholds->setBounds(0, 330, 120,20);

}

Expand Down Expand Up @@ -402,7 +411,15 @@ void SpikeSorterCanvas::buttonClicked(Button* button)
electrode->spikePlot->updateUnitsFromProcessor();
processor->removeAllUnits(electrode->electrodeID);
}

else if (button == editAllThresholds){

}

// new
if (button == editAllThresholds){
processor->setEditAllState(button->getToggleState());
}

repaint();
}

Expand Down Expand Up @@ -1072,6 +1089,7 @@ void WaveformAxes::plotSpike(SorterSpikePtr s, Graphics& g)
{
if (s.get() == nullptr) return;
float h = getHeight();

g.setColour(Colour(s->color[0], s->color[1], s->color[2]));
//g.setColour(Colours::pink);
//compute the spatial width for each waveform sample
Expand All @@ -1094,13 +1112,15 @@ void WaveformAxes::plotSpike(SorterSpikePtr s, Graphics& g)

float x = 0.0f;


for (int i = 0; i < spikeSamples - 1; i++)
{
//std::cout << s.data[sampIdx] << std::endl;


float s1 = h - (h / 2 + s->getData()[offset + i] / (range)* h);
float s2 = h - (h / 2 + s->getData()[offset + i + 1] / (range)* h);

if (signalFlipped)
{
s1 = h - s1;
Expand Down Expand Up @@ -1456,7 +1476,20 @@ void WaveformAxes::mouseDrag(const MouseEvent& event)

displayThresholdLevel = (0.5f - thresholdSliderPosition) * range;
// update processor
processor->getActiveElectrode()->thresholds[channel] = displayThresholdLevel;

if (processor->getEditAllState()){
int numElectrodes = processor->getNumElectrodes();
for (int electrodeIt = 0 ; electrodeIt < numElectrodes ; electrodeIt++){
//processor->setChannelThreshold(electrodeList->getSelectedItemIndex(),i,slider->getValue());
for (int channelIt = 0 ; channelIt < processor->getNumChannels(electrodeIt) ; channelIt++){
processor->setChannelThreshold(electrodeIt,channelIt,displayThresholdLevel);
}
}
}
else{
processor->getActiveElectrode()->thresholds[channel] = displayThresholdLevel;
}

SpikeSorterEditor* edt = (SpikeSorterEditor*) processor->getEditor();
for (int k=0; k<processor->getActiveElectrode()->numChannels; k++)
edt->electrodeButtons[k]->setToggleState(false, dontSendNotification);
Expand Down Expand Up @@ -1684,7 +1717,7 @@ void WaveformAxes::paint(Graphics& g)
for (int spikeNum = 0; spikeNum < bufferSize; spikeNum++)
{

if (spikeNum != spikeIndex)
if (spikeNum != spikeIndex && spikeBuffer[spikeNum] != nullptr)
{
g.setColour(Colours::grey);
plotSpike(spikeBuffer[spikeNum], g);
Expand All @@ -1693,7 +1726,8 @@ void WaveformAxes::paint(Graphics& g)
}

g.setColour(Colours::white);
plotSpike(spikeBuffer[spikeIndex], g);
if (spikeBuffer[spikeIndex] != nullptr)
plotSpike(spikeBuffer[spikeIndex], g);

spikesReceivedSinceLastRedraw = 0;

Expand Down
12 changes: 8 additions & 4 deletions Source/Plugins/SpikeSorter/SpikeSorterCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,22 @@ class SpikeSorterCanvas : public Visualizer, public Button::Listener

SpikeSorter* processor;

// added editAllThresholds
ScopedPointer<UtilityButton> addPolygonUnitButton,
addUnitButton, delUnitButton, addBoxButton, delBoxButton, rePCAButton,nextElectrode,prevElectrode,newIDbuttons,deleteAllUnits;
addUnitButton, delUnitButton, addBoxButton, delBoxButton, rePCAButton,nextElectrode,prevElectrode,newIDbuttons,deleteAllUnits,editAllThresholds;

private:
void removeUnitOrBox();
ScopedPointer<SpikeThresholdDisplay> spikeDisplay;
ScopedPointer<Viewport> viewport;


bool inDrawingPolygonMode;
bool newSpike;
// SpikeObject spike;
Electrode* electrode;
int scrollBarThickness;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeSorterCanvas);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeSorterCanvas);

};

Expand Down Expand Up @@ -146,7 +147,7 @@ class SpikeThresholdDisplay : public Component
private:
int numColumns;
int totalHeight;

SpikeSorter* processor;
SpikeSorterCanvas* canvas;
Viewport* viewport;
Expand Down Expand Up @@ -246,6 +247,9 @@ class WaveformAxes : public GenericDrawAxes

private:
int electrodeID;
// new
bool editAll = false;
//
bool signalFlipped;
bool bDragging ;
Colour waveColour;
Expand Down
16 changes: 14 additions & 2 deletions Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ SpikeSorterEditor::SpikeSorterEditor(GenericProcessor* parentNode, bool useDefau
electrodeList->setEditableText(false);
electrodeList->setJustificationType(Justification::centredLeft);
electrodeList->addListener(this);
//electrodeList->setBounds(65,30,130,20);
electrodeList->setBounds(65,30,130,20);
addAndMakeVisible(electrodeList);

Expand Down Expand Up @@ -204,11 +205,22 @@ void SpikeSorterEditor::sliderEvent(Slider* slider)

if (electrodeNum > -1)
{
// new
SpikeSorter* processor = (SpikeSorter*) getProcessor();
if (processor->getEditAllState()){
int numElectrodes = processor->getNumElectrodes();
for (int electrodeIt = 0 ; electrodeIt < numElectrodes ; electrodeIt++){
//processor->setChannelThreshold(electrodeList->getSelectedItemIndex(),i,slider->getValue());
for (int channelIt = 0 ; channelIt < processor->getNumChannels(electrodeIt) ; channelIt++){
processor->setChannelThreshold(electrodeIt,channelIt,slider->getValue());
}
}
}
else{
processor->setChannelThreshold(electrodeList->getSelectedItemIndex(),
electrodeNum,
slider->getValue());

}


/* //Array<int> dacChannels = processor->getDACassignments;
Expand All @@ -231,7 +243,7 @@ void SpikeSorterEditor::buttonEvent(Button* button)
{

SpikeSorter* processor = (SpikeSorter*) getProcessor();

if (electrodeButtons.contains((ElectrodeButton*) button))
{

Expand Down
1 change: 1 addition & 0 deletions Source/Plugins/SpikeSorter/SpikeSorterEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SpikeSorterEditor : public VisualizerEditor,

private:
void drawElectrodeButtons(int);




Expand Down

0 comments on commit b699e61

Please sign in to comment.