Difference between revisions of "Plugins:sessionmodel2"
|Line 82:||Line 82:|
==SESSION AUTOMATOR WINDOW==
Revision as of 21:34, 23 February 2010
Introduction: What sessionmodel2 is and When You Would Use It
Sessionmodel2 is, in short, a plugin to coordinate within-session and across-session training automation, and upgrade from the previous SessionModel plugin.
First, a word about where sessionmodel2 fits in the Solo system.The sessionmodel2 module is at uppermost layer - the 'Plugins' layer - of the Solo training software system; you could successfully use the Solo system to write and run protocols without ever using this module.
When, then, would you use this module?
Suppose you have written a behavioral protocol using the Solo system. You have painstakingly determined the training steps required to teach naïve animals the task of interest. This probably involves a sequence of training stages at each level of which, you would monitor the animals’ performance and decide whether to move to the next training step. Individual animals learn at different rates so you would adapt the progression of training steps to each animal’s performance. All of this would be done manually with the trainer observing each animal’s performance and accordingly adjusting the training parameters (SoloParamHandles).
Sessionmodel2 formalizes this sequence of training stages into a framework which can be programmed and so allows the progression of training to occur automatically (ie without manual intervention).
It allows the user to:
- Create a sequence of separate training stages
- Define what happens within any given training stage
- Determine performance criteria for changing parameter values (e.g. if animal does “badly”, make task “easier”)
- Determine performance criteria for moving to the next stage (e.g. animal “has learnt” where reward is received; now start pairing CS with reward, or alternating between blocks of trials with different task contingencies)
- Execute special instructions at the end of each session to set up the automation for the next day’s session
Automating a session has practical as well as scientific advantages: many more animals can be simultaneously trained, new protocols could be tested, the trainer is free to do other experiments, and it removes subjective intervention (which could differ between animals) on the part of the trainer.
This section must end with a caveat: Eventually, the trainer is not going to be monitoring an automated session as it happens. Unless the proper analysis tools are in place, she will not know whether the training is progressing as intended or whether a parameter has (unintentionally) been changed to an undesirable value. Such things can go unnoticed for days. See the section “Good Charioteer: Tips for Smoother Daily Automation” for some ideas on how to monitor complex protocols for several animals day after day without risking your sanity.
The Framework: How sessionmodel2 works
Let’s work with a simple training example.
The goal is to acquaint a rat with a water port. In each trial of the session, we will dispense some water from this port, and we will monitor whether the rat licked (hit) the water port or not (miss). We will say that if a rat has licked for five consecutive trials, he is “acquainted” with the port; we can move on.
A training stage: as seen by trainer
The figure to the right shows what the trainer would be doing when monitoring the rat:
- Count the number of recentmost consecutive “hits”
- When this number goes above a decided threshold, she moves to the next training step.
- If the number has not achieved threshold, she allows the next trial to run.
This would happen after every trial until the rat has become acquainted with the port; thereafter, a fresh set of rules is applied, one applicable to the next training stage.
Formally, this training stage consists of the following steps:
- An algorithm defining the training stage: Count the number of recentmost consecutive “hits”
- A test for when the stage has met its goal:When this number goes above a decided threshold, she moves to the next training step
- If the number has not achieved threshold, he/she allows the next trial to run.
Sessionmodel2 is the framework which does the above automatically. It runs at the end of every trial, executing the algorithm for the current training stage and at the same time, testing to see if criteria for stage completion have been met. If they have, it moves to the next training stage (if any); if not, it stays at the same training stage.
The difference is that instead of describing a training stage in the English language (as in the example above), we describe it in Matlab Solo code, the language in which protocols are written.
A training stage: as seen by sessionmodel2
In Matlab terms, each training stage has the following components (there are more pieces than you saw in the previous section but don't worry, the logic is still the same):
- “Training Stage”: Matlab code that evaluates at the end of every trial.
- “Completion Test”: A boolean expression that, when true, will move to the next training stage
- “Vars”: Helper SoloParamHandle variables defined for the training stage (eg the “hit counter” from our example above)
- “End-of-Day Logic”: A piece of code that evaluates only at the end of each session (NOT at the end of each trial). Its purpose is to set up parameter values for the next training session.
The figure on the left shows an abstract view of training stages as defined in Matlab. Notice that the training stages have an order and that each training stage is composed of the pieces listed above.
Installing the SessionModel plugin
Step 1: Inherit from 'sessionmodel' in the 'class' statement at the top of your protocol constructor file.
obj = class(obj, mfilename, sessionmodel);
Step 1b: Make sure the following hack code (which will be unnecessary one day when this gets fixed) is called in your protocol:
hackvar = 10; SoloFunctionAddVars('SessionModel', 'ro_args', 'hackvar');
Step 2: Invoke SessionDefinition after defining all your other SoloParamHandles (ie after you have set up all supporting .m files for your protocol).
SessionDefinition(obj, 'init', x, y, f);
SessionDefinition takes a max of 5 input parameters. They are:
- obj : Object handle of the protocol making the call
- action : A string specifying what function this particular call requests from SessionDefinition
('init' and 'next_trial' are probably the only calls you will ever make, unless you use EOD logic; all other 'actions' are invoked by SessionDefinition calling itself)
- x,y : x & y coordinates on the parent protocol window where the next GUI element is to be placed
- f : Figure handle to the parent protocol figure
... and that should be it!