function unrollmesh(stain, p_scale, t, varargin) % unrollmesh(stain, p_scale, t, ypos_init) % shows linearized mesh with the embryo % if ypos_init is given, only the linearized mesh is shown, hold remains on % ypos_init is the location of the linearized mesh starting with 0, % increments of 1 % NO_EMBRYO = 0; if ~isempty(varargin) if length(varargin) == 1, NO_EMBRYO = 1; ypos_init = varargin{1}; else i = 1; while i <= length(varargin), switch(varargin{i}), case 'ypos' i = i+1; ypos_init = varargin{i}; case 'adjust' i = i+1; s otherwise error('Argument %s not known', varargin{i}); end end i = i+1; end end if nargin > 3 NO_EMBRYO = 1; end line_width = 5; colormap(gray); caxis([1 255]) axis ij; axis off; hold on; xpos = min(p_scale(:,1)); xinc = (max(p_scale(:,1)) - min(p_scale(:,1))) / length(t); if NO_EMBRYO == 1, ypos = line_width * ypos_init; else ypos = max(p_scale(:,2)) + (max(p_scale(:,2)) - min(p_scale(:,2))) * 0.1; end x = [xpos xpos + xinc]; y = [ypos ypos]; y2 = y + [line_width line_width]; for i = 1:size(stain,1) co = stain(i) / 255; roic = [x fliplr(x)]; roir = [y y2]; fill(roic,roir,stain(i), 'EdgeColor', [co co co]); %line(x, y, 'color', [co co co], 'LineWidth', line_width ); x = x + [xinc xinc]; if NO_EMBRYO == 0, roic = fix(p_scale(t(i,:),1)'); roir = fix(p_scale(t(i,:),2)'); fill(roic,roir,stain(i), 'EdgeColor', [co co co]); end end; if NO_EMBRYO == 0, hold off; end; end function [adj] = adj_mesh(toadj, rmin, rmax) to_r = range(toadj); to_min = min(toadj); adj_r = abs(rmax - rmin); adj = abs(rmin - ((toadj - to_min) .* (adj_r / to_r))); adj(adj > 255) = 255; end