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

[Bug]: get_data_in_units fails for ElectricalSeries with channel_conversion #1797

Closed
3 tasks done
h-mayorquin opened this issue Dec 10, 2023 · 0 comments · Fixed by #1806
Closed
3 tasks done

[Bug]: get_data_in_units fails for ElectricalSeries with channel_conversion #1797

h-mayorquin opened this issue Dec 10, 2023 · 0 comments · Fixed by #1806

Comments

@h-mayorquin
Copy link
Contributor

h-mayorquin commented Dec 10, 2023

What happened?

#1745 added a method to get the data in the corect units which is something very nice that I always wanted.

One corner case that i think is not included is that the method will produce incorrect results with an ElectricalSeries object that has a channel conversion.

Steps to Reproduce

This fails on the dev branch:

from pynwb.testing.mock.ecephys import mock_ElectricalSeries

import numpy as np

data = np.asarray([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]])
conversion = 1.0
offset = 3.0
channel_conversion = np.asarray([2.0, 2.0])
electrical_series = mock_ElectricalSeries(
    data=data,
    conversion=conversion,
    offset=offset,
    channel_conversion=channel_conversion,
)

data_in_units = electrical_series.get_data_in_units()
expected_data =  data * conversion * channel_conversion[:, np.newaxis] + offset

np.testing.assert_almost_equal(data_in_units, expected_data)

Traceback

AssertionError: 
Arrays are not almost equal to 7 decimals

Mismatched elements: 10 [/](https://file+.vscode-resource.vscode-cdn.net/) 10 (100%)
Max absolute difference: 1.
Max relative difference: 0.2
 x: array([[4., 4., 4., 4., 4.],
       [4., 4., 4., 4., 4.]])
 y: array([[5., 5., 5., 5., 5.],
       [5., 5., 5., 5., 5.]])

Operating System

Windows

Python Executable

Conda

Python Version

lower version (unsupported)

Package Versions

No response

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant