Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions +eui/SignalsExpPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
% false only those in the list are shown, when false those in the list
% are hidden
Exclude = true
% Flag for formating Signals updates in the InfoField Labels
FormatLabels = false
% The total number of
NumSignalUpdates = 0
% containers.Map of InfoGrid ui labels mapped to their corresponding
Expand Down Expand Up @@ -144,6 +146,27 @@ function event(obj, name, t)
end
end

function fieldCtrl = addInfoField(obj, name, value)
% ADDINFOFIELD Add new event info field to InfoGrid
% Adds a given field to the grid and adjusts the total height of the
% grid to accomodate all current fields. If the FormatLabels
% property is true, the updates are formatted with a space beween
% capital letters.
%
% Example:
% obj.FormatLabels = true;
% obj.addInfoField('events.newTrial', 0)
% obj.InfoLabels(1).String % Formatted as 'New trial'
%
% See also eui.ExpPanel/addInfoField
if any(name=='.') && obj.FormatLabels == true
name = extractAfter(name, '.'); % Take substring after dot
name = lower(regexprep(name, '([a-z])([A-Z])', '$1 $2')); % Spaces
name(1) = upper(name(1)); % Capitalize first letter
end
fieldCtrl = addInfoField@eui.ExpPanel(obj, name, value);
end

function processUpdates(obj)
% PROCESSUPDATES Process all accumulated signals event updates
% Process the signals events that have occured since the method was
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Starting after Rigbox 2.2.0, this file contains a curated, chronologically order
- correct behaviour when listening to already running experiments `32a2a17` 2019-12-18
- added support for remote error ids in srv.StimulusControl `9d31eea` 2019-11-27
- added tests for eui.ExpPanel `572463c` 2020-01-28
- added tests for *paramProfile functions + no error when saving into new repo `72b04fa` 2010-01-30
- added tests for *paramProfile functions + no error when saving into new repo `72b04fa` 2020-01-30
- added FormatLabels flag to eui.SignalsExpPanel `c5794a8` 2020-02-03

## [2.4.1]

Expand Down
14 changes: 10 additions & 4 deletions docs/html/using_ExpPanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>Introduction</title><meta name="generator" content="MATLAB 9.6"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2019-12-18"><meta name="DC.source" content="using_ExpPanel.m"><style type="text/css">
--><title>Introduction</title><meta name="generator" content="MATLAB 9.6"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2020-01-31"><meta name="DC.source" content="using_ExpPanel.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

