From a8b5c2e23b81515fbdbb1e38d4d6ea8331288597 Mon Sep 17 00:00:00 2001 From: Anne Urai Date: Mon, 1 Jul 2024 16:51:47 +0200 Subject: [PATCH] went through documentation and renamed 'reaction time' to 'first movement onset time' or 'response time' depending on the situation --- brainbox/io/one.py | 4 ++-- brainbox/task/trials.py | 18 ++++++++--------- .../loading_data/loading_trials_data.ipynb | 6 +++--- ibllib/pipes/training_status.py | 20 +++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/brainbox/io/one.py b/brainbox/io/one.py index f832fb04c..13d02ca94 100644 --- a/brainbox/io/one.py +++ b/brainbox/io/one.py @@ -674,7 +674,7 @@ def load_passive_rfmap(eid, one=None): def load_wheel_reaction_times(eid, one=None): """ - Return the calculated reaction times for session. Reaction times are defined as the time + Return the calculated first movement onset time for a session. These are are defined as the time between the go cue (onset tone) and the onset of the first substantial wheel movement. A movement is considered sufficiently large if its peak amplitude is at least 1/3rd of the distance to threshold (~0.1 radians). @@ -694,7 +694,7 @@ def load_wheel_reaction_times(eid, one=None): Returns ---------- array-like - reaction times + first movement onset times """ if one is None: one = ONE() diff --git a/brainbox/task/trials.py b/brainbox/task/trials.py index 8ccfcd89e..701e30a3c 100644 --- a/brainbox/task/trials.py +++ b/brainbox/task/trials.py @@ -12,7 +12,7 @@ def find_trial_ids(trials, side='all', choice='all', order='trial num', sort='id :param choice: trial choice, options are 'all', 'correct' or 'incorrect' :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast - :param order: how to order the trials, options are 'trial num' or 'reaction time' + :param order: how to order the trials, options are 'trial num' or 'response time' :param sort: how to sort the trials, options are 'side' (split left right trials), 'choice' (split correct incorrect trials), 'choice and side' (split left right and correct incorrect) :param event: trial event to align to (in order to remove nan trials for this event) @@ -46,15 +46,15 @@ def find_trial_ids(trials, side='all', choice='all', order='trial num', sort='id np.bitwise_and(cont, np.bitwise_and(trials['feedbackType'][idx] == -1, np.isfinite(trials['contrastLeft'][idx]))))[0] - reaction_time = trials['response_times'][idx] - trials['goCue_times'][idx] + response_time = trials['response_times'][idx] - trials['goCue_times'][idx] def _order_by(_trials, order): - # Returns subset of trials either ordered by trial number or by reaction time + # Returns subset of trials either ordered by trial number or by RT sorted_trials = np.sort(_trials) if order == 'trial num': return sorted_trials - elif order == 'reaction time': - sorted_reaction = np.argsort(reaction_time[sorted_trials]) + elif order == 'response time': + sorted_reaction = np.argsort(response_time[sorted_trials]) return sorted_trials[sorted_reaction] dividers = [] @@ -218,7 +218,7 @@ def filter_correct_incorrect_left_right(trials, event_raster, event, contrast, o :param event: event to align to e.g 'goCue_times', 'stimOn_times' :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast - :param order: order to sort trials by either 'trial num' or 'reaction time' + :param order: order to sort trials by either 'trial num' or 'response time' :return: """ trials_sorted, div = find_trial_ids(trials, sort='choice and side', event=event, order=order, contrast=contrast) @@ -258,7 +258,7 @@ def filter_correct_incorrect(trials, event_raster, event, contrast, order='trial :param event: event to align to e.g 'goCue_times', 'stimOn_times' :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast - :param order: order to sort trials by either 'trial num' or 'reaction time' + :param order: order to sort trials by either 'trial num' or 'response time' :return: """ trials_sorted, div = find_trial_ids(trials, sort='choice', event=event, order=order, contrast=contrast) @@ -286,7 +286,7 @@ def filter_left_right(trials, event_raster, event, contrast, order='trial num'): :param event: event to align to e.g 'goCue_times', 'stimOn_times' :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast - :param order: order to sort trials by either 'trial num' or 'reaction time' + :param order: order to sort trials by either 'trial num' or 'response time' :return: """ trials_sorted, div = find_trial_ids(trials, sort='side', event=event, order=order, contrast=contrast) @@ -314,7 +314,7 @@ def filter_trials(trials, event_raster, event, contrast=(1, 0.5, 0.25, 0.125, 0. :param event: event to align to e.g 'goCue_times', 'stimOn_times' :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast - :param order: order to sort trials by either 'trial num' or 'reaction time' + :param order: order to sort trials by either 'trial num' or 'response time' :param sort: how to divide trials options are 'choice' (e.g correct vs incorrect), 'side' (e.g left vs right') and 'choice and side' (e.g correct vs incorrect and left vs right) :return: diff --git a/examples/loading_data/loading_trials_data.ipynb b/examples/loading_data/loading_trials_data.ipynb index 8292c9654..0044b6927 100644 --- a/examples/loading_data/loading_trials_data.ipynb +++ b/examples/loading_data/loading_trials_data.ipynb @@ -225,11 +225,11 @@ "# find index for stim right trials ordered by trial number\n", "trial_id, _ = find_trial_ids(trials, side='right', choice='all', order='trial num')\n", "\n", - "# find index for correct, stim left, 100% contrast trials ordered by reaction time\n", - "trial_id, _ = find_trial_ids(trials, side='left', choice='correct', contrast=[1], order='reaction time')\n", + "# find index for correct, stim left, 100% contrast trials ordered by RT\n", + "trial_id, _ = find_trial_ids(trials, side='left', choice='correct', contrast=[1], order='response time')\n", "\n", "# find index for correct trials ordered by trial number sorted by stimulus side\n", - "trial_id, _ = find_trial_ids(trials, side='left', choice='correct', order='reaction time', sort='side')" + "trial_id, _ = find_trial_ids(trials, side='left', choice='correct', order='response time', sort='side')" ] }, { diff --git a/ibllib/pipes/training_status.py b/ibllib/pipes/training_status.py index 815db9269..1bad4304b 100644 --- a/ibllib/pipes/training_status.py +++ b/ibllib/pipes/training_status.py @@ -548,7 +548,7 @@ def get_sess_dict(session_path, one, protocol, alf_collections=None, raw_collect training.compute_psychometric(trials, block=0.8) sess_dict['performance_easy'] = training.compute_performance_easy(trials) - sess_dict['reaction_time'] = training.compute_median_reaction_time(trials) + sess_dict['response_time'] = training.compute_median_reaction_time(trials) sess_dict['n_trials'] = training.compute_n_trials(trials) sess_dict['sess_duration'], sess_dict['n_delay'], sess_dict['location'] = \ compute_session_duration_delay_location(session_path, collections=raw_collections) @@ -630,7 +630,7 @@ def get_training_info_for_session(session_paths, one, force=True): psychs['80'] = training.compute_psychometric(combined_trials, block=0.8) performance_easy = training.compute_performance_easy(combined_trials) - reaction_time = training.compute_median_reaction_time(combined_trials) + response_time = training.compute_median_response_time(combined_trials) n_trials = training.compute_n_trials(combined_trials) sess_duration = np.nansum([s['sess_duration'] for s in sess_dicts]) @@ -640,7 +640,7 @@ def get_training_info_for_session(session_paths, one, force=True): sess_dict['combined_performance'] = performance sess_dict['combined_contrasts'] = contrasts sess_dict['combined_performance_easy'] = performance_easy - sess_dict['combined_reaction_time'] = reaction_time + sess_dict['combined_response'] = response_time sess_dict['combined_n_trials'] = n_trials sess_dict['combined_sess_duration'] = sess_duration sess_dict['combined_n_delay'] = n_delay @@ -665,7 +665,7 @@ def get_training_info_for_session(session_paths, one, force=True): sess_dict['combined_performance'] = sess_dict['performance'] sess_dict['combined_contrasts'] = sess_dict['contrasts'] sess_dict['combined_performance_easy'] = sess_dict['performance_easy'] - sess_dict['combined_reaction_time'] = sess_dict['reaction_time'] + sess_dict['combined_response_time'] = sess_dict['response_time'] sess_dict['combined_n_trials'] = sess_dict['n_trials'] sess_dict['combined_sess_duration'] = sess_dict['sess_duration'] sess_dict['combined_n_delay'] = sess_dict['n_delay'] @@ -732,7 +732,7 @@ def plot_trial_count_and_session_duration(df, subject): return ax -def plot_performance_easy_median_reaction_time(df, subject): +def plot_performance_easy_median_response_time(df, subject): df = df.drop_duplicates('date').reset_index(drop=True) y1 = {'column': 'combined_performance_easy', @@ -741,9 +741,9 @@ def plot_performance_easy_median_reaction_time(df, subject): 'color': 'k', 'join': True} - y2 = {'column': 'combined_reaction_time', - 'title': 'Median reaction time (s)', - 'lim': [0.1, np.nanmax([10, np.nanmax(df.combined_reaction_time.values)])], + y2 = {'column': 'combined_response_time', + 'title': 'Median response time (s)', + 'lim': [0.1, np.nanmax([10, np.nanmax(df.combined_response_time.values)])], 'color': 'r', 'log': True, 'join': True} @@ -989,7 +989,7 @@ def make_plots(session_path, one, df=None, save=False, upload=False, task_collec return ax1 = plot_trial_count_and_session_duration(df, subject) - ax2 = plot_performance_easy_median_reaction_time(df, subject) + ax2 = plot_performance_easy_median_response_time(df, subject) ax3 = plot_heatmap_performance_over_days(df, subject) ax4 = plot_fit_params(df, subject) ax5 = plot_psychometric_curve(df, subject, one) @@ -1001,7 +1001,7 @@ def make_plots(session_path, one, df=None, save=False, upload=False, task_collec outputs.append(save_name) ax1.get_figure().savefig(save_name, bbox_inches='tight') - save_name = save_path.joinpath('subj_performance_easy_reaction_time.png') + save_name = save_path.joinpath('subj_performance_easy_response_time.png') outputs.append(save_name) ax2.get_figure().savefig(save_name, bbox_inches='tight')