forked from helgestein/htAx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeginAnalysis.m
89 lines (77 loc) · 2.64 KB
/
beginAnalysis.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
88
function [] = beginAnalysis(XRDFolder, EDXFile, EDXCoordFile, ...
ECFolder, XRDDatabaseFolder, filenameInfo, dataFolder)
%BEGINANALYSIS takes in the name of a folder that contains XRD data, the
%name of a file with EDX data, and the name of a file to which the analysis
%can be saved and begins a new analysis session with the data
% labels
labels.A = filenameInfo.labelA;
labels.B = filenameInfo.labelB;
labels.C = filenameInfo.labelC;
filenameInfo.dataDelim
filenameInfo.dataEnd
% read in XRD and EDX data
if filenameInfo.xrdFile == 0
[xEDX, yEDX] = importEDXCoordFile(EDXCoordFile);
[xCoord, yCoord, XRDData] = readXRDData(XRDFolder, filenameInfo, xEDX, yEDX);
else
XRDData = readXRDFileAll(XRDFolder);
end
[A, B, C] = importEDXFile(EDXFile);
% convert EDX data to percents
ids = find(A < 0);
A(ids) = 0;
ids = find(B < 0);
B(ids) = 0;
ids = find(C < 0);
C(ids) = 0;
% normalize
sums = A + B + C;
if sums ~= 0
A = A ./ sums;
B = B ./ sums;
C = C ./ sums;
end
% read in EC data
if ECFolder ~= 1
ECData = readECData(ECFolder, xCoord, yCoord, filenameInfo);
ECDataReal = 1;
else
% fill in dummy EC data
numPoints = size(XRDData, 2) / 2;
numPots = size(XRDData, 1);
ECData = zeros(size(XRDData, 1), size(XRDData, 2));
for i = 1:numPoints
ECData(:, i * 2 - 1) = 1:numPots;
end
ECDataReal = 0;
end
% read in other dataset
if isempty(filenameInfo.dataDelim) ~= 1
otherData = readOtherData(dataFolder, filenameInfo, xCoord, yCoord);
end
% read in XRD database folder
if XRDDatabaseFolder ~= 1
[collcodes, XRDDatabase] = readXRDDatabase(XRDDatabaseFolder);
else
collcodes = 1;
XRDDatabase = 1;
end
%find all points for which XRD data was not taken and remove those
%columns
ids = find(XRDData(1, :) + XRDData(2, :) == 0);
numToRemove = length(ids);
edxToRemove = ids(2 * (1:(numToRemove / 2))) / 2;
A = removerows(A, edxToRemove);
B = removerows(B, edxToRemove);
C = removerows(C, edxToRemove);
colsToRemove = ids;
XRDData = transpose(removerows(transpose(XRDData), colsToRemove));
ECData = transpose(removerows(transpose(ECData), colsToRemove));
pointInfo = zeros(1, 12);
numSelected = 0;
ECPlotInfo = zeros(342, 4);
savedPoly = zeros(1, 6);
openFigs(XRDData, A, B, C, numSelected, pointInfo, ECData, ...
ECPlotInfo, collcodes, XRDDatabase, labels, savedPoly, ...
ECDataReal, otherData);
end