Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/open-ephys/plugin-GUI
Browse files Browse the repository at this point in the history
…into development
  • Loading branch information
jsiegle committed Nov 2, 2024
2 parents 8acce56 + 3756bfa commit c0754eb
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void SpikeDisplayNode::setParameter(int param, float val)

for (auto ch : chan->localChannelIndexes)
{
msg += String(ch) + " ";
msg += String(ch + 1) + " ";
}

//std::cout << "MESSAGE: " << msg << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions Plugins/LfpDisplayNode/LfpChannelDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void LfpChannelDisplay::pxPaint()
double a = (canvasSplit->getYCoordMax(chan, index)/range*channelHeightFloat);
double b = (canvasSplit->getYCoordMin(chan, index)/range*channelHeightFloat);

double mean = (canvasSplit->getMean(chan)/range*channelHeightFloat);
double mean = (canvasSplit->getScreenBufferMean(chan)/range*channelHeightFloat);

if (drawWithOffsetCorrection)
{
Expand Down Expand Up @@ -508,7 +508,7 @@ void LfpChannelDisplay::pxPaintHistory(int playhead, int rightEdge, int maxScree
double a = (canvasSplit->getYCoordMax(chan, index) / range * channelHeightFloat);
double b = (canvasSplit->getYCoordMin(chan, index) / range * channelHeightFloat);

double mean = (canvasSplit->getMean(chan) / range * channelHeightFloat);
double mean = (canvasSplit->getScreenBufferMean(chan) / range * channelHeightFloat);

if (drawWithOffsetCorrection)
{
Expand Down
2 changes: 1 addition & 1 deletion Plugins/LfpDisplayNode/LfpChannelDisplayInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void LfpChannelDisplayInfo::paint(Graphics& g)

g.setColour(Colours::grey);
g.drawText(String(canvasSplit->getStd(chan)), 5, center+110,41,10,Justification::centred,false);
g.drawText(String(canvasSplit->getMean(chan)), 5, center+60,41,10,Justification::centred,false);
g.drawText(String(canvasSplit->getDisplayBufferMean(chan)), 5, center+60,41,10,Justification::centred,false);

if (x > 0)
{
Expand Down
43 changes: 39 additions & 4 deletions Plugins/LfpDisplayNode/LfpDisplayCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ uint16 LfpDisplaySplitter::getChannelStreamId(int channel)
return processor->getContinuousChannel(channel)->getStreamId();
}

float LfpDisplaySplitter::getMean(int chan)
float LfpDisplaySplitter::getScreenBufferMean(int chan)
{
float total = 0.0f;
float numPts = 0;
Expand All @@ -1566,16 +1566,51 @@ float LfpDisplaySplitter::getMean(int chan)
return total / numPts;
}

float LfpDisplaySplitter::getDisplayBufferMean(int chan)
{
float total = 0.0f;
float numPts = 0;

float sample = 0.0f;

// use 0.1s of sample to compute Mean and Std
float totalPoints = 0.1 * sampleRate;

for (int samp = displayBufferIndex[chan] - totalPoints; samp < displayBufferIndex[chan]; samp += 1)
{
if (samp >= 0) // read the beginning of the buffer
sample = *displayBuffer->getReadPointer(chan, samp);
else // read the end of the buffer if negative index
sample = *displayBuffer->getReadPointer(chan, displayBuffer->getNumSamples() - samp);

total += sample;
numPts++;
}

//std::cout << sample << std::endl;

return total / numPts;
}

float LfpDisplaySplitter::getStd(int chan)
{
float std = 0.0f;
float sample = 0.0f;

float mean = getMean(chan);
float mean = getDisplayBufferMean(chan);
float numPts = 1;

for (int samp = 0; samp < (lfpDisplay->getWidth() - leftmargin); samp += 10)
// use 0.1s of sample to compute Mean and Std
float totalPoints = 0.1 * sampleRate;

for (int samp = displayBufferIndex[chan] - totalPoints; samp < displayBufferIndex[chan]; samp += 1)
{
std += pow((*screenBufferMean->getReadPointer(chan, samp) - mean),2);
if (samp >= 0) // read the beginning of the buffer
sample = *displayBuffer->getReadPointer(chan, samp);
else // read the end of the buffer if negative index
sample = *displayBuffer->getReadPointer(chan, displayBuffer->getNumSamples() - samp);

std += pow((sample - mean),2);
numPts++;
}

Expand Down
7 changes: 5 additions & 2 deletions Plugins/LfpDisplayNode/LfpDisplayCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@ class LfpDisplaySplitter : public Component,
/** Gets the event channel state for a particular sample */
const float getEventState(int samp);

/** Returns the mean of a given channel */
float getMean(int chan);
/** Returns the mean of a given channel, computed from the screen buffer */
float getScreenBufferMean(int chan);

/** Returns the mean of a given channel, computed from the display buffer */
float getDisplayBufferMean(int chan);

/** Returns the standard deviation of a given channnel*/
float getStd(int chan);
Expand Down
Loading

0 comments on commit c0754eb

Please sign in to comment.