-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcombinePointStatsFiles.m
executable file
·72 lines (64 loc) · 2.34 KB
/
combinePointStatsFiles.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
function pointStats=combinePointStatsFiles(psFolder,psLength)
% creates a complete pointStats variable from an analysis folder which is
% created by the WormStraightening programs. Adjusted to work on the
% cluster, DOES NOT OVERWRITE EXISTING POINTSTATS FILES
% output is a saved pointStats in the the dataFolder,
% pointStats is an array of structures, with the ith structure
% coresponding to the ith volume in the recording.
if nargin==0
dataFolder=uipickfiles;
dataFolder=dataFolder{1};
end
if nargin==1
dataFolder=psFolder;
end
psFolder=dir([dataFolder filesep 'CLstraight*']);
psFolder=[dataFolder filesep psFolder(end).name];
pList=dir([psFolder filesep 'pointStats*']);
if nargin==1
psLength=length(pList);
end
pointStats=repmat(struct(),1,psLength);
%progressbar(0);
for iFile=1:length(pList)
% progressbar(iFile/length(pList));
if ~mod(iFile,100)
display([ 'Completed frame ' num2str(iFile) ' of ' num2str(psLength)])
end
idx=str2double(pList(iFile).name(11:15));
%addint trycatch loop because matfile occasionally is corrupted during
%saving
try
input=load([psFolder filesep pList(iFile).name]);
input=input.pointStats;
good_vol_flag= length(input.straightPoints)<200;
catch me
fprintf([me.message '\n'])
good_vol_flag=0;
end
if good_vol_flag
pointStats(idx).stackIdx=input.stackIdx;
pointStats(idx).straightPoints=input.straightPoints;
pointStats(idx).rawPoints=input.rawPoints;
pointStats(idx).pointIdx=input.pointIdx;
pointStats(idx).Rintensities=input.Rintensities;
pointStats(idx).Volume=input.Volume;
else
pointStats(idx).stackIdx=[];
pointStats(idx).straightPoints=[];
pointStats(idx).rawPoints=[];
pointStats(idx).pointIdx=[];
pointStats(idx).Rintensities=[];
pointStats(idx).Volume=[];
end
end
%save final pointStats File
save([dataFolder filesep 'PointsStats'],'pointStats');
%write to status file
hostname = char( getHostName( java.net.InetAddress.getLocalHost ) );
if contains(hostname,'della')
Fid=fopen([dataFolder filesep 'status.txt'],'a');
status=[datestr(datetime('now')) ':Finished straightening \n'];
fprintf(Fid,status);
fclose(Fid);
end