Skip to content

Commit

Permalink
GH AllenInstitute#533 - Check for autobias_v in sweep_metadata keys
Browse files Browse the repository at this point in the history
First check that autobias_v is present in sweep_metadata.keys() before assigning value in
Sweep(), set to None if not present. Also added autobias_v as None in
test_get_sweep_metadata from test_mies_nwb_data.py so that expected
result and obtained result match.
  • Loading branch information
ru57y34nn committed Sep 23, 2021
1 parent 59f5132 commit d06ca64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ipfx/dataset/ephys_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def sweep(self, sweep_number: int) -> Sweep:

sweep_data = self.get_sweep_data(sweep_number)
sweep_metadata = self._data.get_sweep_metadata(sweep_number)
if "autobias_v" in sweep_metadata.keys():
autobias_v = sweep_metadata["autobias_v"]
else:
autobias_v = None

time = np.arange(
len(sweep_data["stimulus"])
Expand All @@ -248,8 +252,8 @@ def sweep(self, sweep_number: int) -> Sweep:
sampling_rate=sweep_data["sampling_rate"],
sweep_number=sweep_number,
clamp_mode=sweep_metadata["clamp_mode"],
autobias_v = sweep_metadata["autobias_v"],
epochs=sweep_data.get("epochs", None),
autobias_v = autobias_v
)

except Exception:
Expand Down
1 change: 1 addition & 0 deletions tests/dataset/test_mies_nwb_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_get_sweep_metadata(mies_nwb_data):
'stimulus_code_ext': 'STIMULUS_CODE[1]',
'clamp_mode': 'CurrentClamp',
'stimulus_name': 'expected name',
'autobias_v': None
}

obtained = mies_nwb_data.get_sweep_metadata(sweep_number=4)
Expand Down

0 comments on commit d06ca64

Please sign in to comment.