1 / 53

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

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.

oihane
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Getting your Bearings Path to protocol executable: (root-dir)/ExperPort/Protocols/ Protocol object:protocolnameobj.m Object files in: (1)/@protocolnameobj.m

  3. P C solo_watervalve.m state35.m close.m Call to constructor (update files) close.m state35.m The protocol file

  4. P C Constructor state35.m close.m Matlab object creation code Delete previous SoloParamHandles (SPH) associated with the object Protocol-nonspecific variables Declaring a function that uses SPHs

  5. P C Constructor: Adding UI elements state35.m close.m

  6. Previewing Greatness to Come …

  7. P C Constructor:Adding UI elements (2) state35.m close.m • Optional UI features (labels, tooltips) • Positioning

  8. P C Constructor:Add Dispense Control state35.m close.m Look at HandleParam/*.m for available featurese.g. HandleParam/EditParam.m

  9. P C The constructor initialisesthe state matrix state35.m close.m stm_script Declaring … … and callingSoloFunctions The constructor initialises all peripheral sections of a protocol. e.g. Deciding trial sides (SidesSection.m) Constructing sounds (ChordSection.m)

  10. P C Programming the state matrix:Skeleton for specialised files state35.m close.m stm_script How a SoloFunction gets registered SPHs during each call Adding UI elements to the main figure (controlled by this script)

  11. P C state35.m close.m stm_script Using read-only args Using flags set in mystartup.m Setting a value: myvar.value = 22/7;Getting a value: value(myvar)

  12. P C state35.m: Executed at the end of trials state35.m close.m Constructor stm_script trial_finished_actions is an SPH!

  13. P C Not just a pretty face: Callbacks state35.m close.m stm_script Constructor: Setting a callback … … and executing it. Not returning after a callback segment => extra state matrix generations!!!

  14. Finding protocol dirs Interaction between protocol.m and protocolobj.m End of trial actions (state35.m) Trial update actions (update.m) Breathe.Review the Concepts. Flow of control SoloParamHandles SoloFunctions Creating 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

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

  16. Protocol-writing with the Solo system: Higher, Faster, Stronger: Localisation Sampling (Locsamp)

  17. Finding protocol dirs Interaction between protocol.m and protocolobj.m End of trial actions (state35.m) Trial update actions (update.m) Bells, whistles, and a few useful things ... Flow of control SoloParamHandles SoloFunctions Creating 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

  18. Bells, whistles, and a few useful things ... Flow of control SoloParamHandles SoloFunctions 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, … Declaring SoloFunction Setting r/w variables Setting read-only vars GetSoloFunctionArgs ! switch-case stmts Managing trial dataSaving and LoadingNaming statesThe event cell array

  19. Localisation Sampling: Decomposing a trial 5 4  3  * or LEFTtrial Sound on Left GO 1 2   * or RIGHTtrial GO Sound on Right Functionality File 1 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 RewardsSection.m Tracking correct / incorrect trials

  20. Directory view Data management:Load/SaveDataLoad/SaveSettingsInitSaving Water dispensing:InitWaterValves • Specialised role within a trial • Initialise part ofmain GUI • Own a set of SPHs • Pass them to other functions Functionality File Trial structure 1 make_and_upload_state_matrix.m Trial sides 2 SidesSection.m Variable Poke Delay 3 VpdSection.m Sounds (frequency? Duration? Localisation?) 4 ChordSection.m 5 Tracking correct / incorrect trials RewardsSection.m

  21. The main GUI Interaction of many specialised files • Specialised role within a trial • Initialise part ofmain GUI • Own a set of SPHs • Pass them to other functions

  22. Example of a barebones specialised file:/private/InitSaving.m • Specialised role within a trial • Initialise part ofmain GUI • Own a set of SPHs • Pass them to other functions

  23. P C The constructor:A scaffold for the cascade of dependent SPHs state35.m close.m SavingWvalves • Specialised role within a trial • Initialisepart ofmain GUI • Own a set of SPHs • Pass them to other functions

  24. P C The constructor:A scaffold for the cascade of dependent SPHs state35.m close.m Special file1 Special file2 Dispense timesfor rewards InitWaterValves InitSaving Future poke delays VpdSection TimesSection Penalty times& sounds SidesSection Sides information ChordSection Cue, GO durations make_and_upload_state_matrix

  25. Good! Everything’s in one big window!

  26. UI elements Scalars and arrays tracking parameters for past trials, setting for future trials Axes all plots Figuresreducing workspace clutter Any Matlab variables! core plot objects (line, patch, text), cell arrays storing trial eventspairs storing state matrix descriptions other objects (advanced) Creative uses of SoloParamHandles

  27. Create Set callbacksCall all methods affected by change Update within or after a trial? Write code for ‘update’ action (e.g. updating a plot, updating number of successes) Add to trial_finished_actionsor trial_update_actions Checklist for adding SPH

  28. Mini-Example 1: Making and updating plots with SPH

  29. A plot to decide trial sides

  30. 1.Create:SidesSection.m Matlab graphic objects contained in SPH: Axes Line Text • 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

  31. 2. Set callbacks SidesSection.m … … …

  32. 3. Ensure update within/after trial Recall:trial_finished_actions is processed by state35.m at the end of every trial The main protocol file calls state35.m

  33. Mini-Example 2: SPHs that store figure handles

  34. Collapsible windows: A cleaner workspaceChordSection.m What appears on the main protocol figure Collapsible window

  35. Making collapsible windows: ChordSection.m Store fig handle to main figure Initialise new mini-figure Adjust its properties Return control to the main figure after setup Value(fig) returns a figure handle “figure” makes a figure current Remember to update coordinates

  36. Collapsible windows: ChordSection.m #1: Create controls in mini-figure #2: Set callback to hide/show figure in main window All chord parameters are in figure myfig

  37. Making collapsible windows: ChordSection.m

  38. Collapsible windows: A cleaner workspaceChordSection.m What appears on the main protocol figure All initialised chord parameters are in the myfig figure

  39. Finding protocol dirs Interaction between protocol.m and protocolobj.m End of trial actions (state35.m) Trial update actions (update.m) Bells, whistles, and a few useful things ... Flow of control SoloParamHandles SoloFunctions Creating 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 LoadingMaking and sending soundsNaming statesThe event cell array

  40. Loading and Saving: UI elements InitSaving.m Scripts to load/save data/settings: *_soloparamvalues.m: Loads/saves data *_solouiparamvalues.m: Loads/saves settings * =load or save

  41. Loading … LoadSettings.m LoadData.m Since SPH values have changed, make a callback!

  42. … and saving SaveData.m Recap: Directory view

  43. Using data files • 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

  44. 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 Using data files (cont’d) Example #2: Trial sides for trials #5-10 Example #1: Snapshots of event history of trial #5

  45. Values of all SPHs : push_history State matrix: RealTimeStates Events during the trial: LastTrialEvents How is trial information stored?

  46. 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 …

  47. RealTimeStates:Mapping names to state numbers Setting: make_and_upload_state_matrix.m … and what it looks like: RealTimeStates:a struct (sets of key-value pairs)Key: state nameValue: Corresponding state numbers (vector)

  48. Examples of uses for RealTimeStates:Mapping names to state numbers Easier time building analysis tool:(e.g. Distribution of # timeouts across the session) Extensions: Colour-code states to monitor current and past activity during the session

  49. 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 …

  50. LastTrialEvents:Storing event history Structure: Matrix of e rows and 3 columns,e : Number of events during the trialColumns: 1) State number in which event occurred2) Event number (default: 1-Cin, 2-Cout, 3-Lin, etc.,)3) Time from session start Snapshots of event history of trial #5

More Related