Ho scritto il codice per interno però mi runna praticamente all'infinito. Cioè il file 'EEGrecordings' è di circa 850MB però penso sia proprio un problema di codice:
[load EEGrecordings;
%parametri di riferimento da specificare
fc = 500;
num_ch = 31;
for idx=1:38
if(isfield(EEGrecordings,sprintf('S_%02d',idx)))
data(idx)=EEGrecordings.(sprintf('S_%02d',idx));
results(38)=struct('rP_com',[],'TRP_com',[],'rP_uncom',[],'TRP_uncom',[]);
num_com = size(data(idx).com,2)/2;
num_uncom = size(data(idx).unc,2)/2;
%creo delle matrici di zeri che andrà a sovrascrivere
rP_com = zeros(31,num_com,6);
TRP_com = zeros(31,num_com,6);
rP_uncom = zeros(31,num_uncom,6);
TRP_uncom = zeros(31,num_uncom,6);
for j=1:num_com
for k=1:num_uncom
Obj_ref_com = data(idx).com(j*2-1).com;
Obj_idea_com= data(idx).com(j*2).com;
Obj_ref_unc = data(idx).unc(k*2-1).unc;
Obj_idea_unc = data(idx).unc(k*2).unc;
for i=1:num_ch
[f_ref_com,PSD_ref_com] = est_PSD(Obj_ref_com(i,:),fc);
aP_ref1_com = sum(PSD_ref_com(f_ref_com >= 0 & f_ref_com<4));
aP_ref2_com = sum(PSD_ref_com(f_ref_com >= 4 & f_ref_com<7.5));
aP_ref3_com = sum(PSD_ref_com(f_ref_com >= 7.5 & f_ref_com<12.5));
aP_ref4_com = sum(PSD_ref_com(f_ref_com >= 12.5 & f_ref_com<30));
aP_ref5_com = sum(PSD_ref_com(f_ref_com >= 30 & f_ref_com<45));
aP_ref6_com = sum(PSD_ref_com(f_ref_com >= 45 & f_ref_com<250));
[f_ref_unc,PSD_ref_unc] = est_PSD(Obj_ref_unc(i,:),fc);
aP_ref1_unc = sum(PSD_ref_unc(f_ref_unc >= 0 & f_ref_unc<4));
aP_ref2_unc = sum(PSD_ref_unc(f_ref_unc >= 4 & f_ref_unc<7.5));
aP_ref3_unc = sum(PSD_ref_unc(f_ref_unc >= 7.5 & f_ref_unc<12.5));
aP_ref4_unc = sum(PSD_ref_unc(f_ref_unc >= 12.5 & f_ref_unc<30));
aP_ref5_unc = sum(PSD_ref_unc(f_ref_unc >= 30 & f_ref_unc<45));
aP_ref6_unc = sum(PSD_ref_unc(f_ref_unc >= 45 & f_ref_unc<250));
[f_idea_com,PSD_idea_com]= est_PSD(Obj_idea_com(i,:),fc);
aP_idea1_com = sum(PSD_idea_com(f_idea_com >= 0 & f_idea_com <4));
aP_idea2_com = sum(PSD_idea_com(f_idea_com >= 4 & f_idea_com< 7.5));
aP_idea3_com = sum(PSD_idea_com(f_idea_com>= 7.5 & f_idea_com<12.5));
aP_idea4_com = sum(PSD_idea_com(f_idea_com >= 12.5 & f_idea_com<30));
aP_idea5_com = sum(PSD_idea_com(f_idea_com>= 30 & f_idea_com<45));
aP_idea6_com = sum(PSD_idea_com(f_idea_com >= 45 & f_idea_com<250));
[f_idea_unc,PSD_idea_unc]= est_PSD(Obj_idea_unc(i,:),fc);
aP_idea1_unc = sum(PSD_idea_unc(f_idea_unc >= 0 & f_idea_unc <4));
aP_idea2_unc = sum(PSD_idea_unc(f_idea_unc >= 4 & f_idea_unc< 7.5));
aP_idea3_unc = sum(PSD_idea_unc(f_idea_unc>= 7.5 & f_idea_unc<12.5));
aP_idea4_unc = sum(PSD_idea_unc(f_idea_unc >= 12.5 & f_idea_unc<30));
aP_idea5_unc = sum(PSD_idea_unc(f_idea_unc>= 30 & f_idea_unc <45));
aP_idea6_unc = sum(PSD_idea_unc(f_idea_unc >= 45 & f_idea_unc <250));
results(idx).rP_com(i,j,1) = 100*aP_idea1_com/sum(PSD_idea_com);
results(idx).rP_com(i,j,2) = 100*aP_idea2_com/sum(PSD_idea_com);
results(idx).rP_com(i,j,3) = 100*aP_idea3_com/sum(PSD_idea_com);
results(idx).rP_com(i,j,4) = 100*aP_idea4_com/sum(PSD_idea_com);
results(idx).rP_com(i,j,5) = 100*aP_idea5_com/sum(PSD_idea_com);
results(idx).rP_com(i,j,6) = 100*aP_idea6_com/sum(PSD_idea_com);
results(idx).rP_uncom(i,k,1) = 100*aP_idea1_unc/sum(PSD_idea_unc);
results(idx).rP_uncom(i,k,2) = 100*aP_idea2_unc/sum(PSD_idea_unc);
results(idx).rP_uncom(i,k,3) = 100*aP_idea3_unc/sum(PSD_idea_unc);
results(idx).rP_uncom(i,k,4) = 100*aP_idea4_unc/sum(PSD_idea_unc);
results(idx).rP_uncom(i,k,5) = 100*aP_idea5_unc/sum(PSD_idea_unc);
results(idx).rP_uncom(i,k,6) = 100*aP_idea6_unc/sum(PSD_idea_unc);
results(idx).TRP_com(i,j,1) = log10(aP_idea1_com) - log10(aP_ref1_com);
results(idx).TRP_com(i,j,2) = log10(aP_idea2_com) - log10(aP_ref2_com);
results(idx).TRP_com(i,j,3) = log10(aP_idea3_com) - log10(aP_ref3_com);
results(idx).TRP_com(i,j,4) = log10(aP_idea4_com) - log10(aP_ref4_com);
results(idx).TRP_com(i,j,5) = log10(aP_idea5_com) - log10(aP_ref5_com);
results(idx).TRP_com(i,j,6) = log10(aP_idea6_com) - log10(aP_ref6_com);
results(idx).TRP_uncom(i,k,1) = log10(aP_idea1_unc) - log10(aP_ref1_unc);
results(idx).TRP_uncom(i,k,2) = log10(aP_idea2_unc) - log10(aP_ref2_unc);
results(idx).TRP_uncom(i,k,3) = log10(aP_idea3_unc) - log10(aP_ref3_unc);
results(idx).TRP_uncom(i,k,4) = log10(aP_idea4_unc) - log10(aP_ref4_unc);
results(idx).TRP_uncom(i,k,5) = log10(aP_idea5_unc) - log10(aP_ref5_unc);
results(idx).TRP_uncom(i,k,6) = log10(aP_idea6_unc) - log10(aP_ref6_unc);
end
end
end
else
idx=idx+1;
end
end
save results.mat results
]