Skip to content

Accept recording= consistently in detect_and_remove_bad_channels, depth_order and average_across_direction - #4779

Merged
alejoe91 merged 3 commits into
SpikeInterface:mainfrom
JESUSROYETH:fix/preprocessing-recording-kwarg-naming
Sep 15, 2026
Merged

alejoe91 merged 3 commits into
SpikeInterface:mainfrom
JESUSROYETH:fix/preprocessing-recording-kwarg-naming

Conversation

@JESUSROYETH

Copy link
Copy Markdown
Contributor

detect_and_remove_bad_channels(recording=rec) — the example in doc/modules/preprocessing.rst — raises TypeError: DetectAndRemoveBadChannelsRecording.__init__() missing 1 required positional argument: 'parent_recording'. Same for depth_order and average_across_direction, different message. All three work fine called positionally, probably why this went unnoticed.

Cause: these three classes name their first __init__ argument parent_recording, while every other preprocessing class (and the dispatcher that builds the public function, core_tools.py) expects recording.

Fix: rename to recording in all three, matching the rest of the module. parent_recording stays accepted permanently, not deprecated — it's the literal key ChannelSliceRecording (and these classes) already use to serialize _kwargs, so recordings saved by older versions still reload with parent_recording=. Put the alias in the __init__s rather than from_dict or the dispatcher so direct construction keeps working too, not just deserialisation — happy to move it if you'd rather handle it differently.

Added a recording= test per function plus one for the resolver helper (fail on main, pass with the patch), and a from_dict round-trip test per function using the legacy name (passes on main too, by design — shows the fix doesn't break loading old recordings). Local preprocessing suite: 268 passed, no regressions.

Fixes #4744.

recording: BaseRecording | None = None,
direction: str = "y",
dtype="float32",
parent_recording: BaseRecording | None = None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to keep this. We have a mechanism to modify kwargs on-the-fly on load and it specifically to handle these kind of API changes.

I'll push the changes here directly!

@alejoe91

Copy link
Copy Markdown
Member

@JESUSROYETH thanks you! We definitely need to fix it, but we have an internal mechanism to remap kwagrs before loading called _handle_kwargs_backward_compatibility.

In my last commit 0b40414, I modified the implementation to use it, and also extended it to ChannelSlice and FrameSlice.

As we are doing a major release, we can just drop the legacy argument IMO. @chrishalcrow @samuelgarcia do you agree?

Note that both DetectAndRemoveBadChannels and DepthOrder don't need to reimplement the _handle_kwargs_backward_compatibility, since it's inherited from ChannelSlice.

@alejoe91 alejoe91 added this to the 0.105.0 milestone Sep 15, 2026
@alejoe91 alejoe91 added preprocessing Related to preprocessing module deprecations Related to code deprecation labels Sep 15, 2026
@alejoe91
alejoe91 merged commit d838c3d into SpikeInterface:main Sep 15, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecations Related to code deprecation preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect_and_remove_bad_channels recording instead of parent_recording

3 participants