Skip to content

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

@avakiai

Description

@avakiai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    motion correctionQuestions related to motion correction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions