-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadData.m
executable file
·87 lines (77 loc) · 2.06 KB
/
loadData.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 DataStruct = loadData(file_names, progressBarHandle, data_dir)
% Read CEQ raw data and load into structure variable
%% Initialize
nFiles = max(size(file_names));
DataStruct = struct();
DataStruct.filenames = {};
F = cell(1,5); % 5 possible signals (fluorescence 1-4 and current)
% Progress bar
set(gcf, 'CurrentAxes', progressBarHandle);
progressBar = patch([0 1 1 0], [0 0 1 1], 'white', 'EdgeColor', 'red');
drawnow;
%% Loop through each raw data file
n=0;
for i=1:nFiles
% Status
title(['Loading file ', num2str(i), ' of ', num2str(nFiles), '...']);
set(progressBar,...
'XData',[0 (i-1)/nFiles (i-1)/nFiles 0],...
'YData',[0 0 1 1],...
'FaceColor','red');
drawnow;
[tmp1, tmp2, tmp3, tmp4, tmpC] = readCEQ([data_dir, '/', file_names{i}]);
if ~isempty(tmp1)
n=n+1;
DataStruct.filenames{n} = file_names{i};
F{1} = tmp1;
F{2} = tmp2;
F{3} = tmp3;
F{4} = tmp4;
F{5} = tmpC;
DataStruct.Dataset{n} = F;
end
end
% Status update
title('');
set(progressBar,...
'XData',[0 1 1 0],...
'YData',[0 0 1 1],...
'FaceColor',get(0,'DefaultUIControlBackgroundColor'),...
'EdgeColor',get(0,'DefaultUIControlBackgroundColor'));
drawnow;
end
function [f1, f2, f3, f4, current] = readCEQ(filename)
fid = fopen(filename,'r');
nHeaderlines = 0;
indexFound = false;
sepFound = false;
% Determine the number of lines to skip
% by looking for the keywords 'Separation' and 'INDEX'
% contained in every CEQ data file
while ~indexFound && ~feof(fid)
tline = fgets(fid);
if ~isempty(strfind(tline, 'Separation'))
sepFound = true;
end
if sepFound && ~isempty(strfind(tline, 'INDEX'))
indexFound = true;
end
nHeaderlines = nHeaderlines + 1;
end
fclose(fid);
% Store each signal in an array
if indexFound
I = importdata(filename, '\t', nHeaderlines);
f1 = I.data(:,1);
f2 = I.data(:,2);
f3 = I.data(:,3);
f4 = I.data(:,4);
current = I.data(:,5);
else
f1 = [];
f2 = [];
f3 = [];
f4 = [];
current = [];
end
end