Skip to content
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.3.2] = 2020-10-19

### Bug Fixes
- (Internal) Fixed a running\_processing bug for behavior ophys experiments when the input data would have one more encoder entry than timestamp. The behavior of the code now matches what the warning says.

## [2.3.1] = 2020-10-13

### Bug Fixes
- (Internal) Fixed a write_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.
- (Internal) Fixed a write\_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.

## [2.3.0] = 2020-10-09

Expand Down
2 changes: 1 addition & 1 deletion allensdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@



__version__ = '2.3.1'
__version__ = '2.3.2'


try:
Expand Down
6 changes: 4 additions & 2 deletions allensdk/brain_observatory/behavior/running_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _shift(
Iterable containing numeric data. If int, will be converted to
float in returned object.
periods: int (default=1)
The number of elements to shift.
The number of elements to shift.
fill_value: float (default=np.nan)
The value to fill at the beginning of the shifted array
Returns
Expand Down Expand Up @@ -364,7 +364,9 @@ def get_running_df(data, time: np.ndarray, lowpass: bool = True):
if len(v_in) == len(time) + 1:
warnings.warn(
"Time array is 1 value shorter than encoder array. Last encoder "
"value removed\n", stacklevel=1)
"value removed\n", UserWarning, stacklevel=1)
v_in = v_in[:-1]
v_sig = v_sig[:-1]

# dx = 'd_theta' = angular change
# There are some issues with angular change in the raw data so we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,43 @@ def test_get_running_df(running_data, timestamps, lowpass):
assert np.count_nonzero(np.isnan(actual["speed"])) == 0


@pytest.mark.parametrize(
"lowpass", [True, False]
)
def test_get_running_df_one_fewer_timestamp_check_warning(running_data,
timestamps,
lowpass):
with pytest.warns(
UserWarning,
match="Time array is 1 value shorter than encoder array.*"
):
# Call with one fewer timestamp, check for a warning
_ = get_running_df(
data=running_data,
time=timestamps[:-1],
lowpass=lowpass
)


@pytest.mark.parametrize(
"lowpass", [True, False]
)
def test_get_running_df_one_fewer_timestamp_check_truncation(running_data,
timestamps,
lowpass):
# Call with one fewer timestamp
output = get_running_df(
data=running_data,
time=timestamps[:-1],
lowpass=lowpass
)

# Check that the output is actually trimmed, and the values are the same
assert len(output) == len(timestamps) - 1
Copy link
Contributor

@njmei njmei Oct 19, 2020

Choose a reason for hiding this comment

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

I would add the following asserts:

assert output["v_sig"] == running_data["items"]["behavior"]["encoders"]["vsig"][:-1]
assert output["v_in"] == running_data["items"]["behavior"]["encoders"]["vin"][:-1]

Which checks that encoder values are truncated AND have the expected values.

np.testing.assert_equal(output["v_sig"], running_data["items"]["behavior"]["encoders"][0]["vsig"][:-1])
np.testing.assert_equal(output["v_in"], running_data["items"]["behavior"]["encoders"][0]["vin"][:-1])


@pytest.mark.parametrize(
"arr, periods, fill, expected",
[
Expand Down
8 changes: 8 additions & 0 deletions doc_template/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ The Allen SDK provides Python code for accessing experimental metadata along wit
See the `mouse connectivity section <connectivity.html>`_ for more details.


What's New - 2.3.2 (October 19, 2020)
-----------------------------------------------------------------------
As of the 2.3.2 release:

- (Internal) Fixed a running_processing bug for behavior ophys experiments when the input data would have one more encoder entry than timestamp. The behavior of the code now matches what the warning says.


What's New - 2.3.1 (October 13, 2020)
-----------------------------------------------------------------------
As of the 2.3.1 release:

- (Internal) Fixed a write_nwb bug for behavior ophys experiments involving the BehaviorOphysJsonApi expecting a mesoscope-specific method.


What's New - 2.3.0 (October 9, 2020)
-----------------------------------------------------------------------
As of the 2.3.0 release:
Expand Down