html { min-height:100%; margin-bottom:1px; }
Expand Down Expand Up @@ -82,7 +82,7 @@
| NB: All subclasses should chain a call to superclass update)
eui._ExpPanel/processUpdates (method only present in SignalExpPanel
| classes)
eui.ExpPanel/addInfoField (adds any new Signals event fields)</pre><h2 id="9">exp.SignalsExpPanel</h2><p>The subclass, <tt>eui.SignalsExpPanel</tt>, is the default class for Signals Experiments. In this class, all Signals updates are shown as InfoFields whose colours pulse green as the values update. The signals sent from the stimulus computer includes events, parameters, inputs and outputs signals. The 'Trial count' field reflects the value of events.trialNum.</p><p>The UpdatesFilter property contains a list of signals updates to create a label for, or if Exclude == true, all signals names in this list are ignored. This is useful when your events structure is large and you don't wish to see all of them during the experiment.</p><p><tt>exp.SignalsExp</tt> periodically(1) sends signals event updates to the <tt>MC</tt> computer(2). These updates trigger the expUpdate method which stores the updates in the SignalUpdates property. All updates in this property are delt with and removed by the processUpdates method, which is called via the update by the <tt>MC</tt> Refresh timer once per 100ms(3).</p><p>The SignalUpdate property is a struct with the following fields:</p><div><ul><li>name - The name of the signal, e.g. 'events.newTrial'</li><li>value - The value of the signal.</li><li>timestamp - a date vector of the date and time when the signal was queued. (NB: This is in the system time of the remote rig and depends on its timezone. These timestamps aren't as precise as those in the block file).</li></ul></div><h2 id="10">Custom Signals ExpPanels</h2><p>Below is a list of steps to follow when creating a custom Signals ExpPanel, for an example of this see advancedChoiceWorldExpPanel(4):</p><div><ol><li>Subclass <tt>eui.SignalsExpPanel</tt> Subclassing means you will inherit all of the methods and properties found in <tt>eui.SignalsExpPanel</tt> and <tt>eui.ExpPanel</tt>.</li><li>Add any extra properties specific to your ExpPanel For example if you're creating a new plot you may wish to store the axes in a property. (c.f. PsychometricAxes in advancedChoiceWorldExpPanel)</li><li>Add a constructor to initialize any properties if required Chain a call to the superclass method like so: obj = <a href="mailto:obj@eui.SignalsExpPanel">obj@eui.SignalsExpPanel</a>(parent, ref, params, logEntry);</li><li>Add a build method to initialize an axes or extra UI elements. Typically everything built here will use obj.CustomPanel as the parent container. This method must have protected access. Chain a call to the superclass method first: <a href="mailto:build@eui.SignalsExpPanel">build@eui.SignalsExpPanel</a>(obj, parent);</li><li>Add a processUpdates to deal with your experiment-specific events. Here you can add code to update plots, etc. based on the event updates. This method must have protected access. Instead of chaining a call, copy the code from eui.SignalsExpPanel/processUpdates directly and use it as a template for your own functions.</li></ol></div><p>There are some useful superclass methods that are useful to keep in mind:</p><div><ul><li>mergeTrialData - Update the local block structure with data from the last trial. This is found in eui.ExpPanel.</li><li>newTrial - This doesn't do anything in the superclasses but is a good place to put code that should be executed at events.newTrial. Call it from processUpdates.</li><li>trialCompleted - As with newTrial, this could be used as a place for code that runs after e.g. an outputs or feedback event.</li><li>expStopped - Useful for executing code when the session ends. Must chain a call to superclass here.</li><li>expStarted - See above.</li><li>cleanup - Place code here for e.g. stopping timers, clearing listeners, etc.</li></ul></div><p>Here are some useful properties to be aware of:</p><div><ul><li>Parameters - A copy of that experiment's paramStruct.</li><li>UpdatesFilter - As mentioned above, this holds a cell array of events you wish to ignore/include. It's behaviour depends on whether the Exclude property is true or false.</li><li>RecentColour - The colour of recently updated Signals update events in the InfoGrid. This can be changed dynamically during the session, for instance could turn red as the subject's performance declines or towards the end of the session.</li></ul></div><p>Finally there are some other useful untilities to be aware of:</p><div><ul><li>+psy - The <tt>psy</tt> package contains useful functions for plotting psychometrics and producing fits.</li><li><tt>bui.Axes</tt> - This class provides a convenient way to interact with plotting axes. It's particularly useful if you wish to add multple elements to the same axes. Below is an example from advancedChoiceWorld:</li></ul></div><pre class="codeinput">obj.ExperimentAxes = bui.Axes(plotgrid); <span class="comment">% Create new bui.Axes object</span>
eui.ExpPanel/addInfoField (adds any new Signals event fields)</pre><h2 id="9">exp.SignalsExpPanel</h2><p>The subclass, <tt>eui.SignalsExpPanel</tt>, is the default class for Signals Experiments. In this class, all Signals updates are shown as InfoFields whose colours pulse green as the values update. The signals sent from the stimulus computer includes events, parameters, inputs and outputs signals. The 'Trial count' field reflects the value of events.trialNum.</p><p>The UpdatesFilter property contains a list of signals updates to create a label for, or if Exclude == true, all signals names in this list are ignored. This is useful when your events structure is large and you don't wish to see all of them during the experiment.</p><p><tt>exp.SignalsExp</tt> periodically(1) sends signals event updates to the <tt>MC</tt> computer(2). These updates trigger the expUpdate method which stores the updates in the SignalUpdates property. All updates in this property are delt with and removed by the processUpdates method, which is called via the update by the <tt>MC</tt> Refresh timer once per 100ms(3).</p><p>The SignalUpdate property is a struct with the following fields:</p><div><ul><li>name - The name of the signal, e.g. 'events.newTrial'</li><li>value - The value of the signal.</li><li>timestamp - a date vector of the date and time when the signal was queued. (NB: This is in the system time of the remote rig and depends on its timezone. These timestamps aren't as precise as those in the block file).</li></ul></div><p>When new updates are processed in <tt>eui.SignalsExpPanel</tt>, if an info field does not already exist, one is created. When the FormatLabels property is true the Signals update labels are formatted as sperate words. For example 'events.newTrial' is displayed as 'New trial'. This flag and others such as the UpdatesFilter can be set it your subclass constructor.</p><h2 id="10">Custom Signals ExpPanels</h2><p>Below is a list of steps to follow when creating a custom Signals ExpPanel, for an example of this see advancedChoiceWorldExpPanel(4):</p><div><ol><li>Subclass <tt>eui.SignalsExpPanel</tt> Subclassing means you will inherit all of the methods and properties found in <tt>eui.SignalsExpPanel</tt> and <tt>eui.ExpPanel</tt>.</li><li>Add any extra properties specific to your ExpPanel For example if you're creating a new plot you may wish to store the axes in a property. (c.f. PsychometricAxes in advancedChoiceWorldExpPanel)</li><li>Add a constructor to initialize any properties if required Chain a call to the superclass method like so: <tt>obj = <a href="mailto:obj@eui.SignalsExpPanel">obj@eui.SignalsExpPanel</a>(parent, ref, params, logEntry);</tt></li><li>Add a build method to initialize an axes or extra UI elements. Typically everything built here will use obj.CustomPanel as the parent container. This method must have protected access. Chain a call to the superclass method first: <tt>build@eui.SignalsExpPanel(obj, parent);</tt></li><li>Add a processUpdates to deal with your experiment-specific events. Here you can add code to update plots, etc. based on the event updates. This method must have protected access. Instead of chaining a call, copy the code from eui.SignalsExpPanel/processUpdates directly and use it as a template for your own functions.</li></ol></div><p>There are some useful superclass methods that are useful to keep in mind:</p><div><ul><li>mergeTrialData - Update the local block structure with data from the last trial. This is found in eui.ExpPanel.</li><li>newTrial - This doesn't do anything in the superclasses but is a good place to put code that should be executed at events.newTrial. Call it from processUpdates.</li><li>trialCompleted - As with newTrial, this could be used as a place for code that runs after e.g. an outputs or feedback event.</li><li>expStopped - Useful for executing code when the session ends. Must chain a call to superclass here.</li><li>expStarted - See above.</li><li>cleanup - Place code here for e.g. stopping timers, clearing listeners, etc.</li></ul></div><p>Here are some useful properties to be aware of:</p><div><ul><li>Parameters - A copy of that experiment's paramStruct.</li><li>UpdatesFilter - As mentioned above, this holds a cell array of events you wish to ignore/include. It's behaviour depends on whether the Exclude property is true or false.</li><li>RecentColour - The colour of recently updated Signals update events in the InfoGrid. This can be changed dynamically during the session, for instance could turn red as the subject's performance declines or towards the end of the session.</li></ul></div><p>Finally there are some other useful untilities to be aware of:</p><div><ul><li>+psy - The <tt>psy</tt> package contains useful functions for plotting psychometrics and producing fits.</li><li><tt>bui.Axes</tt> - This class provides a convenient way to interact with plotting axes. It's particularly useful if you wish to add multple elements to the same axes. Below is an example from advancedChoiceWorld:</li></ul></div><pre class="codeinput">obj.ExperimentAxes = bui.Axes(plotgrid); <span class="comment">% Create new bui.Axes object</span>
obj.ExperimentAxes.ActivePositionProperty = <span class="string">'position'</span>;
obj.ExperimentAxes.XTickLabel = []; <span class="comment">% Remove the X tick labels</span>
obj.ExperimentAxes.NextPlot = <span class="string">'add'</span>; <span class="comment">% Add new plots without clearing axes</span>
Expand Down Expand Up @@ -244,6 +244,12 @@
% queued. (NB: This is in the system time of the remote rig and depends on
% its timezone. These timestamps aren't as precise as those in the block
% file).
%
% When new updates are processed in |eui.SignalsExpPanel|, if an info field
% does not already exist, one is created. When the FormatLabels property
% is true the Signals update labels are formatted as sperate words. For
% example 'events.newTrial' is displayed as 'New trial'. This flag and
% others such as the UpdatesFilter can be set it your subclass constructor.

