Refactor correct_motion into compute motion, then make interpolation#3905
Refactor correct_motion into compute motion, then make interpolation#3905alejoe91 merged 19 commits intoSpikeInterface:mainfrom
correct_motion into compute motion, then make interpolation#3905Conversation
correct_motion into compute motion, then make interpolation
| detect_peaks_method = detect_kwargs["method"] | ||
| method_class = detect_peak_methods[detect_peaks_method] | ||
| detect_kwargs_without_method = { | ||
| key: detect_kwarg for key, detect_kwarg in detect_kwargs.items() if key != "method" |
There was a problem hiding this comment.
The previous code was poping some kwargs from the dict, which pop'd them out of the parameters dict, losing provenance. We now make a detect_kwargs_without_method so that we don't edit the detect_kwargs dict,
| raise RuntimeError(error_message) | ||
| else: | ||
| warnings.warn(error_message) | ||
| motion = None |
There was a problem hiding this comment.
If raise_error is set to False and the estimate_motion function fails, the function still returns motion_info, just with motion = None.
There was a problem hiding this comment.
This was my wish! Thank you! :)
There was a problem hiding this comment.
I think that the save_motion_info / and load_motion_info should also be updated to handle motion=None. Maybe worth adding a test with a specified folder?
There was a problem hiding this comment.
Done - now if motion = None, save_motion_info makes a folder with no motion subfolder. When load_motion_info finds this folder structure, it sets motion to None.
alejoe91
left a comment
There was a problem hiding this comment.
Just some tiny comments! Looks super :)
Have you tried medicine in the handle drift tutorial?
| raise RuntimeError(error_message) | ||
| else: | ||
| warnings.warn(error_message) | ||
| motion = None |
There was a problem hiding this comment.
This was my wish! Thank you! :)
Co-authored-by: Alessio Buccino <alejoe9187@gmail.com>
…/spikeinterface into add-estimate-motion
|
Hello, I'm trying |
PR to re-factor the
correct_motionfunction into two parts:compute_motion(which returns just amotion_infoobject) andinterpolate_motion.We expose the
compute_motionfunction and edit the docs to use it. This encourages users to do the motion correction computation and check their results before interpolation (as Sam always tells us to do!). At the moment, to do this, the user has to doThen analyse the results. Now they can do
Which hopefully feels nicer.
Alessio also requested a
raise_errorargument, so that if theestimate_motionfails, the peaks and peak locations are still returned. Motion estimation often fails on e.g. a single shank-bank of a NP probe. But it can still be helpful to do a raster plot of the peaks. Hence this seems helpful. Note: it returnsmotion_info['motion'] = Noneat the moment.I've done some little refactors, and updated some things to improve provenance. These are also in preparation for adding a new class
ComputeMotionAndInterpolateRecordingsoon.The
correct_motionfunction should work exactly as before.