Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dense event matching #1815

Open
bmcfee opened this issue Mar 2, 2024 · 1 comment
Open

Dense event matching #1815

bmcfee opened this issue Mar 2, 2024 · 1 comment
Labels
enhancement Does this improve existing functionality? functionality Does this add new functionality?

Comments

@bmcfee
Copy link
Member

bmcfee commented Mar 2, 2024

Is your feature request related to a problem? Please describe.

In implementing #1766, i ran into a snag when trying to extend onset backtracking to support multichannel inputs. The problem is as follows:

  • multichannel support requires densely encoded (boolean) outputs to indicate detections to avoid ragged output
  • backtracking entails matching each detection to the nearest preceding local minimum
  • matching is done efficiently using our event matching function. This only supports sparsely encoded events

Describe the solution you'd like

It should be possible to implement an efficient matching algorithm for boolean inputs. Probably the way to do it is to convert the target events to a sparse representation and then use searchsorted, but we shouldn't need to do this explicitly with the source events.

Describe alternatives you've considered

We could hack the onset backtracking code to wrap everything in a dense -sparse-dense conversion, and vectorize accordingly so that it behaves transparently. This might not be as efficient as a direct implementation, but it would work.

@bmcfee bmcfee added enhancement Does this improve existing functionality? functionality Does this add new functionality? labels Mar 2, 2024
@bmcfee
Copy link
Member Author

bmcfee commented Mar 4, 2024

I gave this a bit more thought, and I'm actually not sure that a direct implementation (ie linear search) would have any benefit over the alternative that would convert dense (booleans) to sparse (indices) and use searchsorted. So I'm leaning toward just doing the latter.

Since this is a pretty niche use case, I think we can just build it directly into the backtracking function and not lift it up to the main API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Does this improve existing functionality? functionality Does this add new functionality?
Development

No branches or pull requests

1 participant