User Tools

Site Tools


plotcurves

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plotcurves [2010/06/19 18:16] – typo (stupid!) jochenplotcurves [2011/05/27 15:54] (current) – added additional keyboard commands jochen
Line 24: Line 24:
  
 % this filters channel 1 into a new channel (10) % this filters channel 1 into a new channel (10)
-% all parameters are default, the post-filtering cut-off is set to 0.5s +% all parameters are default, the post-filtering cut-off is set to 0.2s 
-gsr.Filter(1, struct('dest', 10, 'post', 0.5));</code>+gsr.Filter(1, struct('dest', 10, 'post', 0.2));</code>
  
 ===== Function reference ('help plotcurves') ===== ===== Function reference ('help plotcurves') =====
Line 36: Line 36:
         obj         xff object with plotable data or SxC double data         obj         xff object with plotable data or SxC double data
         opts        optional settings         opts        optional settings
 +         .cuediff   difference between cue and onset (only useful if
 +                    fixed interval!; default: -2)
          .curves    Cx2 cell array with names and a 1x3 double array          .curves    Cx2 cell array with names and a 1x3 double array
                     containing [channelnumber, onset, offset]                     containing [channelnumber, onset, offset]
-                    for multiple curves, the mean will be computed +                    for curves in a set, the mean/std. error is computed 
-         .freq      data sampling frequency (if not in object) +                    - onset and offset are given in seconds 
-         .resfreq   resampling frequency+         .dchannel  data channel (for onset detection, default: 1) 
 +         .dfilt     detection filter length (in seconds, default: 0.5) 
 +         .dminlat   minimum detection latency (after one point, def: 0.5) 
 +         .freq      data sampling frequency (if not in object, def: 100
 +         .ochannel  onset channel number (will add curves, default: []) 
 +         .odchannel original data channel (allows to filter effect) 
 +         .onsets    Ox1 onset vector in seconds 
 +         .owin      1x2 onset window in seconds (default: [-2, 18])
          .sets      Sx2 cell array with names and lists of curve indices          .sets      Sx2 cell array with names and lists of curve indices
-         .spot      Sx1 cell array with Cx1 X or Cx2 x/y coordinates +         .spot      Sx1 cell array with Cx1 X or Cx2 x/y time-points
-         .spotcol   Sx3 RGB color (either [0 .. 255] or [0 .. 1])+
          .spotnames Sx1 cell array with strings          .spotnames Sx1 cell array with strings
          .spottype  Sx1 cell array with either of          .spottype  Sx1 cell array with either of
-                    {'free'}, 'max', 'min', 'minmax'+                    'cue', {'free'}, 'max', 'min', 'minmax', 'onset'
          .var       1xV struct with fields          .var       1xV struct with fields
            .calc    either of 'dx', {'dy'}, 'mean', 'std', 'var', 'x', 'y'            .calc    either of 'dx', {'dy'}, 'mean', 'std', 'var', 'x', 'y'
 +           .name    variable name
            .spot    1x1 or 1x2 index into S            .spot    1x1 or 1x2 index into S
            .trans   apply additional transformation to each value, one of            .trans   apply additional transformation to each value, one of
                     {'none'}, 'log', 'log+1', 'sqrt'                     {'none'}, 'log', 'log+1', 'sqrt'
-         .varnames   
    
   Output fields:   Output fields:
Line 59: Line 67:
         varc        computed variables         varc        computed variables
         spot        updated spots         spot        updated spots
-        sets        updates sets (new indices)</file>+        sets        updates sets (new indices) 
 +  
 +  Note: where appropriate, the options are taken from obj.RunTimeVars 
 +        if not specified in the call!</file>
  
 ===== GUI ===== ===== GUI =====
 This function has its own GUI. Once called (with appropriate parameters), the following dialog will open: This function has its own GUI. Once called (with appropriate parameters), the following dialog will open:
 +
 +{{:plotcurves_ui_initialview.png|plotcurves UI (with automatic delay/peak detection, see below)}}
 +
 +The dialog has the following controls:
 +  * curve filtering setting (various filter lengths)
 +  * curve (onset-based window) selection
 +  * set-mean standard error patch switch (not yet implemented)
 +  * use-curve checkbox (selection of curves is stored in the object)
 +  * variables (edit boxes for manual override)
 +  * accept button (same as close dialog)
 +  * force-spot-on-curve checkbox
 +  * actual curve/spot plot
 +  * overview plot
 +
 +Additionally the following keyboard commands are supported (when no UI control has the focus!):
 +  * cursor up/down -> select previous/next curve in list
 +  * ''SHIFT'' + cursor up/down/left/right -> move plot window along X/Y axis (0.1 of window size)
 +  * '''d''' key -> decrease zoom (de-magnify)
 +  * '''f''' key -> toggle force-to-curve checkbox
 +  * '''i''' / '''o''' keys -> toggle whether this curve (onset) is included (i) or omitted (o) from averages
 +  * '''m''' key -> increase zoom (magnify)
 +  * '''p''' key -> places a currently highlighted marker at a peak (max or min, depending on data)
 +  * '''r''' key -> reset axes limits (to initial curve setting)
 +  * '''u''' key -> toggle use-curve checkbox
 +
 +The curve/spot plot has the following mouse-based functions:
 +  * a cursor (crosshair) is moving along with the mouse pointer
 +  * when the cursor gets close to one of the defined spots, the closest spot will become movable (indicated by a dashed line)
 +  * pressing and holding the mouse button and then moving the mouse will either
 +    * move one of the spots (if the cursor was close enough to catch it), the spot can only be moved between the window axes limits and any neighboring spots (e.g. the peak spot can not be moved in front of the onset or delay spots!)
 +    * create a zoom-box (which grows/shrinks as long as the mouse button remains held); once the mouse button is released, the axes limits will be changed to the zoom-box limits (to unzoom, use the ''d'' or ''r'' keys)
 +
 +Operating the dialog is straight forward:
 +  * select the curve to work on (either clicking into the list or using the cursor up/down keys)
 +  * if this curve is not usable, deselect it (either by unchecking the use-curve box or by pressing the ''u'' key if the box is checked)
 +  * in case the auto-detection worked well, continue with the next curve
 +  * otherwise move, for instance, the latency (delay) and peak spots to their approximate location
 +  * zoom in each spot's location and fine-tune the value
 +    * if you wish to free the spot from the curve, uncheck the force-to-curve box (temporarily at least)
 +    * **important: holding the shift key while moving a spot allows you to force it to the original data instead of the filtered data!**
 +  * check that all variables (amplitude, etc.) are as desired and adapt if necessary
 +  * move on to the next curve
 +
 +After all curves have been inspected/worked on, simply click on ''Accept curves and variables'' or close the dialog (no difference in behavior).
  
 ===== Usage ===== ===== Usage =====
Line 115: Line 170:
  
 <code matlab plotcurves_withonsets.m>% data is in object gsr and already preprocessed <code matlab plotcurves_withonsets.m>% data is in object gsr and already preprocessed
-% we define three spots of interest:+for this example we define four (!) spots of interest: 
 +% - cue (time of stimulus minus 2 secs)
 % - onset (time of stimulus), % - onset (time of stimulus),
 % - delay of response (minimum before peak), % - delay of response (minimum before peak),
 % - and peak of response (amplitude) % - and peak of response (amplitude)
-spotnames = {'onset', 'delay', 'peak'}; +spotnames = {'cue', 'onset', 'delay', 'peak'}; 
-spottype = {'onset', 'min', 'max'};+spottype = {'cue', 'onset', 'min', 'max'};
  
 % the spot values are set to empty arrays with size 0x2! % the spot values are set to empty arrays with size 0x2!
 % this tells plotcurves to autodetect... % this tells plotcurves to autodetect...
-spot = {zeros(0,2), zeros(0,2), zeros(0, 2)};+spot = {zeros(0,2), zeros(0,2), zeros(0,2), zeros(0, 2)}
 + 
 +% then we define the variables of interest: 
 +% NOTE: since we have a CUE spot, all spot indices shift by one! 
 +% - Latency (defined as x-diff between onset and delay) 
 +% - Response time (defined as x-diff between delay and peak) 
 +% - Base amplitude (defined as y-value at delay) 
 +% - Peak amplitude (defined as y-value at peak) 
 +% - Peak-to-peak response amplitude (defined as y-diff between delay and peak) 
 +% additionally, we define that for the response amplitude, the log+1 transform 
 +% should be applied after we're done 
 +vars = struct( ... 
 +    'name', {'Latency', 'Resp. time', 'Base ampl.', 'Peak ampl.', 'Resp. ampl.'}, ... 
 +    'calc', {'dx', 'dx', 'y', 'y', 'dy'}, ... 
 +    'spot', {[2, 3], [3, 4], [3], [4], [3, 4]}, ... 
 +    'trans', {'none', 'none', 'none', 'none', 'log+1'});
  
 % re-using the variables definition from above, options: % re-using the variables definition from above, options:
Line 130: Line 201:
 % - original data is in channel 1 (pre-filter) % - original data is in channel 1 (pre-filter)
 % - onsets are coded in channel 8 (0Volts nothing, 5 Volts boxes) % - onsets are coded in channel 8 (0Volts nothing, 5 Volts boxes)
 +% - cue onffset is 2 seconds
 +% - thus, the window is increased! [-4, 20]
 % - variables and spots as defined % - variables and spots as defined
 pcopts = struct( ... pcopts = struct( ...
Line 135: Line 208:
     'odchannel', 1, ...     'odchannel', 1, ...
     'ochannel',  8, ...     'ochannel',  8, ...
 +    'cuediff',   2, ...
 +    'owin',      [-4, 20],...
     'var',       vars, ...     'var',       vars, ...
     'spot',      {spot}, ...     'spot',      {spot}, ...
Line 142: Line 217:
 % now we call plotcurves % now we call plotcurves
 plotcurves(gsr, pcopts);</code> plotcurves(gsr, pcopts);</code>
 +
 +===== Output =====
 +The function outputs the following variables:
 +  * sel (boolean vector with curve selection, copied from use-curve checkbox)
 +  * varc (number-of-curves - by - number-of-variables double table)
 +  * spot (1 - by - number-of-spots cell array with coordinates of spots)
 +  * sets (updated list of sets, that is to say with correct indices, only if sets defined!)
 +
 +In addition to this, the final options and configuration (when the dialog was closed) is stored in the gsr object under ''.RunTimeVars.plotcurves''.
plotcurves.1276971393.txt.gz · Last modified: 2010/06/19 18:16 by jochen