function showmeshcollection(emesh, conn, src, varargin) % Provided as is % Used as utility function to display meshes in TImrf2 x_pan = 1; y_pan = 8; show_img = 0; mesh_adjust = 0; src_idx = []; symbols = {}; if ~isempty(varargin), var=1; while var <= length(varargin), switch varargin{var} case 'mesh_adjust' var = var+1; mesh_adjust = varargin{var}; case 'src_index' var = var+1; src_idx = varargin{var}; case 'symbols' var = var+1; symbols = varargin{var}; otherwise error('Unknown argument: %s', varargin{var}); end var = var + 1; end end % check if source is an index, struct or staining values if isvector(src), % source is index % -> create artificial source source.idx = src; source.stain = emesh.stain(:, src); source.dmesh = []; elseif isstruct(src) % source is already a struct source = src; else % source is a matrix containing emesh.stain like values if isempty(src_idx) source.idx = 1:size(src,2); else source.idx = src_idx; end source.stain = src; source.dmesh = []; end same_pan = 1; if show_img > 0, x_pan = x_pan + 1; same_pan = same_pan + 1; end if ~isempty(source.dmesh), x_pan = x_pan + 1; same_pan = same_pan + 1; end % if only meshes are displayed, display 5 in a row if x_pan == 1, x_pan = 5; panels = x_pan * y_pan; else panels = y_pan; end clus_memb = 1:length(source.idx); % clus_pan = length(clus_memb); j = 0; while j < length(clus_memb), figure; final_panel = j+panels; if final_panel > length(clus_memb), final_panel = length(clus_memb); end for i=j+1:final_panel if isempty(conn), if isempty(symbols) sym{1} = ''; else sym{1} = symbols{i}; end else sym=pg_query(conn,0, pg_insitus('symbol'),emesh.files{source.idx(clus_memb(i))}); fprintf('%d = %s\n', clus_memb(i), sym{1}); end this_panel = i-j + ((i-j) - 1) * (same_pan - 1); this_panel_inc = 1; subplot(y_pan,x_pan,this_panel); displaymesh(source.stain(:,clus_memb(i)), emesh.p_scale, emesh.t, mesh_adjust); title(sprintf('%s', sym{1})); if ~isempty(source.dmesh), subplot(y_pan,x_pan,this_panel+this_panel_inc); displaymesh(abs(255 - source.dmesh(:,clus_memb(i)) .* 255), emesh.p_scale, emesh.t); this_panel_inc = this_panel_inc + 1; end if show_img > 0, subplot(y_pan,x_pan,this_panel+this_panel_inc); displayimage(conn, emesh.files{source.idx(clus_memb(i))}); title(sprintf('%s', emesh.files{source.idx(clus_memb(i))})); this_panel_inc = this_panel_inc + 1; end end j = j+panels; end end