diff --git a/brainbox/task/closed_loop.py b/brainbox/task/closed_loop.py index 96810f6ff..d32102177 100644 --- a/brainbox/task/closed_loop.py +++ b/brainbox/task/closed_loop.py @@ -388,7 +388,7 @@ def generate_pseudo_stimuli(n_trials, contrast_set=[0, 0.06, 0.12, 0.25, 1], fir return p_left, contrast_left, contrast_right -def generate_pseudo_session(trials, generate_choices=True): +def generate_pseudo_session(trials, generate_choices=True, contrast_distribution='biased'): """ Generate a complete pseudo session with biased blocks, all stimulus contrasts, choices and rewards and omissions. Biased blocks and stimulus contrasts are generated using the same @@ -426,7 +426,7 @@ def generate_pseudo_session(trials, generate_choices=True): # Draw position and contrast for this trial position = _draw_position([-1, 1], pseudo_trials['probabilityLeft'][i]) - contrast = _draw_contrast(contrast_set, 'uniform') + contrast = _draw_contrast(contrast_set, prob_type=contrast_distribution, idx=np.where(contrast_set == 0)[0][0]) signed_stim = contrast * np.sign(position) if generate_choices: diff --git a/brainbox/tests/test_task.py b/brainbox/tests/test_task.py index 5e7e85684..402b57c82 100755 --- a/brainbox/tests/test_task.py +++ b/brainbox/tests/test_task.py @@ -105,8 +105,19 @@ def test_generate_pseudo_stimuli(self): def test_generate_pseudo_session(self): test_trials = self.test_trials - pseudo_trials = task.generate_pseudo_session(test_trials) - self.assertTrue(pseudo_trials.shape[0] == test_trials.shape[0]) + c = np.zeros(9) + np.random.seed(456) + for m in np.arange(10): + pseudo_trials = task.generate_pseudo_session(test_trials, generate_choices=False, contrast_distribution='biased') + c += pseudo_trials.groupby("signed_contrast")['signed_contrast'].count().values / pseudo_trials.shape[0] + self.assertTrue(np.all(np.round(c * 2) / 2 == 1)) + c = np.zeros(9) + np.random.seed(456) + for m in np.arange(10): + pseudo_trials = task.generate_pseudo_session(test_trials, generate_choices=False, + contrast_distribution='uniform') + c += pseudo_trials.groupby("signed_contrast")['signed_contrast'].count().values / pseudo_trials.shape[0] + self.assertTrue(np.all(np.round(c * 2) / 2 == np.array([1., 1., 1., 1., 2., 1., 1., 1., 1.]))) def test_get_impostor_target(self): # labels between 3 and 14 diff --git a/ibllib/__init__.py b/ibllib/__init__.py index 05e6e1a90..f890e2d0e 100644 --- a/ibllib/__init__.py +++ b/ibllib/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.13.4" +__version__ = "2.13.5" import warnings from ibllib.misc import logger_config diff --git a/release_notes.md b/release_notes.md index 93b957a32..a6d4b8fdc 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,7 @@ ## Release Notes 2.13 +## Release Notes 2.13.4 2022-07-27 +- Hotfix: pseudo session biased generation contrast distribution + ## Release Notes 2.13.4 2022-07-22 - Hotfix: Density displays had unexisting colormaps in snapshots QC tasks - Generate extra training plots based on psychometric curves