Skip to content

Commit a9f00ea

Browse files
authored
Merge pull request #2201 from AllenInstitute/ticket/2194/reorder/stimulus/table
Ticket/2194/reorder/stimulus/table
2 parents 58a3152 + 8cb944d commit a9f00ea

File tree

1 file changed

+63
-34
lines changed

1 file changed

+63
-34
lines changed

allensdk/brain_observatory/behavior/behavior_session.py

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,39 @@ def __init__(self, api: Optional[BehaviorDataApi] = None):
3535
settable=True, lowpass=True)
3636
self._raw_running_speed = LazyProperty(self.api.get_running_speed,
3737
settable=True, lowpass=False)
38+
39+
def stimulus_getter():
40+
_df = self.api.get_stimulus_presentations()
41+
_df.drop(['index'], axis=1, errors='ignore')
42+
_df = _df[['start_time', 'stop_time',
43+
'duration',
44+
'image_name', 'image_index',
45+
'is_change', 'omitted',
46+
'start_frame', 'end_frame',
47+
'image_set']]
48+
return _df
3849
self._stimulus_presentations = LazyProperty(
39-
self.api.get_stimulus_presentations, settable=True)
50+
stimulus_getter, settable=True)
51+
4052
self._stimulus_templates = LazyProperty(
4153
self.api.get_stimulus_templates, settable=True)
4254
self._stimulus_timestamps = LazyProperty(
4355
self.api.get_stimulus_timestamps, settable=True)
4456
self._task_parameters = LazyProperty(self.api.get_task_parameters,
4557
settable=True)
46-
self._trials = LazyProperty(self.api.get_trials, settable=True)
58+
59+
def trials_getter():
60+
_df = self.api.get_trials()
61+
_df = _df[['initial_image_name', 'change_image_name',
62+
'stimulus_change', 'change_time',
63+
'go', 'catch', 'lick_times', 'response_time',
64+
'response_latency', 'reward_time', 'reward_volume',
65+
'hit', 'false_alarm', 'miss', 'correct_reject',
66+
'aborted', 'auto_rewarded', 'change_frame',
67+
'start_time', 'stop_time', 'trial_length']]
68+
return _df
69+
self._trials = LazyProperty(trials_getter, settable=True)
70+
4771
self._metadata = LazyProperty(self.api.get_metadata, settable=True)
4872

4973
# ==================== class and utility methods ======================
@@ -441,27 +465,29 @@ def stimulus_presentations(self) -> pd.DataFrame:
441465
stimulus_presentations_id [index]: (int)
442466
identifier for a stimulus presentation
443467
(presentation of an image)
468+
start_time: (float)
469+
image presentation start time in seconds
470+
stop_time: (float)
471+
image presentation end time in seconds
444472
duration: (float)
445473
duration of an image presentation (flash)
446474
in seconds (stop_time - start_time). NaN if omitted
447-
end_frame: (float)
448-
image presentation end frame
475+
image_name: (str)
449476
image_index: (int)
450477
image index (0-7) for a given session,
451478
corresponding to each image name
452-
image_set: (string)
453-
image set for this behavior session
454-
index: (int)
455-
an index assigned to each stimulus presentation
479+
is_change: (bool)
480+
True if the presentation represents a change
481+
in image
456482
omitted: (bool)
457483
True if no image was shown for this stimulus
458484
presentation
459485
start_frame: (int)
460486
image presentation start frame
461-
start_time: (float)
462-
image presentation start time in seconds
463-
stop_time: (float)
464-
image presentation end time in seconds
487+
end_frame: (float)
488+
image presentation end frame
489+
image_set: (string)
490+
image set for this behavior session
465491
"""
466492
return self._stimulus_presentations
467493

@@ -583,9 +609,29 @@ def trials(self) -> pd.DataFrame:
583609
dataframe columns:
584610
trials_id: (int)
585611
trial identifier
612+
initial_image_name: (string)
613+
name of image presented at start of trial
614+
change_image_name: (string)
615+
name of image that is changed to at the change time,
616+
on go trials
617+
stimulus_change: (bool)
618+
True if an image change occurs during the trial
619+
(if the trial was both a 'go' trial and the trial
620+
was not aborted)
621+
change_time: (float)
622+
go: (bool)
623+
Trial type. True if there was a change in stimulus
624+
image identity on this trial
625+
catch: (bool)
626+
Trial type. True if there was not a change in stimulus
627+
identity on this trial
586628
lick_times: (array of float)
587629
array of lick times in seconds during that trial.
588630
Empty array if no licks occured during the trial.
631+
response_time: (float)
632+
time of first lick in trial in seconds and NaN if
633+
trial aborted
634+
response_latency: (float)
589635
reward_time: (NaN or float)
590636
Time the reward is delivered following a correct
591637
response or on auto rewarded trials.
@@ -601,41 +647,24 @@ def trials(self) -> pd.DataFrame:
601647
miss: (bool)
602648
Behavior response type. On a go trial, mouse either
603649
does not lick at all, or licks after reward window
604-
stimulus_change: (bool)
605-
True if an image change occurs during the trial
606-
(if the trial was both a 'go' trial and the trial
607-
was not aborted)
650+
correct_reject: (bool)
651+
Behavior response type. On a catch trial, mouse
652+
either does not lick at all or licks after reward
653+
window
608654
aborted: (bool)
609655
Behavior response type. True if the mouse licks
610656
before the scheduled change time.
611-
go: (bool)
612-
Trial type. True if there was a change in stimulus
613-
image identity on this trial
614-
catch: (bool)
615-
Trial type. True if there was not a change in stimulus
616-
identity on this trial
617657
auto_rewarded: (bool)
618658
True if free reward was delivered for that trial.
619659
Occurs during the first 5 trials of a session and
620660
throughout as needed.
621-
correct_reject: (bool)
622-
Behavior response type. On a catch trial, mouse
623-
either does not lick at all or licks after reward
624-
window
661+
change_frame: (float)
625662
start_time: (float)
626663
start time of the trial in seconds
627664
stop_time: (float)
628665
end time of the trial in seconds
629666
trial_length: (float)
630667
duration of trial in seconds (stop_time -start_time)
631-
response_time: (float)
632-
time of first lick in trial in seconds and NaN if
633-
trial aborted
634-
initial_image_name: (string)
635-
name of image presented at start of trial
636-
change_image_name: (string)
637-
name of image that is changed to at the change time,
638-
on go trials
639668
"""
640669
return self._trials
641670

0 commit comments

Comments
 (0)