@@ -91,13 +91,14 @@ void LfpDisplayNode::updateSettings()
9191 displayBufferMap[streamId]->sampleRate = channel->getSampleRate ();
9292 displayBufferMap[streamId]->name = name;
9393 }
94-
94+ //
9595 displayBufferMap[streamId]->addChannel (channel->getName (), // name
9696 ch, // index
9797 channel->getChannelType (), // type
9898 channel->isRecorded ,
9999 0 , // group
100- channel->position .y // ypos
100+ channel->position .y , // ypos
101+ channel-> getDescription ()
101102 );
102103}
103104
@@ -179,6 +180,11 @@ bool LfpDisplayNode::stopAcquisition()
179180 LfpDisplayEditor* editor = (LfpDisplayEditor*) getEditor ();
180181 editor->disable ();
181182
183+ for (auto split : splitDisplays) {
184+ Array<int > emptyArray = Array<int >();
185+ split -> setFilteredChannels (emptyArray);
186+ }
187+
182188 for (auto buffer : displayBuffers)
183189 buffer->ttlState = 0 ;
184190
@@ -327,3 +333,62 @@ void LfpDisplayNode::acknowledgeTrigger(int id)
327333{
328334 latestTrigger.set (id, -1 );
329335}
336+
337+ bool LfpDisplayNode::getIntField (DynamicObject::Ptr payload, String name, int & value, int lowerBound, int upperBound) {
338+ if (!payload->hasProperty (name) || !payload->getProperty (name).isInt ())
339+ return false ;
340+ int tempVal = payload->getProperty (name);
341+ if ((upperBound != INT_MIN && tempVal > upperBound) || (lowerBound != INT_MAX && tempVal < lowerBound))
342+ return false ;
343+ value = tempVal;
344+ return true ;
345+ }
346+
347+
348+ void LfpDisplayNode::handleBroadcastMessage (String msg) {
349+ var parsedMessage = JSON::parse (msg);
350+ if (!parsedMessage.isObject ())
351+ return ;
352+ DynamicObject::Ptr jsonMessage = parsedMessage.getDynamicObject ();
353+ if (jsonMessage == nullptr )
354+ return ;
355+ String pluginName= jsonMessage -> getProperty (" plugin" );
356+ if (pluginName != " LFPViewer" ) {
357+ return ;
358+ }
359+ String command = jsonMessage -> getProperty (" command" );
360+ DynamicObject::Ptr payload = jsonMessage -> getProperty (" payload" ).getDynamicObject ();
361+ if (command == " filter" ) {
362+ if (payload.get () == nullptr ){
363+ LOGD (" Tried to filter in LFPViewer, but could not find a payload" );
364+ return ;
365+ }
366+ int split, start, rows, cols, colsPerRow, end;
367+ if (!getIntField (payload, " split" , split, 0 , 2 ) || !getIntField (payload, " start" , start, 0 )) {
368+ LOGD (" Tried to filter in LFPViewer, but a valid split and start weren't provided" );
369+ return ;
370+ }
371+ Array<int > channelNames;
372+ // If an end is specificed add channels from start to end
373+ // Else calculate the rectangular selection based on rows and columns
374+ if (getIntField (payload, " end" , end, 0 )) {
375+ for (int index = 0 ; index < (end - start); index++) {
376+ channelNames.add (start + index);
377+ }
378+ }
379+ else {
380+ if (!getIntField (payload, " rows" , rows, 0 ) || !getIntField (payload, " cols" , cols, 0 ) || !getIntField (payload, " colsPerRow" , colsPerRow, 0 )) {
381+ LOGD (" Tried to filter by rectangular selection in LFPViewer, but valid row/column/columnsPerRow counts weren't provided" );
382+ return ;
383+ }
384+ for (int row = 0 ; row < rows; row++) {
385+ for (int col = 0 ; col < cols; col++) {
386+ channelNames.add (start + col + row*colsPerRow);
387+ }
388+ }
389+ }
390+ splitDisplays[split] -> setFilteredChannels (channelNames);
391+ splitDisplays[split] -> shouldRebuildChannelList = true ;
392+ }
393+ }
394+
0 commit comments