-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathOrganizeInput.m
87 lines (73 loc) · 2.75 KB
/
OrganizeInput.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function OrganizeInput(GUIControl)
% Control file for organizing instrument output into Data and Config arrays
% Called from MITT
% Calls Organize(Instrument)Data, where Instrument comes from Control.Instrument
% and CalcChannelMesh
%%
% get control file
CSVControl = ConvCSV2Struct([GUIControl.CSVControlpathname,GUIControl.CSVControlfilename],0);
% number of files
nftot = length(CSVControl);
% store output name and number of files
GUIControl.nftot = nftot;
if GUIControl.DefineGeometry
% calculate mesh of sampling channel
GUIControl = CalcChannelMesh(GUIControl,CSVControl);
end
% save file
chk = dir(GUIControl.outname);
if isempty(chk)
save(GUIControl.outname,'GUIControl')
else
save(GUIControl.outname,'GUIControl','-append')
end
% for each file
for nf = 1:nftot
% load data by sending Control structure to the instrument-appropriate Organize**Data file
eval(['[Dataa,Configa] = Organize',CSVControl(nf).instrument,'Data(GUIControl,CSVControl(nf));']);
% for each array
if isfield(Configa,'nArrays')
natot = Configa.nArrays;
else
natot = 1;
end
for na = 1:natot
% create Config and Data arrays
Config = Configa(na);
Config.CSVControlpathname = GUIControl.CSVControlpathname;
% filename
Config.filename = [CSVControl(nf).filename,'na',num2str(na)];
% save Config and Data to the output file
oname = [GUIControl.odir,filesep,Config.filename,'.mat'];
% chk for any output files
chk = dir(oname);
% if this file has not been created
if isempty(chk)
% get data from Dataa matrix (raw data only)
Data = Dataa(na);
% add empty variables faQC and goodCells to Config in
% preparation for data quality control
Config.faQC = struct;
goodCells = ones(Config.nCells,1);
% add a goodCells vector for each component
ncomptot = length(Config.comp);
for nc = 1:ncomptot
eval(['Config.goodCells.',Config.comp{nc},' = goodCells;']);
end
% add variable nums to keep track of what analyses have been completed
Config.Despiked = 0; %
Config.Filtered = 0; %
save(oname,'Config','Data');
% else if this file exists, then just worry about Config and
% transfer information about quality analyses
else
Ctemp = load(oname,'Config');
Config.faQC = Ctemp.Config.faQC';
Config.goodCells = Ctemp.Config.goodCells;
Config.Despiked = Ctemp.Config.Despiked;
Config.Filtered = Ctemp.Config.Filtered;
save(oname,'Config','-append');
end
end
end
end