Home > data-import > generate_derived_smart_room > master_derived_toy_room.m

master_derived_toy_room

PURPOSE ^

postfixation

SYNOPSIS ^

function master_derived_toy_room(subexpIDs, option, flagReliability)

DESCRIPTION ^

 postfixation
 all
   trial
   inhand
   roi
   ja
   inhand-roi

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function master_derived_toy_room(subexpIDs, option, flagReliability)
0002 % postfixation
0003 % all
0004 %   trial
0005 %   inhand
0006 %   roi
0007 %   ja
0008 %   inhand-roi
0009 
0010 if ~exist('flagReliability', 'var')
0011     flagReliability = 0;
0012 end
0013 subs = cIDs(subexpIDs);
0014 
0015 for s = 1:numel(subs)
0016     sub = subs(s);
0017     fprintf('%d\n', sub);
0018     read_trial_info(sub);
0019     fs = filesep;
0020     root = get_subject_dir(sub);
0021     agents = {'child', 'parent'};
0022     extract_range_fn = fullfile(root, 'supporting_files', 'extract_range.txt');
0023     if ~exist(extract_range_fn, 'file')
0024         movefile(fullfile(root, 'extra_p', 'extract_range.txt'), extract_range_fn);
0025     end
0026     % fix cstreams
0027     %     remove_nan(sub);
0028     % parse config to get video cuts
0029     %     config = parse_ini([root fs 'config.ini']);
0030     %     b_offset = config.s_extractframes.o_begin;
0031     %     b_offset = parse_time(b_offset);
0032     %     b_offset_frame = ceil(b_offset.total_sec*30) + 1;
0033     %
0034     %     e_offset = config.s_extractframes.o_end;
0035     %     e_offset = parse_time(e_offset);
0036     %     e_offset_frame = e_offset.total_sec*30 + 1;
0037     
0038     if sum(ismember(option, {'postfixation'})) > 0
0039         fprintf('\nProcessing postfixation for %d\n', sub);
0040         pause(1);
0041         for a = 1:2
0042             agent = agents{a};
0043             if flagReliability
0044                 fn = [root fs 'reliability' fs sprintf('coding_eye_roi_%s_reliability.mat', agent)];
0045             else
0046                 fn = [root fs 'supporting_files' fs sprintf('coding_eye_roi_%s.mat', agent)];
0047             end
0048             if exist(fn, 'file')
0049                 load(fn);
0050                 data = sdata.data;
0051                 if flagReliability
0052                     fixations = get_csv_data_v2([root fs 'reliability' fs 'fixation_frames_' agent '_reliability.txt']);
0053                 else
0054                     fixations = get_csv_data_v2([root fs 'supporting_files' fs 'fixation_frames_' agent '.txt']);
0055                 end
0056                 for f = 1:size(fixations, 1)
0057                     data(fixations(f,1):fixations(f,2),2) = data(fixations(f,3),2);
0058                 end
0059                 log = ismember(data(:,2), [27 28]);
0060                 data(log,2) = -1;
0061                 data(data(:,2)==-1,2) = NaN;
0062                 data(:,1) = (data(:,1) - 1)/30 + 30;
0063                 %                 data(isnan(data(:,2)), 2) = 0;
0064                 cev = cstream2cevent(data);
0065                 if flagReliability
0066                     record_variable(sub, ['cstream_eye_roi_fixation_' agent '_reliability'], data);
0067                     record_variable(sub, ['cevent_eye_roi_fixation_' agent '_reliability'], cev);
0068                 else
0069                     record_variable(sub, ['cstream_eye_roi_fixation_' agent], data);
0070                     record_variable(sub, ['cevent_eye_roi_fixation_' agent], cev);
0071                 end
0072                 
0073                 cev = cevent_merge_segments(cev, 0.50001);
0074                 cst = cevent2cstreamtb(cev, data);
0075                 
0076                 if flagReliability
0077                     record_variable(sub, ['cstream_eye_roi_' agent '_reliability'], cst);
0078                     record_variable(sub, ['cevent_eye_roi_' agent '_reliability'], cev);
0079                 else
0080                     record_variable(sub, ['cstream_eye_roi_' agent], cst);
0081                     record_variable(sub, ['cevent_eye_roi_' agent], cev);
0082                 end
0083             end
0084         end
0085     end
0086     
0087     if sum(ismember(option, {'postframebyframe'})) > 0
0088         fprintf('\nProcessing postframebyframe for %d\n', sub);
0089         pause(1);
0090         for a = 1:2
0091             agent = agents{a};
0092             cst = get_variable(sub, sprintf('cstream_eye_roi_%s', agent));
0093             cev = cstream2cevent(cst);
0094             cev(isnan(cev(:,3)),:) = [];
0095             record_variable(sub, sprintf('cevent_eye_roi_%s', agent), cev);
0096         end
0097     end
0098     
0099     if sum(ismember(option, {'trial', 'all'})) > 0
0100         make_trials_vars(sub);
0101     end
0102     
0103     if sum(ismember(option, {'ja', 'roi', 'trial', 'all'})) > 0
0104         fprintf('\nProcessing roi for %d\n', sub);
0105         pause(1);
0106         make_joint_attention_smart_room(sub);
0107         make_synched_attention(sub);
0108     end
0109     
0110     if sum(ismember(option, {'inhand', 'all'})) > 0
0111         fprintf('\nProcessing inhand for %d\n', sub);
0112         pause(1);
0113         for a = 1:2
0114             agent = agents{a};
0115             cstlh = get_variable(sub, sprintf('cstream_inhand_left-hand_obj-all_%s', agent));
0116             cstrh = get_variable(sub, sprintf('cstream_inhand_right-hand_obj-all_%s', agent));
0117             cevlh = cstream2cevent(cstlh);
0118             cevrh = cstream2cevent(cstrh);
0119             cevlh(isnan(cevlh(:,3)),:) = [];
0120             cevrh(isnan(cevrh(:,3)),:) = [];
0121             cevboth = cat(1, cevlh, cevrh);
0122             cevboth = sortrows(cevboth, [1 2 3]);
0123             
0124             record_variable(sub, sprintf('cevent_inhand_left-hand_obj-all_%s', agent), cevlh);
0125             record_variable(sub, sprintf('cevent_inhand_right-hand_obj-all_%s', agent), cevrh);
0126             record_variable(sub, sprintf('cevent_inhand_%s', agent), cevboth);
0127         end
0128         make_both_inhand(sub);
0129     end
0130     
0131     if sum(ismember(option, {'inhand-roi', 'roi', 'inhand', 'all'})) > 0
0132         fprintf('\nProcessing inhand/roi for %d\n', sub);
0133         pause(1);
0134         make_joint_eye_inhand_smart_room(sub);
0135     end
0136 end
0137 end

Generated on Tue 23-May-2017 02:00:59 by m2html © 2005