SpikeInterface / SpikeInterface/spikeinterface

"Can't interpolate traces" with int16 dtype in motion_correction

Open
#3,146 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

motion correction
Dominant language
Python
Stars
847
Forks
280
Avg merge
3d 9h
Merged PRs (30d)
29

Description

Hello,

I'm trying out a few motion correction algorithms on Neuropixel 1.0 data. I'm currently running through the pipeline with a short (<5 minute) recording. After chaining preprocessing steps, I get the following error when the detect and localize step completes. Any ideas what is causing this behavior?

At first I thought the error may have been caused by one bad channel that had been removed, but the error persists regardless of whether any channels are removed or not.
Also, the dtype has not changed through preprocessing - og dtype is and remains int16.

job_kwargs = dict(n_jobs=40, chunk_duration='1s', progress_bar=True)

rec1 = si.highpass_filter(raw_rec, freq_min=400.)
bad_channel_ids, channel_labels = si.detect_bad_channels(rec1)
rec2 = rec1.remove_channels(bad_channel_ids)
print('bad_channel_ids', bad_channel_ids)

rec3 = si.phase_shift(rec1)
rec4 = si.common_reference(rec3, operator="median", reference="global")
rec = rec4

some_presets = ('kilosort_like', 'nonrigid_accurate')
for preset in some_presets:
    print('Computing with', preset)
    folder = anim_dat_dir[2] + '/' + 'motion_folder_dataset1' + '/' + preset

    # if folder.exists():
    #     shutil.rmtree(folder)
    recording_corrected, motion_info = si.correct_motion(rec, preset=preset,
                                                         folder=folder,
                                                         output_motion_info=True, **job_kwargs)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[57], line 6
      3 folder = anim_dat_dir[2] + '/' + 'motion_folder_dataset1' + '/' + preset
      4 # if folder.exists():
      5 #     shutil.rmtree(folder)
----> 6 recording_corrected, motion_info = si.correct_motion(rec, preset=preset,
      7                                                      folder=folder,
      8                                                      output_motion_info=True, **job_kwargs)

File D:\downloads_\spikeinterface\src\spikeinterface\preprocessing\motion.py:386, in correct_motion(recording, preset, folder, output_motion_info, overwrite, detect_kwargs, select_kwargs, localize_peaks_kwargs, estimate_motion_kwargs, interpolate_motion_kwargs, **job_kwargs)
    383 t1 = time.perf_counter()
    384 run_times["estimate_motion"] = t1 - t0
--> 386 recording_corrected = InterpolateMotionRecording(recording, motion, **interpolate_motion_kwargs)
    388 motion_info = dict(
    389     parameters=parameters,
    390     run_times=run_times,
   (...)
    393     motion=motion,
    394 )
    395 if folder is not None:

File D:\downloads_\spikeinterface\src\spikeinterface\sortingcomponents\motion_interpolation.py:343, in InterpolateMotionRecording.__init__(self, recording, motion, border_mode, spatial_interpolation_method, sigma_um, p, num_closest, interpolation_time_bin_centers_s, interpolation_time_bin_size_s, dtype, **spatial_interpolation_kwargs)
    341         dtype = recording.dtype
    342     else:
--> 343         raise ValueError(f"Can't interpolate traces of recording with non-floating dtype={recording.dtype=}.")
    345 dtype_ = fix_dtype(recording, dtype)
    346 BasePreprocessor.__init__(self, recording, channel_ids=channel_ids, dtype=dtype_)

ValueError: Can't interpolate traces of recording with non-floating dtype=recording.dtype=dtype('int16').

Many thanks,
ava

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with preprocessing/motion.py and sortingcomponents/motion_interpolation.py, especially correct_motion and InterpolateMotionRecording where the traceback fails. Reproduce the shown pipeline with an int16 recording, then inspect how the interpolation step handles recording dtype. Done means the reported failure is addressed with a verified behavior for this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.