Skip to content

Fix highpass-spatial-filter return dtype #2864

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

Merged
merged 4 commits into from
May 21, 2024

Conversation

alejoe91
Copy link
Member

@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label May 16, 2024
@JoeZiminski
Copy link
Collaborator

This looks great, I'll quickly test it now

@JoeZiminski
Copy link
Collaborator

JoeZiminski commented May 16, 2024

Hey Alessio I couldn't push to your fork, how are such issues usually managed?

The test I added the below test in test_highpass_spatial_file.py. I had to add the properties so the data could be returned scaled, but I think maybe there is a better way. It would be cool to generalise this test to all preprocessing steps, but my guess is this would be tricky!

@pytest.mark.parametrize("dtype", [np.int16, np.float32, np.float64])
def test_dtype_stability(dtype):
    """
    Check that the dtype of the recording and
    output data is as expected, as data is cast to float32
    during filtering.
    """
    num_chan = 32
    si_recording = generate_recording(num_channels=num_chan, durations=[2])
    si_recording.set_property("gain_to_uV", np.ones(num_chan))
    si_recording.set_property("offset_to_uV", np.ones(num_chan))
    si_recording = spre.astype(si_recording, dtype)

    assert si_recording.dtype == dtype

    highpass_spatial_filter = spre.highpass_spatial_filter(si_recording, n_channel_pad=2)

    assert highpass_spatial_filter.dtype == dtype

    filtered_data_unscaled = highpass_spatial_filter.get_traces(return_scaled=False)

    assert filtered_data_unscaled.dtype == dtype

    filtered_data_scaled = highpass_spatial_filter.get_traces(return_scaled=True)

    assert filtered_data_scaled.dtype == np.float32

@alejoe91
Copy link
Member Author

I think that only maintainers can push! I'll add the suggested test :)

@JoeZiminski
Copy link
Collaborator

Great thanks, LGTM!

Copy link
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Let's open an issue for the get_traces when the dtype is already float.

@samuelgarcia samuelgarcia merged commit 89968ca into SpikeInterface:main May 21, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preprocessing Related to preprocessing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

highpass_spatial_filter returns as float32
4 participants