Skip to content

Commit

Permalink
Allow block-based updating of activity view
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Jul 5, 2024
1 parent 48df0c5 commit 0ecf00c
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Source/Basestations/SimulatedBasestation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SimulatedBasestationConfigWindow::SimulatedBasestationConfigWindow (SimulatedBas
comboBox->setBounds (65, 50 + 35 * i, 200, 20);
}

acceptButton = std::make_unique<UtilityButton> ("LAUNCH", Font ("Small Text", 13, Font::plain));
acceptButton = std::make_unique<UtilityButton> ("LAUNCH", FontOptions ("Small Text", 13, Font::plain));
acceptButton->setBounds (120, 200, 80, 20);
acceptButton->addListener (this);
addAndMakeVisible (acceptButton.get());
Expand Down
6 changes: 2 additions & 4 deletions Source/NeuropixEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void EditorBackground::paint (Graphics& g)
g.setFont (10);
g.drawText ("SLOT", 90 * i + 72, 15, 50, 12, Justification::centredLeft);

//g.setFont(26);
//g.drawText(String(basestations[i]->slot), 90 * i + 72, 28, 25, 26, Justification::centredLeft);
g.setFont (8);
g.drawText (String ("0"), 90 * i + 87, 100, 50, 10, Justification::centredLeft);
g.drawText (String ("100"), 90 * i + 87, 60, 50, 10, Justification::centredLeft);
Expand Down Expand Up @@ -444,7 +442,7 @@ NeuropixEditor::NeuropixEditor (GenericProcessor* parentNode, NeuropixThread* t)
int x_pos = i * 90 + 70;
int y_pos = 50;

UtilityButton* b = new UtilityButton ("", Font ("Small Text", 13, Font::plain));
UtilityButton* b = new UtilityButton ("", FontOptions ("Small Text", 13, Font::plain));
b->setBounds (x_pos, y_pos, 30, 20);
b->addListener (this);
//addAndMakeVisible(b);
Expand Down Expand Up @@ -501,7 +499,7 @@ NeuropixEditor::NeuropixEditor (GenericProcessor* parentNode, NeuropixThread* t)
background->toBack();
background->repaint();

addSyncChannelButton = std::make_unique<UtilityButton> ("+", Font ("Small Text", 13, Font::plain));
addSyncChannelButton = std::make_unique<UtilityButton> ("+", FontOptions ("Small Text", 13, Font::plain));
addSyncChannelButton->setBounds (90 * basestations.size() + 78, 40, 20, 20);
addSyncChannelButton->addListener (this);
addSyncChannelButton->setTooltip ("Add sync channel to the continuous data stream.");
Expand Down
22 changes: 19 additions & 3 deletions Source/Probes/Neuropixels_QuadBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,20 @@ bool Neuropixels_QuadBase::open()
lfp_timestamp = 0;
eventCode = 0;

apView = new ActivityView (384 * 4, 3000);
Array<Array<int>> blocks;

for (int shank = 0; shank < 4; shank++)
{

blocks.add (Array<int>());

for (int i = 0; i < 384; i++)
{
blocks.getReference(shank).add (i + 384 * shank);
}
}

apView = new ActivityView (384 * 4, 3000, blocks);

