Commit 2d37fd43 authored by tk11br's avatar tk11br
Browse files

Diagnostic output added as well as overlay bug fix.

parent ff432881
Subproject commit eb58a1e067347780e855649ba59351ffcf47015d Subproject commit 0917d2a77293fd978331afb26ff407edf7692b4a
# ASA electrode file
ReferenceLabel avg
UnitPosition mm
NumberPositions= 7
Positions
0.1123 88.2470 -1.7130
-80.7750 14.1203 -11.1350
81.8151 15.4167 -11.3300
0.4009 -9.1670 100.2440
-54.8404 -97.5279 2.7920
55.6666 -97.6251 2.7300
0.1076 -114.8920 14.6570
Labels
Fpz
FT7
FT8
Cz
PO7
PO8
Oz
...@@ -14,26 +14,35 @@ set(bfh,'Position',[1986 1 348 973]); ...@@ -14,26 +14,35 @@ set(bfh,'Position',[1986 1 348 973]);
%PLOT CHAN DATA SCROLL PLOT USING VISED PLUGIN... %PLOT CHAN DATA SCROLL PLOT USING VISED PLUGIN...
EEG_scalp = pop_vised(EEG,'data_type','EEG', ... EEG_scalp = pop_vised(EEG,'data_type','EEG', ...
'pop_gui','off', ... 'pop_gui','off', ...
'event_type',[], ...
'spacing',80, ... 'spacing',80, ...
'command','', ... 'command','', ...
'tag','ve_eeg', ... 'tag','ve_eeg', ...
'keyselectcommand',{'t,ve_eegplot(''topoplot'',gcbf)';'r,ve_eegplot(''drawp'',0)';'o,qc_ovl_tog';'u,qc_ovl_upd'}); 'keyselectcommand',{'t,ve_eegplot(''topoplot'',gcbf)';'r,ve_eegplot(''drawp'',0)';'o,qc_ovl_tog';'u,qc_ovl_upd'}, ...
'dispchans',32);
sfh = gcf; sfh = gcf;
set(sfh,'Position',[66 1 1484 1003]); set(sfh,'Position',[66 1 1484 1003]);
%PLOT FULL DURATION NON-MANUAL ICAACT SURFACE PLOT %PLOT FULL DURATION NON-MANUAL ICAACT SURFACE PLOT
notman_pnts = marks_label2index(EEG.marks.time_info,{'manual'},'indexes','invert','on'); %notman_pnts = marks_label2index(EEG.marks.time_info,{'manual'},'indexes','invert','on');
normact=zeros(size(EEG.icaact(:,notman_pnts))); %normact=zeros(size(EEG.icaact(:,notman_pnts)));
fullnormact=zeros(size(EEG.icaact));
sortnormact=zeros(size(EEG.icaact(:,notman_pnts))); %sortnormact=zeros(size(EEG.icaact(:,notman_pnts)));
for i=1:min(size(EEG.icaweights)); for i=1:min(size(EEG.icaweights));
normact(i,:)=(EEG.icaact(i,notman_pnts)-min(EEG.icaact(i,notman_pnts)))/(max(EEG.icaact(i,notman_pnts))-min(EEG.icaact(i,notman_pnts))); %normact(i,:)=(EEG.icaact(i,notman_pnts)-min(EEG.icaact(i,notman_pnts)))/(max(EEG.icaact(i,notman_pnts))-min(EEG.icaact(i,notman_pnts)));
sortnormact(i,:)=sort(normact(i,:)); fullnormact(i,:) = (EEG.icaact(i,:)-min(EEG.icaact(i,:)))/(max(EEG.icaact(i,:))-min(EEG.icaact(i,:)));
%sortnormact(i,:)=sort(normact(i,:));
end end
nash=figure; %nash=figure;
surf(normact,'linestyle','none');axis('tight');view(0,270); %surf(normact,'linestyle','none');axis('tight');view(0,270);
set(nash,'Position',[1550 1 371 973]); %set(nash,'Position',[1550 1 371 973]);
fullnash=figure;
surf(fullnormact,'linestyle','none');axis('tight');view(0,270);
set(fullnash,'Position',[1550 1 371 973]);
%snash=figure; %snash=figure;
%surf(sortnormact,'linestyle','none');axis('tight');view(0,270); %surf(sortnormact,'linestyle','none');axis('tight');view(0,270);
...@@ -62,7 +71,8 @@ close(tfh(find(strncmp('View components properties - pop_viewprops() (dataset:', ...@@ -62,7 +71,8 @@ close(tfh(find(strncmp('View components properties - pop_viewprops() (dataset:',
%CLOSE/CLEAR ICLABEL BAR GRAPH %CLOSE/CLEAR ICLABEL BAR GRAPH
try close(bfh),clear bfh, catch clear bfh, end try close(bfh),clear bfh, catch clear bfh, end
try close(nash),clear nash, catch clear nash, end try close(fullnash),clear fullnash, catch clear fullnash, end
%try close(nash),clear nash, catch clear nash, end
%try close(snash),clear snash, catch clear snash, end %try close(snash),clear snash, catch clear snash, end
%CLOSE/CLEAR EEG SCROLL PLOT HANDLES %CLOSE/CLEAR EEG SCROLL PLOT HANDLES
......
...@@ -8,7 +8,7 @@ function main_diagnostics(filePath) ...@@ -8,7 +8,7 @@ function main_diagnostics(filePath)
fOut = fopen(fName,'w'); fOut = fopen(fName,'w');
% Update this eventually... % Update this eventually...
header = 'fname,nbchan,pnts,srate,manual,ch_s_sd-m,ch_s_sd_b-m,ch_s_sd_b-m-ch_sd_b,ch_s_sd_b-m-ic_sd1_b,ch_sd-m,ch_sd_b-m,ch_sd_b-m-ic_sd1_b,low_r-m,ic_sd1-m,ic_sd1_b-m,ic_sd2,ch_s_sd,ch_sd,low_r,bridge,LtModelMean,LtModelStd,Lt_quant_0.05,Lt_quant_0.15,Lt_quant_0.25,Lt_quant_0.5,Lt_quant_0.75,Lt_quant_0.85,Lt_quant_0.95,manual_comp_1,ic_rt_1,linkpvaluesMean,linkpvaluesStd,lpv_quant_0.05,lpv_quant_0.15,lpv_quant_0.25,lpv_quant_0.5,lpv_quant_0.75,lpv_quant_0.85,lpv_quant_0.95,tvar_mean, tvar_std, tvar_quant_0.05,tvar_quant_0.15,tvar_quant_0.25,tvar_quant_0.5,tvar_quant_0.75,tvar_quant_0.85,tvar_quant_0.95, pvar_mean, pvar_std,pvar_quant_0.05,pvar_quant_0.15,pvar_quant_0.25,pvar_quant_0.5,pvar_quant_0.75,pvar_quant_0.85,pvar_quant_0.95'; header = 'fname,nbchan,pnts,srate,manual,ch_s_sd_m,ch_s_sd_b_m,ch_sd_m,ch_sd_b_m,low_r_m,ic_sd1_m,ic_sd1_b_m,ic_sd2_m,mark_gap,ch_s_sd_b-ch_sd_b,ch_s_sd_b-ic_sd1_b,ch_sd_b-ic_sd1_b,low_r_m-ic_sd1_b,manual_only,non_manual,remaining,ch_s_sd,ch_sd,low_r,bridge,LtModelMean,LtModelStd,Lt_quant_0.05,Lt_quant_0.15,Lt_quant_0.25,Lt_quant_0.5,Lt_quant_0.75,Lt_quant_0.85,Lt_quant_0.95,manual_comp_1,ic_rt_1,linkpvaluesMean,linkpvaluesStd,lpv_quant_0.05,lpv_quant_0.15,lpv_quant_0.25,lpv_quant_0.5,lpv_quant_0.75,lpv_quant_0.85,lpv_quant_0.95,tvar_mean, tvar_std, tvar_quant_0.05,tvar_quant_0.15,tvar_quant_0.25,tvar_quant_0.5,tvar_quant_0.75,tvar_quant_0.85,tvar_quant_0.95, pvar_mean, pvar_std,pvar_quant_0.05,pvar_quant_0.15,pvar_quant_0.25,pvar_quant_0.5,pvar_quant_0.75,pvar_quant_0.85,pvar_quant_0.95';
fprintf(fOut,'%s\n',header); fprintf(fOut,'%s\n',header);
% Read line by line of the specified diag list % Read line by line of the specified diag list
...@@ -16,6 +16,7 @@ function main_diagnostics(filePath) ...@@ -16,6 +16,7 @@ function main_diagnostics(filePath)
tline = fgetl(fIn); tline = fgetl(fIn);
while ischar(tline) while ischar(tline)
single_diagnostic(fOut,tline); single_diagnostic(fOut,tline);
single_spect_diag(tline);
tline = fgetl(fIn); tline = fgetl(fIn);
end end
......
...@@ -18,32 +18,43 @@ function single_diagnostic(fOutID, singleSetFile) ...@@ -18,32 +18,43 @@ function single_diagnostic(fOutID, singleSetFile)
outString = [outString, num2str(EEG.pnts), ',']; outString = [outString, num2str(EEG.pnts), ','];
outString = [outString, num2str(EEG.srate), ',']; outString = [outString, num2str(EEG.srate), ','];
% All time_info flag enables in seconds: % All time_info flags in seconds:
% Manual % Manual
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags==1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags== 1)) / EEG.srate), ','];
% ch_s_sd m % ch_s_sd_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 1)) / EEG.srate), ','];
% ch_s_sd b m % ch_s_sd_b_m (padding of ch_s_sd_m)
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5)) / EEG.srate), ','];
% ch_s_sd b m ch_sd b % ch_sd_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5 & EEG.marks.time_info(4).flags == 0.5)) / EEG.srate), ','];
% ch_s_sd b m ic_sd1 b
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% ch_sd m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 1)) / EEG.srate), ','];
% ch_sd b m % ch_sd_b_m (padding of ch_sd_m)
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 0.5)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 0.5)) / EEG.srate), ','];
% ch_sd b m ic_sd1 b % low_r_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 0.5 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% low_r m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(5).flags == 1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(5).flags == 1)) / EEG.srate), ','];
% ic_sd1 m % ic_sd1_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(8).flags == 1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(8).flags == 1)) / EEG.srate), ','];
% ic_sd1 b m % ic_sd1_b_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% ic_sd2 % ic_sd2_m
outString = [outString, num2str(length(find(EEG.marks.time_info(12).flags==1)) / EEG.srate), ',']; outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(12).flags == 1)) / EEG.srate), ','];
% mark_gap
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(6).flags == 1)) / EEG.srate), ','];
% overlap between ch_s_sd_b_m and ch_sd_b_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5 & EEG.marks.time_info(4).flags == 0.5)) / EEG.srate), ','];
% overlap between ch_s_sd_b_m and ic_sd1_b_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0.5 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% overlap between ch_sd_b_m and ic_sd1_b_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(4).flags == 0.5 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% overlap between low_r_m and ic_sd1_b_m
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(5).flags == 1 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% manual only
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(3).flags == 0 & EEG.marks.time_info(4).flags == 0 & ...
EEG.marks.time_info(5).flags == 0 & EEG.marks.time_info(6).flags == 0 & EEG.marks.time_info(8).flags == 0 & EEG.marks.time_info(12).flags == 0)) / EEG.srate), ','];
% non-manual but flagged for other reason
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 0 & (EEG.marks.time_info(3).flags > 0 | EEG.marks.time_info(4).flags > 0 | EEG.marks.time_info(5).flags > 0 | EEG.marks.time_info(6).flags > 0 | EEG.marks.time_info(8).flags > 0 | EEG.marks.time_info(12).flags > 0))) / EEG.srate), ','];
% all non-manual
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 0)) / EEG.srate), ','];
% Single chan_info flag enables in seconds: % Single chan_info flag enables in seconds:
for i=2:5 % [2,5] are ch_s_sd, ch_sd, low_r, and bridge respectively. for i=2:5 % [2,5] are ch_s_sd, ch_sd, low_r, and bridge respectively.
outString = [outString, num2str(length(find(EEG.marks.chan_info(i).flags==1))), ',']; outString = [outString, num2str(length(find(EEG.marks.chan_info(i).flags==1))), ','];
......
% This function loads a single file and gathers all of the needed
% information. fOutID should be the output file handle from
% main_diagnostics. singleSetFile should reflect its name.
function single_spect_diag(singleSetFile)
% Storing what's going to be written to the csv in a variable to act as
% Load:
EEG = pop_loadset('filepath','','filename',singleSetFile);
EEG = eeg_checkset( EEG );
% Removed flagged channels and time segments
sprintf('%s','Purging flagged channels...\n');
EEG = pop_marks_select_data(EEG,'channel marks',[],'labels',{'manual'},'remove','on');
EEG = pop_marks_select_data(EEG,'time marks',[],'labels',{'manual'},'remove','on');
% EEG = pop_marks_select_data(EEG,'component marks',[],'labels',{'manual'},'remove','on');
EEG = eeg_checkset(EEG);
EEG= warp_locs(EEG,'derivatives/lossless/code/misc/standard_1020_Fpz_FT7_FT8_Cz_PO7_PO8_Oz.elc','transform',[0,0,0,0,0,-1.57,1,1,1],'manual','off');
EEG = interp_mont(EEG,'derivatives/lossless/code/misc/standard_1020_Fpz_FT7_FT8_Cz_PO7_PO8_Oz.elc','manual','off');
EEG = eeg_checkset(EEG);
EEG.icaact=[];
EEG.icawinv=[];
EEG.icasphere=[];
EEG.icaweights=[];
EEG.icachansind=[];
% Window the continuous data
logging_log('INFO', 'Windowing the continous data...');
EEG = marks_continuous2epochs(EEG,'recurrence',0.5,'limits',[0,1],'keepboundary','off');
EEG = eeg_checkset(EEG);
if EEG.srate==500;
EEG.data=EEG.data(:,1:2:end,:);
%EEG.srate=250;
end
%EEG = eeg_checkset(EEG);
h=hanning(250);
hr=repmat(h,1,EEG.trials);
for i=1:size(EEG.data,1);
d=squeeze(EEG.data(i,:,:));
dh=d.*hr;
f=fft(dh);
out.tfm(:,i)=mean(abs(f(1:125,:)),2);
end
% Load:
EEG = pop_loadset('filepath','','filename',singleSetFile);
EEG = eeg_checkset( EEG );
% Removed flagged channels and time segments
sprintf('%s','Purging flagged channels...\n');
EEG = pop_marks_select_data(EEG,'channel marks',[],'labels',{'manual'},'remove','on');
EEG = pop_marks_select_data(EEG,'time marks',[],'labels',{'manual'},'remove','on');
EEG = pop_marks_select_data(EEG,'component marks',[],'labels',{'manual'},'remove','on');
EEG = eeg_checkset(EEG);
EEG= warp_locs(EEG,'derivatives/lossless/code/misc/standard_1020_Fpz_FT7_FT8_Cz_PO7_PO8_Oz.elc','transform',[0,0,0,0,0,-1.57,1,1,1],'manual','off');
EEG = interp_mont(EEG,'derivatives/lossless/code/misc/standard_1020_Fpz_FT7_FT8_Cz_PO7_PO8_Oz.elc','manual','off');
EEG = eeg_checkset(EEG);
EEG.icaact=[];
EEG.icawinv=[];
EEG.icasphere=[];
EEG.icaweights=[];
EEG.icachansind=[];
% Window the continuous data
logging_log('INFO', 'Windowing the continous data...');
EEG = marks_continuous2epochs(EEG,'recurrence',0.5,'limits',[0,1],'keepboundary','off');
EEG = eeg_checkset(EEG);
if EEG.srate==500;
EEG.data=EEG.data(:,1:2:end,:);
%EEG.srate=250;
end
%EEG = eeg_checkset(EEG);
h=hanning(250);
hr=repmat(h,1,EEG.trials);
for i=1:size(EEG.data,1);
d=squeeze(EEG.data(i,:,:));
dh=d.*hr;
f=fft(dh);
out.pfm(:,i)=mean(abs(f(1:125,:)),2);
end
[path, name, ~]= fileparts(singleSetFile);
outfname = [path,'/',name, '_spect_diag.mat'];
disp(['Saving ' outfname '...']);
save(outfname,'out');
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment