0001 function [ses_mask] = artifact_edit(fname, fhdr, chdr, edit_file_type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 disp(['Starting edit code reading']);
0016 ses_hdr_offsets_v; ave_hdr_offsets_v;
0017
0018
0019 EDC = 0; MYSTERY = 1;
0020 if nargin < 4
0021 disp('Possible edit code file types are: ');
0022 disp(' 0) Edit codes files as written by MacAverager')
0023 disp(' 1) MYSTERY format')
0024 edit_file_type = input('Select one: ')
0025 end
0026
0027 if edit_file_type == EDC
0028 ses_mask = read_edc([fname '.edc'], fhdr, chdr);
0029
0030 elseif edit_file_type == MYSTERY
0031
0032 mys_fname = [fname '.mys'];
0033 mys_fid = fopen(mys_fname, 'r');
0034 ses_mask = zeros(sum(chdr(:,NTrials)), fhdr(NChan));
0035 ses_mask = fread(mys_fid, [sum(chdr(:,NTrials)), fhdr(NChan)], 'int8');
0036
0037
0038
0039
0040
0041 end
0042
0043
0044 ses_mask(:, fhdr(NChan) + 1) = ones(sum(chdr(:, NObs)), 1);
0045
0046
0047
0048
0049 replace_indices = find(sum(ses_mask') == 1)';
0050 ses_mask(replace_indices, fhdr(NChan) + 1) = zeros(length(replace_indices),1);
0051