From eaf09ba55b3062bf5ff340f92c669ba04d722e75 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Mon, 16 Sep 2024 11:50:24 +0200 Subject: [PATCH] Auto-cast recording to float prior to interpolation --- src/spikeinterface/preprocessing/motion.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/preprocessing/motion.py b/src/spikeinterface/preprocessing/motion.py index ddb981a944..14c565a290 100644 --- a/src/spikeinterface/preprocessing/motion.py +++ b/src/spikeinterface/preprocessing/motion.py @@ -13,6 +13,7 @@ from spikeinterface.core.core_tools import SIJsonEncoder from spikeinterface.core.job_tools import _shared_job_kwargs_doc + motion_options_preset = { # dredge "dredge": { @@ -277,10 +278,11 @@ def correct_motion( This function depends on several modular components of :py:mod:`spikeinterface.sortingcomponents`. - If select_kwargs is None then all peak are used for localized. + If `select_kwargs` is None then all peak are used for localized. The recording must be preprocessed (filter and denoised at least), and we recommend to not use whithening before motion estimation. + Since the motion interpolation requires a "float" recording, the recording is casted to float32 if necessary. Parameters for each step are handled as separate dictionaries. For more information please check the documentation of the following functions: @@ -435,6 +437,8 @@ def correct_motion( t1 = time.perf_counter() run_times["estimate_motion"] = t1 - t0 + if recording.get_dtype().kind != "f": + recording = recording.astype("float32") recording_corrected = InterpolateMotionRecording(recording, motion, **interpolate_motion_kwargs) motion_info = dict(