Skip to content

Commit

Permalink
Merge pull request #2241 from AllenInstitute/rc/2.13.1
Browse files Browse the repository at this point in the history
Update __init__.py
  • Loading branch information
danielsf authored Oct 5, 2021
2 parents ce0def7 + ec6ece5 commit 80722b0
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 399 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.13.1] = 2021-10-04
- Fixes bug that was preventing the BehaviorSession from properly instantiating passive sessions.

## [2.13.0] = 2021-09-22
- Major internal refactor to BehaviorSession, BehaviorOphysExperiment classes. Implements DataObject pattern for fetching and serialization of data.

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

__version__ = '2.13.0'
__version__ = '2.13.1'


try:
Expand Down
26 changes: 17 additions & 9 deletions allensdk/brain_observatory/behavior/data_objects/licks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import warnings
from typing import Optional

import pandas as pd
Expand Down Expand Up @@ -86,18 +85,27 @@ def from_nwb(cls, nwbfile: NWBFile) -> Optional["Licks"]:
if 'licking' in nwbfile.processing:
lick_module = nwbfile.processing['licking']
licks = lick_module.get_data_interface('licks')

df = pd.DataFrame({
'timestamps': licks.timestamps[:],
'frame': licks.data[:]
})
timestamps = licks.timestamps[:]
frame = licks.data[:]
else:
warnings.warn("This session "
f"'{int(nwbfile.identifier)}' has no rewards data.")
return None
timestamps = []
frame = []

df = pd.DataFrame({
'timestamps': timestamps,
'frame': frame
})

return cls(licks=df)

def to_nwb(self, nwbfile: NWBFile) -> NWBFile:

# If there is no lick data, do not write
# anything to the NWB file (this is
# expected for passive sessions)
if len(self.value['frame']) == 0:
return nwbfile

lick_timeseries = TimeSeries(
name='licks',
data=self.value['frame'].values,
Expand Down
22 changes: 15 additions & 7 deletions allensdk/brain_observatory/behavior/data_objects/rewards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from typing import Optional

import pandas as pd
Expand Down Expand Up @@ -51,16 +50,25 @@ def from_nwb(cls, nwbfile: NWBFile) -> Optional["Rewards"]:
time = rewards.get_data_interface('autorewarded').timestamps[:]
autorewarded = rewards.get_data_interface('autorewarded').data[:]
volume = rewards.get_data_interface('volume').data[:]
df = pd.DataFrame({
'volume': volume, 'timestamps': time,
'autorewarded': autorewarded})
else:
warnings.warn("This session "
f"'{int(nwbfile.identifier)}' has no rewards data.")
return None
volume = []
time = []
autorewarded = []

df = pd.DataFrame({
'volume': volume,
'timestamps': time,
'autorewarded': autorewarded})
return cls(rewards=df)

def to_nwb(self, nwbfile: NWBFile) -> NWBFile:

# If there is no rewards data, do not
# write anything to the NWB file (this
# is expected for passive sessions)
if len(self.value['timestamps']) == 0:
return nwbfile

reward_volume_ts = TimeSeries(
name='volume',
data=self.value['volume'].values,
Expand Down
Loading

0 comments on commit 80722b0

Please sign in to comment.