0001
0002
0003 eeg_load_difdata_script;
0004
0005
0006
0007
0008 times = [150 300 450; 300 550 700];
0009
0010
0011 missing = 0;
0012
0013 clear dif
0014
0015 for g=1:length(groups),
0016 for s=1:length(subs),
0017
0018 for t=1:size(times,1),
0019
0020
0021
0022 sub = sprintf('%s%02d%s%s',groups{g},subs(s),cond{1},ext);
0023 fprintf('Selecting %s\n',sub);
0024 p.volt.data = eval(sub);
0025 p.volt.timeArray = timeArray;
0026
0027 regions = eeg_region_peaks(p,times(t,:),[],missing);
0028
0029 dif(t,g).sub(s,:) = {sub};
0030 dif(t,g).group(s,:) = groups(g);
0031 dif(t,g).cond(s,:) = cond(1);
0032 dif(t,g).times(s,:) = times(t,:);
0033 dif(t,g).names(s,:) = {regions.name};
0034 dif(t,g).pospeaks(s,:) = [regions.pospeaks];
0035 dif(t,g).postimes(s,:) = [regions.postimes];
0036 dif(t,g).poselecs(s,:) = [regions.poselecs];
0037 dif(t,g).negpeaks(s,:) = [regions.negpeaks];
0038 dif(t,g).negtimes(s,:) = [regions.negtimes];
0039 dif(t,g).negelecs(s,:) = [regions.negelecs];
0040
0041 clear regions posregion negregion
0042
0043 end
0044 end
0045 end
0046
0047 clear g s r sub p
0048
0049
0050
0051
0052
0053
0054 regions = elec_regions;
0055
0056
0057 Sub = char([dif(1,1).sub; dif(1,2).sub]);
0058 Gp = [ones(length(dif(1,1).sub),1); ones(length(dif(1,1).sub),1) * 2];
0059
0060 status = mkdir(eegpath,'regions');
0061 if status > 0,
0062 [path,name,ext] = fileparts(strcat(eegpath,filesep,'regions',filesep,''));
0063 outpath = fullfile(path);
0064 end
0065
0066 for t = 1:size(times,1),
0067
0068
0069 [path,name,ext] = fileparts(strcat(outpath,filesep,'eeg_regions_dif_p',sprintf('%04d',times(t,2)),'_amp.txt'));
0070 pampfile = fullfile(path,[name ext]);
0071 [path,name,ext] = fileparts(strcat(outpath,filesep,'eeg_regions_dif_p',sprintf('%04d',times(t,2)),'_lat.txt'));
0072 platfile = fullfile(path,[name ext]);
0073 [path,name,ext] = fileparts(strcat(outpath,filesep,'eeg_regions_dif_n',sprintf('%04d',times(t,2)),'_amp.txt'));
0074 nampfile = fullfile(path,[name ext]);
0075 [path,name,ext] = fileparts(strcat(outpath,filesep,'eeg_regions_dif_n',sprintf('%04d',times(t,2)),'_lat.txt'));
0076 nlatfile = fullfile(path,[name ext]);
0077
0078
0079 pampfid = fopen(pampfile,'w');
0080 platfid = fopen(platfile,'w');
0081 nampfid = fopen(nampfile,'w');
0082 nlatfid = fopen(nlatfile,'w');
0083
0084
0085 fprintf(pampfid,'%-15s\t%-8s\t','Subjects','Group');
0086 fprintf(platfid,'%-15s\t%-8s\t','Subjects','Group');
0087 fprintf(nampfid,'%-15s\t%-8s\t','Subjects','Group');
0088 fprintf(nlatfid,'%-15s\t%-8s\t','Subjects','Group');
0089
0090 DifCond = strcat(dif(1,1).names(1,:),'dif');
0091 fprintf(pampfid,'%-10s\t',DifCond{:}); fprintf(pampfid,'\n');
0092 fprintf(platfid,'%-10s\t',DifCond{:}); fprintf(platfid,'\n');
0093 fprintf(nampfid,'%-10s\t',DifCond{:}); fprintf(nampfid,'\n');
0094 fprintf(nlatfid,'%-10s\t',DifCond{:}); fprintf(nlatfid,'\n');
0095
0096
0097 format = '%-15s\t%-8d\t';
0098 for i=1:length(regions),format = strcat(format,'%10.4f\t'); end
0099 format = strcat(format,'\n');
0100
0101
0102 Dif = [dif(t,1).pospeaks; dif(t,2).pospeaks];
0103 Data = [Dif];
0104 for i=1:length(Sub),
0105 fprintf(pampfid,format,Sub(i,:),Gp(i),Data(i,:));
0106 end
0107
0108 Dif = [dif(t,1).postimes; dif(t,2).postimes];
0109 Data = [Dif];
0110 for i=1:length(Sub),
0111 fprintf(platfid,format,Sub(i,:),Gp(i),Data(i,:));
0112 end
0113
0114 Dif = [dif(t,1).negpeaks; dif(t,2).negpeaks];
0115 Data = [Dif];
0116 for i=1:length(Sub),
0117 fprintf(nampfid,format,Sub(i,:),Gp(i),Data(i,:));
0118 end
0119
0120 Dif = [dif(t,1).negtimes; dif(t,2).negtimes];
0121 Data = [Dif];
0122 for i=1:length(Sub),
0123 fprintf(nlatfid,format,Sub(i,:),Gp(i),Data(i,:));
0124 end
0125
0126 fclose('all');
0127
0128 fprintf('\n\nRegion peaks results in files:\n');
0129 fprintf('... %s\n',pampfile);
0130 fprintf('... %s\n',platfile);
0131 fprintf('... %s\n',nampfile);
0132 fprintf('... %s\n',nlatfile);
0133 end
0134 fprintf('\nThese files can be imported into SPSS as tab delimited text.\n');
0135
0136
0137
0138
0139 return