Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change "idw" to "kriging" in spatial_interpolation_kernel parameters #2708

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions src/spikeinterface/preprocessing/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@
weight_with_amplitude=False,
),
"interpolate_motion_kwargs": dict(
direction=1,
border_mode="remove_channels",
spatial_interpolation_method="idw",
num_closest=3,
direction=1, border_mode="remove_channels", spatial_interpolation_method="kriging", sigma_um=20.0, p=2
),
},
"nonrigid_fast_and_accurate": {
Expand Down Expand Up @@ -131,10 +128,7 @@
weight_with_amplitude=False,
),
"interpolate_motion_kwargs": dict(
direction=1,
border_mode="remove_channels",
spatial_interpolation_method="idw",
num_closest=3,
direction=1, border_mode="remove_channels", spatial_interpolation_method="kriging", sigma_um=20.0, p=2
),
},
# This preset is a super fast rigid estimation with center of mass
Expand All @@ -159,10 +153,7 @@
rigid=True,
),
"interpolate_motion_kwargs": dict(
direction=1,
border_mode="remove_channels",
spatial_interpolation_method="idw",
num_closest=3,
direction=1, border_mode="remove_channels", spatial_interpolation_method="kriging", sigma_um=20.0, p=2
),
},
# This preset try to mimic kilosort2.5 motion estimator
Expand Down Expand Up @@ -196,11 +187,7 @@
win_shape="rect",
),
"interpolate_motion_kwargs": dict(
direction=1,
border_mode="force_extrapolate",
spatial_interpolation_method="kriging",
sigma_um=[20.0, 30],
p=1,
direction=1, border_mode="force_extrapolate", spatial_interpolation_method="kriging", sigma_um=20.0, p=2
),
},
# empty preset
Expand Down
4 changes: 2 additions & 2 deletions src/spikeinterface/preprocessing/preprocessing_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def get_spatial_interpolation_kernel(
method="kriging",
sigma_um=20.0,
p=1,
num_closest=3,
num_closest=4,
sparse_thresh=None,
dtype="float32",
force_extrapolate=False,
Expand Down Expand Up @@ -40,7 +40,7 @@ def get_spatial_interpolation_kernel(
Used in the "kriging" formula
sparse_thresh: None or float, default: None
If not None for "kriging" force small value to be zeros to get a sparse matrix.
num_closest: int, default: 3
num_closest: int, default: 4
Used for "idw"
force_extrapolate: bool, default: False
How to handle when target location are outside source location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_get_spatial_interpolation_kernel():
target_location[:, 1] = np.linspace(0, 130, 4)

for method in ("kriging", "idw", "nearest"):

kernel = get_spatial_interpolation_kernel(
source_location, target_location, method=method, force_extrapolate=False
)
Expand All @@ -23,6 +24,13 @@ def test_get_spatial_interpolation_kernel():
# check sum sum close 1
assert np.allclose(np.sum(kernel[:, 1:], axis=0), 1.0)

# import matplotlib.pyplot as plt
# fig, ax = plt.subplots()
# im = ax.imshow(kernel)
# ax.set_title(method)
# fig.colorbar(im)
# plt.show()


if __name__ == "__main__":
test_get_spatial_interpolation_kernel()
Loading