0001
0002
0003 eeg_load_data_script;
0004
0005
0006
0007 times = [300 700];
0008
0009 clear exp con
0010
0011 for g=1:length(groups),
0012 for s=1:length(subs),
0013
0014 for t=1:size(times,1),
0015
0016
0017
0018 sub = sprintf('%s%02d%s%s',groups{g},subs(s),cond{1},ext);
0019 fprintf('Selecting %s\n',sub);
0020 p.volt.data = eval(sub);
0021 p.volt.timeArray = timeArray;
0022
0023 regions = eeg_region_peaks(p,times(t,:));
0024
0025 exp(t,g).sub(s,:) = {sub};
0026 exp(t,g).group(s,:) = groups(g);
0027 exp(t,g).cond(s,:) = cond(1);
0028 exp(t,g).times(s,:) = times(t,:);
0029 exp(t,g).names(s,:) = {regions.name};
0030 exp(t,g).pospeaks(s,:) = [regions.pospeaks];
0031 exp(t,g).postimes(s,:) = [regions.postimes];
0032 exp(t,g).poselecs(s,:) = [regions.poselecs];
0033 exp(t,g).negpeaks(s,:) = [regions.negpeaks];
0034 exp(t,g).negtimes(s,:) = [regions.negtimes];
0035 exp(t,g).negelecs(s,:) = [regions.negelecs];
0036
0037
0038
0039
0040
0041
0042 sub = sprintf('%s%02d%s%s',groups{g},subs(s),cond{2},ext);
0043 fprintf('Selecting %s\n',sub);
0044 p.volt.data = eval(sub);
0045 p.volt.timeArray = timeArray;
0046
0047
0048
0049
0050 for r=1:length(regions),
0051 posregion(r).name = regions(r).name;
0052 posregion(r).elec = regions(r).poselecs;
0053 negregion(r).name = regions(r).name;
0054 negregion(r).elec = regions(r).negelecs;
0055 end
0056
0057 clear regions
0058
0059 regions = eeg_region_peaks(p,times(t,:),posregion);
0060
0061 con(t,g).sub(s,:) = {sub};
0062 con(t,g).group(s,:) = groups(g);
0063 con(t,g).cond(s,:) = cond(2);
0064 con(t,g).times(s,:) = times(t,:);
0065 con(t,g).names(s,:) = {regions.name};
0066 con(t,g).pospeaks(s,:) = [regions.pospeaks];
0067 con(t,g).postimes(s,:) = [regions.postimes];
0068 con(t,g).poselecs(s,:) = [regions.poselecs];
0069
0070 clear regions
0071
0072 regions = eeg_region_peaks(p,times(t,:),negregion);
0073
0074 con(t,g).negpeaks(s,:) = [regions.negpeaks];
0075 con(t,g).negtimes(s,:) = [regions.negtimes];
0076 con(t,g).negelecs(s,:) = [regions.negelecs];
0077
0078 clear regions posregion negregion
0079
0080 end
0081 end
0082 end
0083
0084 clear g s r sub p
0085
0086 regions = elec_regions;
0087
0088
0089 Sub = char([exp(1,1).sub; exp(1,2).sub]);
0090 Gp = [ones(length(exp(1,1).sub),1); ones(length(exp(1,1).sub),1) * 2];
0091
0092
0093
0094
0095
0096
0097
0098 for t = 1:size(times,1),
0099
0100 [path,name,ext] = fileparts(strcat(eegpath,'regions_',num2str(times(t)),'.txt'));
0101 file = fullfile(path,[name ext]);
0102
0103 fid = fopen(file,'w');
0104
0105 fprintf(fid,'%-15s\t%-8s\t','Subjects','Group');
0106 ExpCond = strcat(exp(1,1).names(1,:),'exp');
0107 fprintf(fid,'%-10s\t',ExpCond{:});
0108 ConCond = strcat(con(1,1).names(1,:),'con');
0109 fprintf(fid,'%-10s\t',ConCond{:});
0110 fprintf(fid,'\n');
0111
0112 Exp = [exp(t,1).pospeaks; exp(t,2).pospeaks];
0113 Con = [con(t,1).pospeaks; con(t,2).pospeaks];
0114
0115 Data = [Exp,Con];
0116
0117 format = '%-15s\t%-8d\t';
0118 for i=1:length(regions)*2,format = strcat(format,'%10.4f\t'); end
0119 format = strcat(format,'\n');
0120
0121 for i=1:length(Sub),
0122 fprintf(fid,format,Sub(i,:),Gp(i),Data(i,:));
0123 end
0124 fclose(fid);
0125
0126 fprintf('\n\nRegion peaks results in file:\n... %s\n',file);
0127 fprintf('\nThis file can be imported into SPSS as text.\n');
0128 end
0129
0130
0131
0132
0133
0134 return
0135
0136
0137
0138
0139
0140 MODEL = 'full';
0141 SSTYPE = 3;
0142 DISPLAYOPT = 'off';
0143 for t = 1:size(times,1),
0144 for r = 1:length(regions),
0145
0146 cont = [exp(t,1).pospeaks(:,r); con(t,1).pospeaks(:,r)];
0147 ptsd = [exp(t,2).pospeaks(:,r); con(t,2).pospeaks(:,r)];
0148
0149 Y = [cont; ptsd];
0150
0151 GROUP1 = {'CONT'};
0152 GROUP2 = {'PTSD'};
0153 GROUPS = [ repmat(GROUP1,size(exp(t,1).pospeaks(:,r))); ...
0154 repmat(GROUP1,size(con(t,1).pospeaks(:,r))); ...
0155 repmat(GROUP2,size(exp(t,2).pospeaks(:,r))); ...
0156 repmat(GROUP2,size(con(t,2).pospeaks(:,r))) ];
0157
0158 EXP = {'tac'};
0159 CON = {'oac'};
0160 CONDITIONS = [ repmat(EXP,size(exp(t,1).pospeaks(:,r))); ...
0161 repmat(CON,size(con(t,1).pospeaks(:,r))); ...
0162 repmat(EXP,size(exp(t,2).pospeaks(:,r))); ...
0163 repmat(CON,size(con(t,2).pospeaks(:,r))) ];
0164
0165 GROUP = {GROUPS CONDITIONS};
0166 GNAME = strvcat('Group', 'Task');
0167
0168 [anova(t,r).p,anova(t,r).table] = ANOVAN(Y,GROUP,MODEL,SSTYPE,GNAME,DISPLAYOPT) ;
0169
0170 end
0171 end
0172 clear Y GROUP MODEL SSTYPE GNAME DISPLAYOPT;