return errorCode == Neuropixels::SUCCESS;
}
Expand Down Expand Up @@ -325,12 +338,15 @@ void Neuropixels_QuadBase::writeConfiguration()
void Neuropixels_QuadBase::startAcquisition()
{

apView->reset();


if (acquisitionThreads.size() == 0)
{
for (int shank = 0; shank < 4; shank++)
{

apView->reset(shank);

quadBaseBuffers[shank]->clear();

acquisitionThreads.add (
Expand Down Expand Up @@ -454,7 +470,7 @@ void AcquisitionThread::run()
apSamples[packetNum + count * j] =
float (data[packetNum * shank_channel_count + j]) / 4096.0f / 100.0f * 1000000.0f; // convert to microvolts

apView->addSample (apSamples[packetNum + count * j], j + shank * 384);
apView->addSample (apSamples[packetNum + count * j], j + shank * 384, shank);
}

if (sendSync)
Expand Down
62 changes: 44 additions & 18 deletions Source/UI/ActivityView.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,55 @@ Helper class for viewing real-time activity across the probe.
class ActivityView
{
public:
ActivityView (int numChannels, int updateInterval_)
ActivityView (int numChannels, int updateInterval_, Array<Array<int>> blocks_ = Array<Array<int>>())
{
for (int i = 0; i < numChannels; i++)
peakToPeakValues.add (0);

if (blocks_.size() == 0)
{
Array<int> block;

for (int i = 0; i < numChannels; i++)
{
block.add (i);
}
blocks.add (block);
}
else
{
blocks = blocks_;
}

updateInterval = updateInterval_;

reset();
for (int i = 0; i < numChannels; i++)
{
minChannelValues.add (999999.9f);
maxChannelValues.add (-999999.9f);
peakToPeakValues.add (0);
}

for (int i = 0; i < blocks.size(); i++)
{
counters.add (0);
}
}

const float* getPeakToPeakValues()
{
return peakToPeakValues.getRawDataPointer();
}

void addSample (float sample, int channel)
void addSample (float sample, int channel, int block=0)
{
if (channel == 0)
if (channel == blocks[block][0])
{
if (counter == updateInterval)
reset();
if (counters[block] == updateInterval)
reset(block);

counter++;
counters.set (block, counters[block] + 1);
}

if (counter % 10 == 0)
if (counters[block] % 10 == 0)
{
if (sample < minChannelValues[channel])
{
Expand All @@ -81,25 +104,28 @@ class ActivityView
}
}

void reset()
void reset(int blockIndex = 0)
{
for (int i = 0; i < peakToPeakValues.size(); i++)
{
peakToPeakValues.set (i, maxChannelValues[i] - minChannelValues[i]);

minChannelValues.set (i, 999999.9f);
maxChannelValues.set (i, -999999.9f);
for (auto ch : blocks[blockIndex])
{
peakToPeakValues.set (ch, maxChannelValues[ch] - minChannelValues[ch]);
minChannelValues.set (ch, 999999.9f);
maxChannelValues.set (ch, -999999.9f);
}

counter = 0;
counters.set (blockIndex, 0);


}

private:
Array<float, CriticalSection> minChannelValues;
Array<float, CriticalSection> maxChannelValues;
Array<float, CriticalSection> peakToPeakValues;

int counter;
Array<Array<int>> blocks;
Array<int> counters;
int updateInterval;
};

Expand Down
4 changes: 2 additions & 2 deletions Source/UI/NeuropixInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ bool NeuropixInterface::applyProbeSettings (ProbeSettings p, bool shouldUpdatePr

probe->settings.clearElectrodeSelection();

for (auto electrode : electrodeMetadata)
for (auto const electrode : electrodeMetadata)
{
if (electrode.status == ElectrodeStatus::CONNECTED)
{
Expand Down Expand Up @@ -1563,7 +1563,7 @@ ProbeSettings NeuropixInterface::getProbeSettings()

if (p.probeType != ProbeType::UHD2)
{
for (auto electrode : electrodeMetadata)
for (auto const electrode : electrodeMetadata)
{
if (electrode.status == ElectrodeStatus::CONNECTED)
{
Expand Down
8 changes: 4 additions & 4 deletions Source/UI/WavePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,25 @@ WavePlayer::WavePlayer (OneBoxDAC* dac_)
patternSelector->setEditableText (true);
addAndMakeVisible (patternSelector);

startStopButton = new UtilityButton ("RUN", Font ("Small Text", 15, Font::plain));
startStopButton = new UtilityButton ("RUN", FontOptions ("Small Text", 15, Font::plain));
startStopButton->setBounds (30, 85, 55, 30);
startStopButton->addListener (this);
addAndMakeVisible (startStopButton);

pulsePatternButton = new UtilityButton ("Pulse", Font ("Small Text", 10, Font::plain));
pulsePatternButton = new UtilityButton ("Pulse", FontOptions ("Small Text", 10, Font::plain));
pulsePatternButton->setCorners (true, false, true, false);
pulsePatternButton->setBounds (140, 40, 50, 20);
pulsePatternButton->addListener (this);
pulsePatternButton->setToggleState (true, false);
addAndMakeVisible (pulsePatternButton);

sinePatternButton = new UtilityButton ("Sine", Font ("Small Text", 10, Font::plain));
sinePatternButton = new UtilityButton ("Sine", FontOptions ("Small Text", 10, Font::plain));
sinePatternButton->setCorners (false, false, false, false);
sinePatternButton->setBounds (190, 40, 50, 20);
sinePatternButton->addListener (this);
addAndMakeVisible (sinePatternButton);

customPatternButton = new UtilityButton ("Custom", Font ("Small Text", 10, Font::plain));
customPatternButton = new UtilityButton ("Custom", FontOptions ("Small Text", 10, Font::plain));
customPatternButton->setCorners (false, true, false, true);
customPatternButton->setBounds (240, 40, 60, 20);
customPatternButton->addListener (this);
Expand Down

0 comments on commit 0ecf00c

Please sign in to comment.