[MRG] Add multidim decorator to filter_signal#264
Conversation
|
This definitely falls under the category of "poorly documented behaviour", but I think the reason that the multidim decorator wasn't added to the filter functions is that these functions actually do already work on 2d signals. On main, for me, this currently works: The most relevant step for this is that the @ryanhammonds - were you running into some error with applying the filter to 2d arrays? If not, and you can have a quick check that the current approach does generalize beyond 1d, then I think what we should do here is update the docs, rather than add the decorator. Also: woah on the different between |
|
@TomDonoghue Thanks for this! You're totally correct, it works for 1d or 2d (but not 3d) signals. I don't see a huge use case for 3d arrays anyways. And like you mentioned it's redundant. I removed the multidim decorator, but did add a note in the docstring that 2d arrays are supported. I also added a small test to show it's does indeed work with 2d arrays as intended. I was surprised by the the performance diff of stack vs array as well. I think in most cases np.array + list comprehension is typically faster than stack/vstack. I have a weird fascination with code optimization, maybe I should learn C / other lower level language some day lol. |
This allows 2d signals to be passed to filter_signal. My use case was filtering a 2d array of signals from a MEA.
I also updated np.stack to np.array in the decorator since it's equivalent in this case and 10x faster.