Skip to content

Commit

Permalink
bugs fixed in plot_export_*_depth.m
Browse files Browse the repository at this point in the history
  • Loading branch information
lpolerecky committed Feb 4, 2024
1 parent 8d973b0 commit aea8dc8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 37 deletions.
50 changes: 31 additions & 19 deletions src/fnc/plot_export_masses_depth.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function plot_export_masses_depth(m, dm, images,planes, opt1, opt4, mass, fdir,
% designeg GUI.
% (c) Lubos Polerecky, 03-07-2011

if ~isempty(m) & ~isempty(dm)
if ~isempty(m) && ~isempty(dm)

Nc=size(m{1},1);
M=length(m);
Expand All @@ -23,16 +23,28 @@ function plot_export_masses_depth(m, dm, images,planes, opt1, opt4, mass, fdir,
x=images{ii};
if isempty(x)
x=planes;
end;
end

Np = length(x);
out = zeros(Np,Nc*2);
pol = zeros(1,Nc);

% fix indexing:
% if the original data were loaded with selected planes and saved
% as "full processed", then when the data is loaded again as "full processed",
% the planes in the GUI are set as [], but planes in the input of
% this function is still correctly set as those selected
% planes. This causes error in indexing.

x_ind = x;
if length(x_ind)==size(m{1},2)
x_ind = x_ind - min(x_ind) + 1;
end

for jj=1:Nc

y=m{ii}(jj,x);
dy=dm{ii}(jj,x);
y=m{ii}(jj,x_ind);
dy=dm{ii}(jj,x_ind);

% remember output in out for export as ascii and EPS
out(:,(jj-1)*2+[1:2]) = [y(:) dy(:)];
Expand All @@ -44,13 +56,13 @@ function plot_export_masses_depth(m, dm, images,planes, opt1, opt4, mass, fdir,
if ~warning_printed
fprintf(1,'*** Warning: mass %s has a significant trend with depth for ROI(s):\n',mass{ii});
warning_printed = 1;
end;
end
fprintf(1,'%d ', jj);
end;
end

end;
end

if warning_printed, fprintf(1,'\n'); end;
if warning_printed, fprintf(1,'\n'); end

% remember results for later plotting
all_x{k} = x(:);
Expand All @@ -62,33 +74,33 @@ function plot_export_masses_depth(m, dm, images,planes, opt1, opt4, mass, fdir,
if opt1(10)
fname = [fdir, 'dat', delimiter, mass{ii}, '-z.dat'];
outdir = [fdir, 'dat', delimiter];
if ~isdir(outdir)
if ~isfolder(outdir)
mkdir(outdir);
fprintf(1,'Directory %s did not exist, so it was created.\n',outdir);
end;
end
fid = fopen(fname,'w');
fprintf(fid,'# %s: %s\n',fdir,mass{ii});
fprintf(fid,'# cell');
for kk=1:Nc
fprintf(fid,'\tMEAN%d\tPoiss_E%d',kk,kk);
end;
end
fprintf(fid,'\n# plane');
for kk=1:Nc
fprintf(fid,'\tPOL=%d\t',pol(kk));
end;
end
fprintf(fid,'\n');
for jj=1:Np
fprintf(fid,'%d', x(jj));
fprintf(fid,'\t%.3e\t%.3e',out(jj,1:2*Nc));
fprintf(fid,'\n');
end;
end
fclose(fid);
fprintf(1,'Depth profiles of %s for defined ROIs saved as %s\n',mass{ii},fname);
end;
end

end;
end

end;
end

% plot depth profiles
if k>0
Expand All @@ -98,16 +110,16 @@ function plot_export_masses_depth(m, dm, images,planes, opt1, opt4, mass, fdir,
for ii=1:length(all_out)
data.y{ii}=all_out{ii}(:,[1:2:2*Nc]);
data.dy{ii}=all_out{ii}(:,1+[1:2:2*Nc]);
end;
end
data.pol=all_pol;
data.plot_flag=opt1(11);
data.ratio = all_masses;
data.fdir = fdir;
data.print_factor = print_factor;
% here is the call to the actual GUI
depth_profiles_masses_gui(data);
end;
end

else
fprintf(1,'*** Warning: Empty mass values. Nothing done.\n');
end;
end
48 changes: 30 additions & 18 deletions src/fnc/plot_export_ratios_depth.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ function plot_export_ratios_depth(m, dm, cell_sizes, images, planes, opt1, opt4,
% designeg GUI.
% (c) Lubos Polerecky, 03-07-2011

if ~isempty(m) & ~isempty(dm)
if ~isempty(m) && ~isempty(dm)

Nc=size(m{1},1);
M=length(ratios);

x=images{1};
if isempty(x)
x=planes;
end;
end

k=0; % count of truly displayed ratios

Expand Down Expand Up @@ -43,11 +43,23 @@ function plot_export_ratios_depth(m, dm, cell_sizes, images, planes, opt1, opt4,
ind=unique([find(~isfinite(per)) find(isnan(per))]);
per(ind) = zeros(size(ind));

% fix indexing:
% if the original data were loaded with selected planes and saved
% as "full processed", then when the data is loaded again as "full processed",
% the planes in the GUI are set as [], but planes in the input of
% this function is still correctly set as those selected
% planes. This causes error in indexing.

x_ind = x;
if length(x_ind)==size(r,2)
x_ind = x_ind - min(x_ind) + 1;
end

% calculate ratios and Poisson errors for all ROIs
for jj=1:Nc

y=r(jj,x);
dy=r(jj,x).*per(jj,x);
y=r(jj,x_ind);
dy=r(jj,x_ind).*per(jj,x_ind);

% remember output in out for export as ascii and EPS
out(:,(jj-1)*2+[1:2]) = [y(:) dy(:)];
Expand All @@ -59,13 +71,13 @@ function plot_export_ratios_depth(m, dm, cell_sizes, images, planes, opt1, opt4,
if ~warning_printed
fprintf(1,'*** Warning: ratio %s has a significant trend with depth for ROI(s):\n',ratios{ii});
warning_printed = 1;
end;
end
fprintf(1,'%d ', jj);
end;
end

end;
end

if warning_printed, fprintf(1,'\n'); end;
if warning_printed, fprintf(1,'\n'); end

% remember results for later plotting
all_x{k} = x(:);
Expand All @@ -81,30 +93,30 @@ function plot_export_ratios_depth(m, dm, cell_sizes, images, planes, opt1, opt4,
if ~isdir(outdir)
mkdir(outdir);
fprintf(1,'Directory %s did not exist, so it was created.\n',outdir);
end;
end
fid = fopen(fname,'w');
fprintf(fid,'# %s: %s\n',fdir,ratios{ii});
fprintf(fid,'# cell');
for kk=1:Nc
fprintf(fid,'\tMEAN%d\tPoiss_E%d',kk,kk);
end;
end
fprintf(fid,'\n# plane');
for kk=1:Nc
fprintf(fid,'\tPOL=%d\t',pol(kk));
end;
end
fprintf(fid,'\n');
for jj=1:Np
fprintf(fid,'%d', x(jj));
fprintf(fid,'\t%.3e\t%.3e',out(jj,1:2*Nc));
fprintf(fid,'\n');
end;
end
fclose(fid);
fprintf(1,'Depth profiles of %s in defined ROIs saved as %s\n',ratios{ii},fname);
end;
end

end;
end

end;
end

% plot depth profiles
if k>0
Expand All @@ -114,16 +126,16 @@ function plot_export_ratios_depth(m, dm, cell_sizes, images, planes, opt1, opt4,
for ii=1:length(all_out)
data.y{ii}=all_out{ii}(:,[1:2:2*Nc]);
data.dy{ii}=all_out{ii}(:,1+[1:2:2*Nc]);
end;
end
data.pol=all_pol;
data.plot_flag=opt1(11);
data.ratio = all_ratios;
data.fdir = fdir;
data.print_factor = print_factor;
% here is the call to the actual GUI
depth_profiles_ratios_gui(data);
end;
end

else
fprintf(1,'*** Warning: Empty mass values. Nothing done.\n');
end;
end
1 change: 1 addition & 0 deletions src/lookatnanosims.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
% will be calculated by accumulating only the
% specified planes.
LANS_version = '2024-01-18'; % Bugs in align_external_image due to autoscale fixed.
% Zero-outside-ROIs in RGB overlay images implemented.

% name of the external image file (empty by default)
EXTERNAL_IMAGEFILE = '';
Expand Down

0 comments on commit aea8dc8

Please sign in to comment.