Skip to content

Commit

Permalink
Strobefix (#13)
Browse files Browse the repository at this point in the history
* Fixes a bug in converting strobes

* Adds tests for strobes

* Bumps minor version number
  • Loading branch information
grero committed Jan 20, 2021
1 parent bf713b4 commit 99f4f24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions NeuralProcessingTools/trialstructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def to_words(self, strobes):
words = []
if (strobes[0] == 4415) or (strobes[0] == 4606) or (strobes[0] == 4159):
for sv in strobes:
w = np.binary_repr(-sv, 16)[-8:]
w = np.binary_repr(~sv, 16)[-8:]
words.append(w)
elif strobes[0] == -4416:
for sv in strobes:
Expand All @@ -151,7 +151,7 @@ def to_words(self, strobes):
words.append(w)
elif (strobes.min() == 63) or (strobes.min() == 77) or (strobes.min() == 2069) or (strobes.min() == 2071) or (strobes.min() == 2271):
for sv in strobes:
w = np.binary_repr(-w, 16)[-8:]
w = np.binary_repr(~sv, 16)[-8:]
words.append(w)
else:
for sv in strobes:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name="NeuralProcessingTools",
version="0.6.0",
version="0.6.1",
description="""Tools for processing neural data""",
url="https://github.com/grero/NeuralProcessingTools.git",
author="Roger Herikstad",
Expand Down
6 changes: 6 additions & 0 deletions tests/test_oldtrials.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def test_oldtrials():
wget.download("http://cortex.nus.edu.sg/testdata/J20140807_event_data.mat", "event_data.mat")
do_unlink = True
trials = OldWorkingMemoryTrials()
# test specific strobes
strobes = np.int16([4415, 4607])
words = trials.to_words(strobes)
assert words[0] == '11000000'
assert words[1] == '00000000'

assert (trials.events == "trial_start").sum() == 934
assert (trials.events == "reward_on").sum() == 369
print(trials.events)
Expand Down

0 comments on commit 99f4f24

Please sign in to comment.