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: 5 additions & 2 deletions DataProcessingTools/trialstructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ def get_timestamps(self, event_label):

return self.timestamps[idx], self.trialidx[idx], self.stimidx[idx]

def get_stim(self, stimidx=0):
def get_stim(self, stimidx=0, trialidx=None):
"""
Return the timestamp, identity and location of the stimulus
at `stimidx` of every trial.
"""
fidx = np.where(self.stimidx==stimidx)[0]
fidx = self.stimidx==stimidx
if trialidx is not None:
qidx = np.isin(self.trialidx, trialidx)
fidx = fidx & qidx
p = re.compile("stimulus_on_([0-9]+)_([0-9]+)")
location = []
identity = []
Expand Down
5 changes: 5 additions & 0 deletions tests/test_trialstructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def test_working_memory():
assert location.count(2) == 431
assert location.count(3) == 312

# only correct trials
reward_onset, ridx, _ = trials.get_timestamps("reward_on")
stim1_onset, identity, location = trials.get_stim(0, ridx)
assert len(stim1_onset) == 395

testdir = "animal/20130923/session01"
with DPT.misc.CWD(os.path.join(os.path.dirname(__file__),testdir)):
trials = DPT.trialstructures.WorkingMemoryTrials()
Expand Down