You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Common Average Referencing (CAR) of multi-channel electrophysiology signals is frequently performed by subtracting the median signal from all channels. As far as I'm aware, there is not a built-in operator in Bonsai for calculating the median of the rows/columns of a matrix. Although it's not too complicated to write an extension to do this, I feel that a median operator would fit naturally in the Bonsai.Dsp package and that having one would reduce friction for people trying to process ephys signals in Bonsai.
I could imagine this being implemented as either:
an additional option in the Reduce operator (however, this would mean moving Reduce away from being a direct port of the equivalent OpenCV function); or
a standalone operator.
I'd be curious to hear others' thoughts on whether this is worth adding and if so what form it should take.
The text was updated successfully, but these errors were encountered:
This one however uses the mean rather than the median to compute the reference value for performance reasons.
I understand that for some signals it might be more relevant to use the median to do this instead. In that case it would probably make sense to extend this operator with a property allowing to switch between the algorithm used to compute the common reference (mean or median, default mean for back compatibility).
What do you think? It should be possible to compute the signal median using OpenCV but some research might be needed to do this efficiently at scale using vectorised operations. I think Sort is implemented row-wise but not entirely sure.
@glopesdev I think adding median referencing as an option within ReferenceChannels makes a lot of sense and very nicely addresses the use case I brought up in the original Issue. It does prevent the user from directly accessing the median signal itself, though (as far as I can tell). I feel like there are other use cases where the median itself is the desired output. For example, I currently compute the median of a rolling Buffer of values to determine moving thresholds for some of my closed-loop feedback experiments.
What do you think of having both an independent Median operator and a median option in ReferenceChannels (using the same, underlying median function)?
Common Average Referencing (CAR) of multi-channel electrophysiology signals is frequently performed by subtracting the median signal from all channels. As far as I'm aware, there is not a built-in operator in Bonsai for calculating the median of the rows/columns of a matrix. Although it's not too complicated to write an extension to do this, I feel that a median operator would fit naturally in the Bonsai.Dsp package and that having one would reduce friction for people trying to process ephys signals in Bonsai.
I could imagine this being implemented as either:
I'd be curious to hear others' thoughts on whether this is worth adding and if so what form it should take.
The text was updated successfully, but these errors were encountered: