Protocol-writing with the Solo system: The Basics: The Water Valve Calibrator

53
Protocol-writing with the Solo system: The Basics: The Water Valve Calibrator

description

Protocol-writing with the Solo system: The Basics: The Water Valve Calibrator. Getting your Bearings. Path to protocol executable: (root-dir)/ExperPort/Protocols/ Protocol object: protocolname obj.m Object files in: (1)/@protocolname obj.m. P. C. solo_watervalve.m. state35.m. close.m. - PowerPoint PPT Presentation

Transcript of Protocol-writing with the Solo system: The Basics: The Water Valve Calibrator

Page 1: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Protocol-writing with the Solo system:

The Basics: The Water Valve Calibrator

Page 2: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Path to protocol executable: (root-dir)/ExperPort/Protocols/

Protocol object: protocolnameobj.m

Object files in: (1)/@protocolnameobj.m

Getting your Bearings

Page 3: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P

The protocol file

Call to constructor

close.m

state35.m

(update files)

Cstate35.mclose.m

solo_watervalve.m

Page 4: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Constructor P Cstate35.mclose.m

Matlab object creation code

Delete previous SoloParamHandles (SPH) associated with the object

Protocol-nonspecific variables

Declaring a function that uses SPHs

Page 5: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Constructor: Adding UI elements P Cstate35.mclose.m

Page 6: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Previewing Greatness to Come …

Page 7: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Constructor: Adding UI elements (2)

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P Cstate35.mclose.m

• Optional UI features (labels, tooltips)

• Positioning

Page 8: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Constructor: Add Dispense Control P Cstate35.mclose.m

Look at HandleParam/*.m for available featurese.g. HandleParam/EditParam.m

Page 9: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

The constructor initialisesthe state matrix

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P Cstate35.mclose.mstm_script

Declaring …

… and callingSoloFunctions

The constructor initialises all peripheral sections of a protocol. e.g.

Deciding trial sides (SidesSection.m)

Constructing sounds (ChordSection.m)

Page 10: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Programming the state matrix:Skeleton for specialised files

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P Cstate35.mclose.mstm_script

How a SoloFunction gets registered SPHs during each call

Adding UI elements to the main figure (controlled by this script)

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 11: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Using read-only args

P Cstate35.mclose.mstm_script

Using flags set in mystartup.m

Setting a value: myvar.value = 22/7;Getting a value: value(myvar)

Page 12: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

state35.m: Executed at the end of trials

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P Cstate35.mclose.mstm_script

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Constructor

trial_finished_actions is an SPH!

Page 13: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Not just a pretty face: Callbacks P Cstate35.mclose.mstm_script

Not returning after a callback segment => extra state matrix generations!!!

Constructor: Setting a callback …

… and executing it.

Page 14: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Breathe.Review the Concepts.

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Flow of control SoloParamHandles SoloFunctionsCreating UI el’ts

(EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Page 15: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

End of Part INext Part: A protocol that requires a rat.

Page 16: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Protocol-writing with the Solo system:

Higher, Faster, Stronger: Localisation Sampling (Locsamp)

Page 17: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Bells, whistles, and a few useful things ...

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Flow of control SoloParamHandles SoloFunctionsCreating UI el’ts

(EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Page 18: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Bells, whistles, and a few useful things ...Flow of control SoloParamHandles SoloFunctions

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Dependencies of SPHs and callbacks

Creating UI el’ts (EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

SPH avatars: figures, arrays, plots, …

Managing trial dataSaving and Loading

Naming states

The event cell array

Page 19: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

RIGHTtrial

Localisation Sampling: Decomposing a trial

Sound on Left

GO

LEFTtrial

or

Sound on Right

GO

or

*

*

2

34

5

1

1

Functionality File

Trial structure make_and_upload_state_matrix.m

2 Trial sides SidesSection.m

3 Variable Poke Delay VpdSection.m

4 Sounds (frequency? Duration? Localisation?)

ChordSection.m

5 Tracking correct / incorrect trials RewardsSection.m

Page 20: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Directory view

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

• Specialised role within a trial

• Initialise part ofmain GUI

• Own a set of SPHs

• Pass them to other functions

1

Functionality File

Trial structure make_and_upload_state_matrix.m

2 Trial sides SidesSection.m

3 Variable Poke Delay VpdSection.m

4 Sounds (frequency? Duration? Localisation?)

ChordSection.m

5 Tracking correct / incorrect trials

RewardsSection.m

Data management:Load/SaveData

Load/SaveSettingsInitSaving

Water dispensing: InitWaterValves

Page 21: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

The main GUI

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

• Specialised role within a trial

• Initialise part ofmain GUI

• Own a set of SPHs

• Pass them to other functions

Interaction of many specialised files

Page 22: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Example of a barebones specialised file:

/private/InitSaving.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

• Specialised role within a trial

• Initialise part ofmain GUI

• Own a set of SPHs

• Pass them to other functions

Page 23: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

The constructor: A scaffold for the cascade of dependent SPHs

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

P Cstate35.mclose.m

SavingWvalves

• Specialised role within a trial

• Initialise part ofmain GUI

• Own a set of SPHs

• Pass them to other functions

Page 24: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

The constructor: A scaffold for the cascade of dependent SPHs

P Cstate35.mclose.m

Special file1

InitWaterValves

InitSaving

SidesSection

ChordSection

VpdSection

TimesSection

make_and_upload_state_matrix

Sides information

Future poke delays

Penalty times& sounds

Cue, GO durations

Dispense timesfor rewards

Special file2

Page 25: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Good! Everything’s in

one big window!

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 26: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Creative uses of SoloParamHandles• UI elements

• Scalars and arraystracking parameters for past trials, setting for future trials

• Axes all plots

• Figures reducing workspace clutter

• Any Matlab variables!core plot objects (line, patch, text),cell arrays storing trial eventspairs storing state matrix descriptionsother objects (advanced)

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 27: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Checklist for adding SPH

1. Create

2. Set callbacksCall all methods affected by change

3. Update within or after a trial?• Write code for ‘update’ action(e.g. updating a plot, updating number of successes)

• Add to trial_finished_actions or trial_update_actions

Page 28: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Mini-Example 1: Making and updating

plots with SPH

Page 29: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

A plot to decide trial sides

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 30: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

1. Create: SidesSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

• Specialised role within a trial

• Initialise part ofmain GUI

• Own a set of SPHs

• Pass them to other functions

value() call of SPHs of graphic objects returns handles

Line

Text

Axes

Matlab graphic objects contained in SPH:

Page 31: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

2. Set callbacks

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

………

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

SidesSection.m

Page 32: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

3. Ensure update within/after trial

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Recall:trial_finished_actions is processed by state35.m at the end of every trial

The main protocol file calls state35.m

Page 33: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Mini-Example 2: SPHs that store figure

handles

Page 34: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Collapsible windows: A cleaner workspaceChordSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

What appears on the main protocol figure

Collapsible window

Page 35: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Making collapsible windows: ChordSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Value(fig) returns a figure handle

“figure” makes a figure current

Remember to update coordinates

Store fig handle to main figure

Initialise new mini-figure

Adjust its properties

Return control to the main figure after setup

Page 36: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Collapsible windows: ChordSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

All chord parameters are in figure myfig

#1: Create controls in mini-figure

#2: Set callback to hide/show figure in main window

Page 37: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Making collapsible windows: ChordSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 38: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Collapsible windows: A cleaner workspaceChordSection.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

What appears on the main protocol figure

All initialised chord parameters are in the

myfig figure

Page 39: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Bells, whistles, and a few useful things ...

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Flow of control SoloParamHandles SoloFunctionsCreating UI el’ts

(EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Managing trial dataSaving and Loading

Making and sending sounds

Naming states

The event cell array

Page 40: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Loading and Saving: UI elements

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

InitSaving.m

Scripts to load/save data/settings: *_soloparamvalues.m: Loads/saves data

*_solouiparamvalues.m: Loads/saves settings

* = load or save

Page 41: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Loading …

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Since SPH values have changed, make a callback!

LoadData.m LoadSettings.m

Page 42: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

… and saving

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

SaveData.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Recap: Directory view

Page 43: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

load_datafile(ratname, taskname, date) returns:

• saved_history: cell arrays of trial-by-trial settings

• saved: arrays that have information across all trials (e.g. side_list)

• fig_position: Position of the main protocol figure

• saved_autoset: strings of autoset commands

Path to saved files: (root-dir)/SoloData/

Data files: Data/(ratname)/data_taskname_datef.matSettings files: Settings/(ratname)/settings_taskname_datef.mat

Using data files

Page 44: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Using data files (cont’d)

• Naming convention:data_struct.SoloFunction_name_SPH_name

e.g. saved.SidesSection_side_list

e.g. saved_history.make_and_upload_state_matrix_badboy_sound

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Example #1: Snapshots of event history of trial #5

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Example #2: Trial sides for trials #5-10

Page 45: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

How is trial information stored?

1. Values of all SPHs : push_history

2. State matrix: RealTimeStates

3. Events during the trial: LastTrialEvents

Page 46: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

push_history: Storing SPH values on a trial-by-trial basis

Pop Quiz: You want to store SPH values on a trial-by-trial basis. Now what?

Hint: The call to make is push_history(class(obj)). The question is, where?

Mystery to be solved during the tutorial …

Page 47: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Setting: make_and_upload_state_matrix.m

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

RealTimeStates: Mapping names to state numbers

RealTimeStates: a struct (sets of key-value pairs)Key: state nameValue: Corresponding state numbers (vector)

… and what it looks like:

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 48: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Examples of uses for

RealTimeStates: Mapping names to state numbers

Easier time building analysis tool:(e.g. Distribution of # timeouts across the session)

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Extensions: Colour-code states to monitor current and past activity

during the session

Page 49: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

LastTrialEvents: Storing event history

Pop Quiz: The pokes plot (previous page) updates

during a trial. The pokes plot uses LastTrialEvents. How would you find out where

LastTrialEvents is updated?

Mystery to be solved during the tutorial …

Page 50: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

LastTrialEvents: Storing event historyStructure: Matrix of e rows and 3 columns, e : Number of events during the trial

Columns: 1) State number in which event occurred2) Event number (default: 1-Cin, 2-Cout, 3-Lin, etc.,)3) Time from session start

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Snapshots of event history of trial #5

Page 51: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Inhale. Exhale.Repeat.

Reviewing Concepts

Page 52: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Core concepts: SoloWaterValve

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Flow of control SoloParamHandles SoloFunctionsCreating UI el’ts

(EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Page 53: Protocol-writing with  the Solo system: The Basics:  The Water Valve Calibrator

Layer II: Localisation sampling

Finding protocol dirs

Interaction between protocol.m and protocolobj.m

End of trial actions (state35.m)

Trial update actions (update.m)

Flow of control SoloParamHandles SoloFunctionsCreating UI el’ts

(EditParam, ToggleParam)

Creating non-UI elements (trial_finished_actions)

Get/set values

Callbacks

Optional parameters(label, tooltipstring)

Declaring SoloFunction

Setting r/w variables

Setting read-only vars

GetSoloFunctionArgs !

switch-case stmts

Managing trial dataSaving and Loading

Making and sending sounds

Naming states

The event cell array