forked from kristinbranson/BABAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeLineInfoWebpageNoMetadata.m
144 lines (129 loc) · 4.75 KB
/
MakeLineInfoWebpageNoMetadata.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
function [filenamecurr] = MakeLineInfoWebpageNoMetadata(line_names,varargin)
timestamp = datestr(now,'yyyymmddTHHMMSS');
persistent imdata;
persistent imdata_vnc;
[imdata,imdata_vnc,...
groupname,filenamecurr] = myparse(varargin,...
'imdata',imdata,...
'imdata_vnc',imdata_vnc,...
'groupname',sprintf('Group selected %s',timestamp),...
'outfilename','');
if isempty(imdata) || isempty(imdata_vnc),
[f,p] = uigetfile('*.mat','Select imdata mat file','/groups/branson/bransonlab/projects/olympiad/FlyBowlAnalysis/ImageryData20150901.mat');
if ~ischar(f),
return;
end
imagerydatafile = fullfile(p,f);
imdata = load(imagerydatafile,'imdata','imdata_vnc');
imdata = imdata.imdata;
end
nlines = numel(line_names);
% create an html page with links to all experiments
if isempty(filenamecurr),
filenamecurr = fullfile(tempdir,sprintf('selectedgroup_%s.html',timestamp));
end
fid = fopen(filenamecurr,'w');
if fid < 1,
warning('Could not open temporary file %s for writing.',filenamecurr);
filenamecurr = '';
return;
else
fprintf(fid,'<html>\n<title>%s</title>\n<body>\n',groupname);
fprintf(fid,'<head>\n');
fprintf(fid,'<style>\n');
fprintf(fid,'table\n');
fprintf(fid,'{\n');
fprintf(fid,'border-collapse:collapse;\n');
fprintf(fid,'}\n');
fprintf(fid,'table, td, th\n');
fprintf(fid,'{\n');
fprintf(fid,'border:1px solid black;\n');
fprintf(fid,'}\n');
fprintf(fid,'</style>\n');
fprintf(fid,'</head>\n');
for i = 1:nlines,
fprintf(fid,'<h1>%s</h1>\n',line_names{i});
reg_file = '';
idxanat = find(strcmp({imdata.line},line_names{i}));
[~,order] = sort([imdata(idxanat).qi]);
for j = idxanat(order)',
maxproj_file = imdata(j).maxproj_file_system_path;
reg_file = regexprep(maxproj_file,'_total.jpg$','.reg.local.jpg');
if exist(reg_file,'file'),
break;
else
reg_file = '';
end
end
if ~isempty(reg_file) && exist(reg_file,'file'),
fprintf(fid,'<a href="%s"><img src="%s" height="200"></a></p>\n',reg_file,reg_file);
end
idxanat = find(strcmp({imdata.line},line_names{i}));
if isempty(idxanat),
fprintf(fid,'<p>No images found.</p>\n');
else
fprintf(fid,'<ul>\n');
for j = idxanat(:)',
name = imdata(j).name;
maxproj_file = imdata(j).maxproj_file_system_path;
maxproj_ch2_file = regexprep(maxproj_file,'_total.jpg$','_ch2_total.jpg');
reg_file = regexprep(maxproj_file,'_total.jpg$','.reg.local.jpg');
translation_file = imdata(j).translation_file_path;
if ~exist(maxproj_file,'file') && ~exist(translation_file,'file'),
continue;
end
fprintf(fid,' <li>%s: ',name);
if exist(maxproj_file,'file'),
fprintf(fid,'<a href="file://%s">Max projection image</a>',maxproj_file);
end
if exist(maxproj_ch2_file,'file') && ~strcmp(maxproj_file,maxproj_ch2_file),
fprintf(fid,', <a href="file://%s">Max proj, channel 2</a>',maxproj_ch2_file);
end
if exist(reg_file,'file') && ~strcmp(maxproj_file,reg_file),
fprintf(fid,', <a href="file://%s">Registered image</a>',reg_file);
end
if exist(translation_file,'file'),
fprintf(fid,', <a href="file://%s">Translation video</a>',translation_file);
end
fprintf(fid,'</li>\n');
end
fprintf(fid,'</ul>\n');
end
idxanat = find(strcmp({imdata_vnc.line},line_names{i}));
if isempty(idxanat),
fprintf(fid,'<p>No VNC images found.</p>\n');
else
fprintf(fid,'<ul>\n');
for j = idxanat(:)',
name = imdata_vnc(j).name;
maxproj_file = imdata_vnc(j).maxproj_file_system_path;
maxproj_ch2_file = regexprep(maxproj_file,'_total.jpg$','_ch2_total.jpg');
translation_file = imdata_vnc(j).translation_file_path;
if ~exist(maxproj_file,'file') && ~exist(translation_file,'file'),
continue;
end
fprintf(fid,' <li>%s: ',name);
if exist(maxproj_file,'file'),
fprintf(fid,'<a href="file://%s">VNC max projection image</a>',maxproj_file);
end
if exist(maxproj_ch2_file,'file') && ~strcmp(maxproj_file,maxproj_ch2_file),
fprintf(fid,', <a href="file://%s">VNC max proj, channel 2</a>',maxproj_ch2_file);
end
if exist(translation_file,'file'),
fprintf(fid,', <a href="file://%s">VNC translation video</a>',translation_file);
end
fprintf(fid,'</li>\n');
end
fprintf(fid,'</ul>\n');
end
end
fprintf(fid,'</body>\n</html>\n');
fclose(fid);
if ~exist(filenamecurr,'file'),
warning('Could not open temporary file %s',filenamecurr);
return;
else
% open this page
web(filenamecurr,'-browser');
end
end