spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

drift correction (Dredge) parameter optimization for long NHP recording

Open liyipeng-moon opened this issue 5 months ago • 6 comments

Hi all, I’m using Dredge (with default SpikeInterface parameters, except for a longer chunk_duration of 6s) to correct motion in my 3-4 hour acute recording in head-fixed macaque. However, I’m seeing spikes in the motion vector trace, even though the animal wasn’t moving much at those times. Could these spikes be real, or might they reflectartifacts? If they’re artifactual, how should I adjust my parameters to improve the motion correction? Thanks in advance for your help!

Image

liyipeng-moon avatar Jul 16 '25 09:07 liyipeng-moon

@cwindolf can you hel @liyipeng-moon on this one?

alejoe91 avatar Jul 16 '25 09:07 alejoe91

Could you please send a zoomed image of 1 such "noisy/spiky" period? These are typically "hallucinations" and not real motions, when DREDge is not finding the right direction and therefore "jumping" within the given spatial limits (as you can see, with roughly similar amplitudes all the time). Your recording indeed doesn't seem to have a lot of motion, only slow drift. Here's what I would do (and have done before) in such poor motion estimation: save this motion vector as a CSV, paste an envelope/curve on it to get this nice slow drift, and use that smooth curve for motion correction instead of this glitchy original. Not sure if such a smoothing function is already available as a built-in feature for motion correction, so I did it separately (but it might make sense, what do you think?)

meszena avatar Jul 16 '25 10:07 meszena

Hi, I’ll take a closer look at the spikes once I’m back to the office. Thank you for your suggestion—I’ll try applying the blue envelope to my recording and compare the results - would take some time though. I’ll share feedback here once I’ve tested it.

liyipeng-moon avatar Jul 16 '25 11:07 liyipeng-moon

Hi. IN dredge, smoothing in time (first) and space (then) can help.

    histogram_depth_smooth_um=1,
    histogram_time_smooth_s=1,

can be change to

    histogram_depth_smooth_um=2,
    histogram_time_smooth_s=1.5,

for instance

samuelgarcia avatar Jul 16 '25 20:07 samuelgarcia

Hi @liyipeng-moon , you could in addition to Sam's suggestion try SI's motion cleaner function https://github.com/SpikeInterface/spikeinterface/blob/main/src/spikeinterface/sortingcomponents/motion/motion_cleaner.py#L6 . I'd also suggest trying to increase the spatial window size parameter (win_scale_um) to get some more signal in each window, but if you do that I'd suggest to visualize the motion tracking results to make sure have the appropriate level of nonrigidity (difference along depth of the probe)

cwindolf avatar Aug 19 '25 18:08 cwindolf

Hi all, I’ve added smooth binning (both spatial and temporal), and the data look much better now. However, I still need to dive into the dredge code with several Ctrl+D in the notebook, since I couldn’t find where to pass these two dredge-specific parameters into si.correct_motion.

Do you have any suggestions? Thanks!

liyipeng-moon avatar Aug 22 '25 07:08 liyipeng-moon