Home > data-import > main_make_inhand.m

main_make_inhand

PURPOSE ^

% Function to make all the main inhand variables for any experiment:

SYNOPSIS ^

function main_make_inhand(IDs, obj_list)

DESCRIPTION ^

% Function to make all the main inhand variables for any experiment:
 Inhand Variables Documentation:
 
 events:  Total number = 2(hands) X 2 (subject) X the 3(number of objects) 
 per trial, for 3 objects, then we would have 12 events.  For 5 object 
 experiments, we would have 20 events.
 event_inhand_[left/right]_obj[#]_[parent/child]

 sbf: no longer using event-based inhand as of exp 39, 5/2013
 
 
 cevents: Total number = 2(number of subjects with inhand data).  Events 
 can overlap within the cevent.  The categorical value is equal to the 
 object id that is held.  So, if a subject is holding object 1 between 
 5-15 seconds in the left hand, object 2 between 10-20 seconds in the 
 right hand, and object 3 between 18-25 seconds in the left hand, you 
 would have the following cevent:
 5    15    1
 10    20    2
 18    25    3
 cevent_inhand_[child/parent]
 
 
 cstreams:  Total number = 2(subjects) X the number of objects per trial, 
 for 3 objects, then we would have 6 cstreams and for 5 objects we would 
 have 10 cstreams.  The categorical values are:   1 = left hand, 
 2 = right hand, 3 = both hands.
 cstream_inhand_obj[#]_[parent/child]
 
 
 Total number of inhand variables = 20 for 3 objects per trial experiments.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function main_make_inhand(IDs, obj_list)
0002 %% Function to make all the main inhand variables for any experiment:
0003 % Inhand Variables Documentation:
0004 %
0005 % events:  Total number = 2(hands) X 2 (subject) X the 3(number of objects)
0006 % per trial, for 3 objects, then we would have 12 events.  For 5 object
0007 % experiments, we would have 20 events.
0008 % event_inhand_[left/right]_obj[#]_[parent/child]
0009 %
0010 % sbf: no longer using event-based inhand as of exp 39, 5/2013
0011 %
0012 %
0013 % cevents: Total number = 2(number of subjects with inhand data).  Events
0014 % can overlap within the cevent.  The categorical value is equal to the
0015 % object id that is held.  So, if a subject is holding object 1 between
0016 % 5-15 seconds in the left hand, object 2 between 10-20 seconds in the
0017 % right hand, and object 3 between 18-25 seconds in the left hand, you
0018 % would have the following cevent:
0019 % 5    15    1
0020 % 10    20    2
0021 % 18    25    3
0022 % cevent_inhand_[child/parent]
0023 %
0024 %
0025 % cstreams:  Total number = 2(subjects) X the number of objects per trial,
0026 % for 3 objects, then we would have 6 cstreams and for 5 objects we would
0027 % have 10 cstreams.  The categorical values are:   1 = left hand,
0028 % 2 = right hand, 3 = both hands.
0029 % cstream_inhand_obj[#]_[parent/child]
0030 %
0031 %
0032 % Total number of inhand variables = 20 for 3 objects per trial experiments.
0033 
0034 % -------------------------------------------------------------------
0035 % You need to set the following things per experiment:
0036 subs = cIDs(IDs);
0037 participant_list = {'child' 'parent'};
0038 
0039 if ~exist('obj_list', 'var') || isempty(obj_list)
0040     inhand_list ={'obj1','obj2','obj3'};
0041 else
0042     inhand_list = cell(numel(obj_list));
0043     for o = obj_list
0044         inhand_list{o} = sprintf('obj%d',o);
0045     end
0046 end
0047 
0048 hand_type = {'left','right'};
0049 
0050 % and either run this on every subject or select specific subjects:
0051 subj_list = subs;
0052 
0053 % -------------------------------------------------------------------
0054 
0055 % Go through each subject.
0056 for s = 1 : length(subj_list)
0057     
0058     subj = subj_list(s);
0059     
0060     % Go through each participant
0061     for p = 1 : length(participant_list)
0062     
0063         participant = participant_list{p};
0064         
0065         % Check to see if they have the inhand coding done.
0066         if has_variable(subj, sprintf('cstream_inhand_%s-hand_%s_%s', ...
0067                 hand_type{1}, inhand_list{1}, participant))
0068             
0069             % A temporary holder of the cstream data per hand, col1=left
0070             % hand, col2 = right hand data.
0071             hand_data = [];
0072             
0073             % Data for each object
0074             output=[];
0075             left_right_data = {};
0076             % loop through the objects
0077             for o = 1 : size(inhand_list,2)
0078                 
0079                 object = inhand_list{o};
0080                 
0081                 % create data for cevents
0082                 cev_hand_data{o} = [];
0083                 
0084                 % loop through both hands
0085                 for h = 1 : size(hand_type,2)
0086                     
0087                     % Grab the cstream variable.
0088                     temp_cstream = get_variable(subj, sprintf('cstream_inhand_%s-hand_%s_%s', ...
0089                         hand_type{h}, object, participant));
0090                     
0091                     left_right_data{h,1}(:,o) = temp_cstream(:,2); 
0092                     
0093                     hand_data(:,h) = temp_cstream(:,2);
0094                     
0095                     % Turn left hand into 1's, and right hand into 2's.  When
0096                     % we sum across we will have 1=left, 2=right, 3=both.
0097                     hand_data(hand_data(:,h) > 0, h) = h;
0098                     left_right_data{h,1}(temp_cstream(:,2) > 0,o) = o; 
0099                     
0100                     % Grab the event data to create the cevents later.
0101                     temp_event = cstream2cevent(temp_cstream);
0102 %
0103 %                     % Turn the event into a cevent with the object id
0104 %                     temp_event(:,3) = o;
0105 %
0106                     cev_hand_data{o} = [cev_hand_data{o};temp_event];
0107                     
0108                 end;
0109                 
0110                 % Set the cstream times:
0111                 output(:,1) = temp_cstream(:,1); 
0112                 % Set the cstream value to the sum of hand data.
0113                 output(:,2) = sum(hand_data,2);
0114 
0115                 % Record the cstream_inhand_obj#_[participant]
0116                 output(:,2) = output(:,2) > 0; %changes 1 2 and 3 into just 1
0117                 record_variable(subj, sprintf('cstream_inhand_%s_%s', object, participant), output);
0118                           
0119             end;
0120             
0121             for h = 1:2
0122                 left_right = left_right_data{h,1};
0123                 left_right = sum(left_right, 2);
0124                 left_right = cat(2, output(:,1), left_right);
0125                 record_variable(subj, sprintf('cstream_inhand_%s-hand_obj-all_%s', hand_type{h}, participant), left_right);
0126             end
0127             
0128             % Now create the cevent_inhand_[participant]
0129             % Combine all the object events and sort the rows.
0130             cev_inhand = sortrows(vertcat(cev_hand_data{:}), [1 2]);
0131             
0132             % Record the cevent
0133             record_variable(subj, sprintf('cevent_inhand_%s', participant), cev_inhand);
0134             
0135         end;
0136         
0137     end;
0138          
0139 end;
0140 
0141 
0142 
0143

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005