Difference between revisions of "Plugins-sqlsummary"

From Bcontrol
(@sqlsummary - sendsummary)
Line 10: Line 10:
 
   'sides' get_val('previous_sides');...
 
   'sides' get_val('previous_sides');...
 
   'endtime' datestr(now,13);...
 
   'endtime' datestr(now,13);...
   'sessiondate' datestr(now,29);...
+
   'sessiondate' datestr(now,29);...
 
   'hostname' get_val('SavingSection_hostname');...
 
   'hostname' get_val('SavingSection_hostname');...
   'experimenter'     get_val('SavingSection_experimenter');...
+
   'experimenter' get_val('SavingSection_experimenter');...
   'ratname'           get_val('SavingSection_ratname');...
+
   'ratname' get_val('SavingSection_ratname');...
 
   'n_done_trials' get_val('n_done_trials');...
 
   'n_done_trials' get_val('n_done_trials');...
 
   'protocol' class(obj);...
 
   'protocol' class(obj);...
   'protocol_data'     'NULL'
+
   'protocol_data' 'NULL'
 
   }; parseargs(varargin, pairs);
 
   }; parseargs(varargin, pairs);
 
+
 
 
 
 
   %% Get the relevant SPH
 
   %% Get the relevant SPH
 
    
 
    
Line 28: Line 27:
 
</tt>
 
</tt>
  
 +
With no extra arguments sendsummary tries to generate a summary making the following assumptions:
 +
# There is a SoloParamHandle named '''hit_history''' that contains a numeric array containing a '''1''' for every correct trial, a '''0''' for incorrect trials and NaN for trials that should not be treated as correct or incorrect.
 +
# There is a SoloParamHandle named '''previous_sides''' that contains a string of <tt>l</tt>'s and <tt>r</tt>'s to indicate whether the correct response was towards the left or the right.
 +
# That the @saveload plugin is being used.
 +
 +
You can still use this function if the above assumptions are false.  In this case, pass in the appropriate information as parameters.
  
 +
For example,  you don't have an SPH called '''previous_sides''' but rather you store this information in '''sides_history''' and it is made up of -1's and 1's.  In this case, write a little bit of code to transform your '''sides_history''' into  a string of <tt>l</tt>'s and <tt>r</tt>'s and then send the string as an argument to sendsummary.
 +
  lets={'l' 'c' 'r'};
 +
  sides=cell2mat(lets(sides_history+2));
 +
  sendsummary(obj, 'sides',sides)
 +
 +
The other feature worth noting is the '''protocol_data''' field.  You can build any struct or cell array you like and pass it in.  For example:
 +
  pd.context=value(previous_cntxt);
 +
  pd.blocks=value(block_history);
 +
  pd.sides=value(previous_sides);
 +
  pd.gotit=value(gotit_history);
 +
  pd.hit=value(hit_history);
 +
  pd.RT=value(RT);
 +
  sendsummary(obj,'protocol_data',pd)
  
 +
The advantage of this is that you can then write code that grabs the '''protocol_data''' for a specific set of sessions and runs through some analysis without having to load the entire data file for each session.  This could significantly simplify analysis of behavior and replace '''hunt'''.
 +
The only constraint is that you cannot use sparse matrices in this field.  This is a limitation of [http://sourceforge.net/projects/mym mym].
 +
  
NOTE: Currently this functionality is only supported for the Brody Lab.  Users outside of the brody lab must set up a mysql server for their lab and replace the *bdata.p* file found in <tt>ExperPort/MySQLUtility</tt> using *bdata_template.m*.  
+
NOTE: Currently this functionality is only supported for the Brody Lab.  Users outside of the brody lab must set up a mysql server for their lab and replace the '''bdata.p''' file found in <tt>ExperPort/MySQLUtility</tt> using '''bdata_template.m'''.  
  
 
[[User:Jerlich|Jerlich]] 20:23, 29 December 2007 (EST)
 
[[User:Jerlich|Jerlich]] 20:23, 29 December 2007 (EST)

Revision as of 01:52, 30 December 2007

@sqlsummary - sendsummary

This plugin lets you call a single command:

 sendsummary(obj);

that will send a summary of your session to a mysql server.

 function [err]=sendsummary(obj, varargin)
 pairs = { ...
 		'hits'				get_val('hit_history');...
 		'sides'				get_val('previous_sides');...
 		'endtime'			datestr(now,13);...
 		'sessiondate'			datestr(now,29);...
 		'hostname'			get_val('SavingSection_hostname');...
 		'experimenter'		get_val('SavingSection_experimenter');...
 		'ratname'			get_val('SavingSection_ratname');...
 		'n_done_trials'		get_val('n_done_trials');...
 		'protocol'			class(obj);...
 		'protocol_data'		'NULL'
 		}; parseargs(varargin, pairs);
 %% Get the relevant SPH
 
 total_correct=nanmean(hits);
 right_correct=nanmean(hits(sides=='r'));
 left_correct=nanmean(hits(sides=='l'));
 percent_violations=mean(isnan(hits));

With no extra arguments sendsummary tries to generate a summary making the following assumptions:

  1. There is a SoloParamHandle named hit_history that contains a numeric array containing a 1 for every correct trial, a 0 for incorrect trials and NaN for trials that should not be treated as correct or incorrect.
  2. There is a SoloParamHandle named previous_sides that contains a string of l's and r's to indicate whether the correct response was towards the left or the right.
  3. That the @saveload plugin is being used.

You can still use this function if the above assumptions are false. In this case, pass in the appropriate information as parameters.

For example, you don't have an SPH called previous_sides but rather you store this information in sides_history and it is made up of -1's and 1's. In this case, write a little bit of code to transform your sides_history into a string of l's and r's and then send the string as an argument to sendsummary.

 lets={'l' 'c' 'r'};
 sides=cell2mat(lets(sides_history+2));
 sendsummary(obj, 'sides',sides)

The other feature worth noting is the protocol_data field. You can build any struct or cell array you like and pass it in. For example:

 pd.context=value(previous_cntxt);
 pd.blocks=value(block_history);
 pd.sides=value(previous_sides);
 pd.gotit=value(gotit_history);
 pd.hit=value(hit_history);
 pd.RT=value(RT);
 sendsummary(obj,'protocol_data',pd)

The advantage of this is that you can then write code that grabs the protocol_data for a specific set of sessions and runs through some analysis without having to load the entire data file for each session. This could significantly simplify analysis of behavior and replace hunt. The only constraint is that you cannot use sparse matrices in this field. This is a limitation of mym.


NOTE: Currently this functionality is only supported for the Brody Lab. Users outside of the brody lab must set up a mysql server for their lab and replace the bdata.p file found in ExperPort/MySQLUtility using bdata_template.m.

Jerlich 20:23, 29 December 2007 (EST)