%% Custom Signals ExpPanels
% Below is a list of steps to follow when creating a custom Signals
Expand All @@ -257,12 +263,12 @@
% in a property. (c.f. PsychometricAxes in advancedChoiceWorldExpPanel)
% # Add a constructor to initialize any properties if required
% Chain a call to the superclass method like so:
% obj = obj@eui.SignalsExpPanel(parent, ref, params, logEntry);
% |obj = obj@eui.SignalsExpPanel(parent, ref, params, logEntry);|
% # Add a build method to initialize an axes or extra UI elements.
% Typically everything built here will use obj.CustomPanel as the parent
% container. This method must have protected access.
% Chain a call to the superclass method first:
% build@eui.SignalsExpPanel(obj, parent);
% |build@eui.SignalsExpPanel(obj, parent);|
% # Add a processUpdates to deal with your experiment-specific events.
% Here you can add code to update plots, etc. based on the event updates.
% This method must have protected access. Instead of chaining a call,
Expand Down
10 changes: 8 additions & 2 deletions docs/using_ExpPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
% queued. (NB: This is in the system time of the remote rig and depends on
% its timezone. These timestamps aren't as precise as those in the block
% file).
%
% When new updates are processed in |eui.SignalsExpPanel|, if an info field
% does not already exist, one is created. When the FormatLabels property
% is true the Signals update labels are formatted as sperate words. For
% example 'events.newTrial' is displayed as 'New trial'. This flag and
% others such as the UpdatesFilter can be set it your subclass constructor.

%% Custom Signals ExpPanels
% Below is a list of steps to follow when creating a custom Signals
Expand All @@ -141,12 +147,12 @@
% in a property. (c.f. PsychometricAxes in advancedChoiceWorldExpPanel)
% # Add a constructor to initialize any properties if required
% Chain a call to the superclass method like so:
% obj = obj@eui.SignalsExpPanel(parent, ref, params, logEntry);
% |obj = obj@eui.SignalsExpPanel(parent, ref, params, logEntry);|
% # Add a build method to initialize an axes or extra UI elements.
% Typically everything built here will use obj.CustomPanel as the parent
% container. This method must have protected access.
% Chain a call to the superclass method first:
% build@eui.SignalsExpPanel(obj, parent);
% |build@eui.SignalsExpPanel(obj, parent);|
% # Add a processUpdates to deal with your experiment-specific events.
% Here you can add code to update plots, etc. based on the event updates.
% This method must have protected access. Instead of chaining a call,
Expand Down
Loading