@@ -162,8 +162,32 @@ ChannelColourScheme* LfpDisplay::getColourSchemePtr()
162162
163163void LfpDisplay::updateRange (int i)
164164{
165- channels[i]->setRange (range[channels[i]->getType ()]);
166- channelInfo[i]->setRange (range[channels[i]->getType ()]);
165+ // Check if this is an AUX channel with auto-scaling enabled
166+ if (channels[i]->getType () == ContinuousChannel::Type::AUX && options->isAuxAutoScaleEnabled ())
167+ {
168+ // Apply individual auto-scaling based on this channel's InputRange
169+ float rangeMin = canvasSplit->displayBuffer ->channelMetadata [i].inputRangeMin ;
170+ float rangeMax = canvasSplit->displayBuffer ->channelMetadata [i].inputRangeMax ;
171+ float autoRange = rangeMax - rangeMin;
172+
173+ if (autoRange > 0 .0f )
174+ {
175+ channels[i]->setRange (autoRange);
176+ channelInfo[i]->setRange (autoRange);
177+ }
178+ else
179+ {
180+ // Fall back to the default range for this type
181+ channels[i]->setRange (range[channels[i]->getType ()]);
182+ channelInfo[i]->setRange (range[channels[i]->getType ()]);
183+ }
184+ }
185+ else
186+ {
187+ // Use the standard range for the channel type
188+ channels[i]->setRange (range[channels[i]->getType ()]);
189+ channelInfo[i]->setRange (range[channels[i]->getType ()]);
190+ }
167191}
168192
169193void LfpDisplay::setNumChannels (int newChannelCount)
@@ -602,7 +626,10 @@ void LfpDisplay::setRange (float r, ContinuousChannel::Type type)
602626 for (int i = 0 ; i < numChans; i++)
603627 {
604628 if (channels[i]->getType () == type)
629+ {
605630 channels[i]->setRange (range[type]);
631+ channelInfo[i]->setRange (range[type]);
632+ }
606633 }
607634
608635 if (displayIsPaused)
@@ -615,6 +642,46 @@ void LfpDisplay::setRange (float r, ContinuousChannel::Type type)
615642 }
616643}
617644
645+ void LfpDisplay::setAutoRangeForAuxChannels ()
646+ {
647+ if (canvasSplit->displayBuffer == nullptr || channels.size () == 0 )
648+ return ;
649+
650+ // Apply individual ranges to each AUX channel based on their InputRange
651+ for (int i = 0 ; i < numChans; i++)
652+ {
653+ if (channels[i]->getType () == ContinuousChannel::Type::AUX)
654+ {
655+ // Get the InputRange from the channel metadata
656+ if (i < canvasSplit->displayBuffer ->channelMetadata .size ())
657+ {
658+ float rangeMin = canvasSplit->displayBuffer ->channelMetadata [i].inputRangeMin ;
659+ float rangeMax = canvasSplit->displayBuffer ->channelMetadata [i].inputRangeMax ;
660+ float autoRange = rangeMax - rangeMin;
661+
662+ if (autoRange > 0 .0f )
663+ {
664+ channels[i]->setRange (autoRange);
665+ channelInfo[i]->setRange (autoRange);
666+ }
667+ else
668+ {
669+ // Fall back to the default range for this type
670+ channels[i]->setRange (range[ContinuousChannel::Type::AUX]);
671+ channelInfo[i]->setRange (range[ContinuousChannel::Type::AUX]);
672+ }
673+ }
674+ }
675+ }
676+
677+ if (displayIsPaused)
678+ {
679+ timeOffsetChanged = true ;
680+ canRefresh = true ;
681+ refresh ();
682+ }
683+ }
684+
618685int LfpDisplay::getRange ()
619686{
620687 return getRange (options->getSelectedType ());
@@ -834,20 +901,25 @@ void LfpDisplay::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& w
834901 {
835902 if (e.mods .isAltDown ()) // ALT + scroll wheel -> change channel range (was SHIFT but that clamps wheel.deltaY to 0 on OSX for some reason..)
836903 {
904+ auto chanType = options->getSelectedType ();
905+
906+ if (chanType == ContinuousChannel::AUX && options->isAuxAutoScaleEnabled ())
907+ return ;
908+
837909 int h = getRange ();
838910
839- int step = options->getRangeStep (options-> getSelectedType () );
911+ int step = options->getRangeStep (chanType );
840912
841913 // std::cout << wheel.deltaY << std::endl;
842914
843915 if (wheel.deltaY > 0 )
844916 {
845- setRange (h + step, options-> getSelectedType () );
917+ setRange (h + step, chanType );
846918 }
847919 else
848920 {
849921 if (h > step + 1 )
850- setRange (h - step, options-> getSelectedType () );
922+ setRange (h - step, chanType );
851923 }
852924
853925 options->setRangeSelection (h); // update combobox
@@ -1174,6 +1246,7 @@ void LfpDisplay::mouseDown (const MouseEvent& event)
11741246 int dist = 0 ;
11751247 int mindist = 10000 ;
11761248 int closest = 5 ;
1249+ float chanRange = getRange ();
11771250
11781251 for (int n = 0 ; n < drawableChannels.size (); n++) // select closest instead of relying on eventComponent
11791252 {
@@ -1188,6 +1261,7 @@ void LfpDisplay::mouseDown (const MouseEvent& event)
11881261 {
11891262 mindist = dist - 1 ;
11901263 closest = n;
1264+ chanRange = drawableChannels[n].channel ->getRange ();
11911265 }
11921266 }
11931267
@@ -1213,7 +1287,7 @@ void LfpDisplay::mouseDown (const MouseEvent& event)
12131287 {
12141288 drawableChannels[0 ].channelInfo ->updateXY (
12151289 float (x) / getWidth () * canvasSplit->timebase ,
1216- (-(float (y) - viewport->getViewPositionY ()) / viewport->getViewHeight () * float (getRange ())) + float (getRange () / 2 ));
1290+ (-(float (y) - viewport->getViewPositionY ()) / viewport->getViewHeight () * float (chanRange)) + float (chanRange / 2 ));
12171291 }
12181292 }
12191293
0 commit comments