Commit e5ae41ed authored by tk11br's avatar tk11br
Browse files

New diagnostics scripts which build csvs added.

parent d6ad1b7e
% Root diagnostics file.
% Argument should be a plaintext file listing the qcr's to be loaded
% newFolder=$(date +%Y_%m_%d_%H_%M_%S)
function main_diagnostics(filePath)
% Generate unique csv file
[~,fMod] = system('(date +%Y_%m_%d_%H_%M_%S)');
fName = ['diag_',strtrim(fMod),'.csv'];
fOut = fopen(fName,'w');
% 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,quant_0.05,quant_0.15,quant_0.25,quant_0.5,quant_0.75,quant_0.85,quant_0.95,pre_qc_comp';
fprintf(fOut,'%s\n',header);
% Read line by line of the specified diag list
fIn = fopen(filePath,'r');
tline = fgetl(fIn);
while ischar(tline)
single_diagnostic(fOut,tline);
tline = fgetl(fIn);
end
% Proper form!
fclose(fIn);
fclose(fOut);
end
\ No newline at end of file
% 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_diagnostic(fOutID, singleSetFile)
% Storing what's going to be written to the csv in a variable to act as
% a buffer. Line starts with filename.
outString = [singleSetFile, ','];
% Load:
EEG = pop_loadset('filepath','','filename',singleSetFile);
EEG = eeg_checkset( EEG );
% Basic row info:
outString = [outString, num2str(EEG.nbchan), ','];
outString = [outString, num2str(EEG.pnts), ','];
outString = [outString, num2str(EEG.srate), ','];
% All time_info flag enables in seconds:
% Manual
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags==1)) / EEG.srate), ','];
% 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), ','];
% ch_s_sd b m
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
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), ','];
% ch_sd b m
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
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), ','];
% ic_sd1 m
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
outString = [outString, num2str(length(find(EEG.marks.time_info(1).flags == 1 & EEG.marks.time_info(8).flags == 0.5)) / EEG.srate), ','];
% ic_sd2
outString = [outString, num2str(length(find(EEG.marks.time_info(12).flags==1)) / EEG.srate), ','];
% Single chan_info flag enables in seconds:
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))), ','];
end
% Amica diagnostic info:
outString = [outString, num2str(mean(EEG.amica(2).models.Lt)), ','];
outString = [outString, num2str(std(EEG.amica(2).models.Lt)), ','];
quants = quantile(EEG.amica(2).models.Lt,[0.05,0.15,0.25,0.5,0.75,0.85,0.95]);
for i=1:length(quants)
outString = [outString, num2str(quants(i)), ','];
end
% Pre QC comp count:
outString = [outString, num2str(length(EEG.icachansind)), ','];
% Final write - includes newline
fprintf(fOutID,'%s\n',outString);
end
\ No newline at end of file
Markdown is supported
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