Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passiveChoiceWorld without the passive stimuli #665

Open
samupicard opened this issue May 28, 2024 · 5 comments · Fixed by #678
Open

passiveChoiceWorld without the passive stimuli #665

samupicard opened this issue May 28, 2024 · 5 comments · Fixed by #678
Assignees

Comments

@samupicard
Copy link
Member

At the moment, passiveChoiceWorld follows a strict protocol described here

For chronic experiments we would like to get neural receptive fields every day, but we don't need the passive replay of the task stimuli (in fact, this may disrupt learning so we probably want to get rid of them altogether). We would also like to shorten the gray screen period (spontaneous activity).

I've quickly hacked the passiveChoiceWorld task for today's experiment (I have renamed this locally to passiveChoiceWorld_SP) but in the future it would be great to either:

  1. adjust the passiveChoiceWorld task protocol itself so that the passive replay can optionally be removed/shortened (if specified in task parameters) and to freely select the duration of grey screen (could also be a task parameter?).
  2. if changing an old protocol isn't desirable, creating a new one with the above features as free parameters (ideally, selectable in the wizzard) would be ok too.
@samupicard
Copy link
Member Author

My current hack (just removing the lines controlling the passive replay)

import logging
import sys
import time
from pathlib import Path

import pandas as pd

import iblrig.misc
from iblrig.base_choice_world import ChoiceWorldSession

log = logging.getLogger('iblrig.task')


class Session(ChoiceWorldSession):
    protocol_name = '_iblrig_tasks_passiveChoiceWorld_SP'

    def __init__(self, *args, session_template_id=0, **kwargs):
        self.extractor_tasks = ['PassiveRegisterRaw', 'PassiveTask']
        super(ChoiceWorldSession, self).__init__(**kwargs)
        self.task_params.SESSION_TEMPLATE_ID = session_template_id
        all_trials = pd.read_parquet(Path(__file__).parent.joinpath('passiveChoiceWorld_trials_fixtures.pqt'))
        self.trials_table = all_trials[all_trials['session_id'] == self.task_params.SESSION_TEMPLATE_ID].copy()
        self.trials_table['reward_valve_time'] = self.compute_reward_time(amount_ul=self.trials_table['reward_amount'])

    @staticmethod
    def extra_parser():
        """:return: argparse.parser()"""
        parser = super(Session, Session).extra_parser()
        parser.add_argument(
            '--session_template_id',
            option_strings=['--session_template_id'],
            dest='session_template_id',
            default=0,
            type=int,
            help='pre-generated session index (zero-based)',
        )
        return parser

    def start_hardware(self):
        if not self.is_mock:
            self.start_mixin_frame2ttl()
            self.start_mixin_bpod()
            self.start_mixin_valve()
            self.start_mixin_sound()
            self.start_mixin_bonsai_cameras()
            self.start_mixin_bonsai_microphone()
            self.start_mixin_rotary_encoder()

    def get_state_machine_trial(self, *args, **kwargs):
        pass

    def next_trial(self):
        pass

    def _run(self):
        """
        This is the method that runs the task with the actual state machine
        :return:
        """
        self.trigger_bonsai_cameras()
        log.info('Starting spontaneous activity followed by receptive field mapping')
        # Run the passive part i.e. spontaneous activity and RFMapping stim
        self.run_passive_visual_stim(sa_time='00:01:00')
        # Do NOT run the replay of task events
        log.info('Skipping replay of task stims')


if __name__ == '__main__':  # pragma: no cover
    # python .\iblrig_tasks\_iblrig_tasks_spontaneous\task.py --subject mysubject
    kwargs = iblrig.misc.get_task_arguments(parents=[Session.extra_parser()])
    sess = Session(**kwargs)
    sess.run()

@bimac bimac self-assigned this May 29, 2024
@samupicard
Copy link
Member Author

@bimac @k1o0 i just realised that the PassiveRegisterRaw extractor fails on my custom-made task passiveChoiceWorld_SP above because it cannot find the raw data files produced by the passive task stimuli. Would it be possible to make an extractor that only looks at the RFMapStim.raw data?

@bimac
Copy link
Contributor

bimac commented Jun 17, 2024

#678

@bimac bimac linked a pull request Jun 17, 2024 that will close this issue
@k1o0
Copy link
Contributor

k1o0 commented Jun 17, 2024

@mayofaulkner to release ibllib with changes to PassiveRegisterRaw; also change extractor to use task parameters when saving replay phase of protocol

@bimac
Copy link
Contributor

bimac commented Jun 17, 2024

new task parameters:

'SPONTANEOUS_ACTIVITY_SECONDS': 600  # duration of spontaneous activity in seconds
'SKIP_EVENT_REPLAY': False  # skip the event replay block

@mayofaulkner mayofaulkner self-assigned this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants