function [] = mask2image(Masks, Image) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Makes an overlaid image of the segmented neuron masks to lie over an image %of the field of view % Inputs: % - Masks: MxNxnNeuron matrix of the individual neuron masks % - Image: The image to show underneath the masks % Output: % - a plotted image showing the masks and field of view %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [a b num_traces] = size(Masks); video_avg = Image; scaledvidave = video_avg/max(video_avg(:)); RGBvidave = cat(3, scaledvidave, scaledvidave, scaledvidave); imagesc(RGBvidave); %Make the 3 channel image green = cat(3, ones(size(video_avg))*48/255, ones(size(video_avg))*183/255, ones(size(video_avg))*38/255); hold on %create the alpha layer h = imagesc(green); hold off Masks = sum(Masks, 3); Masks(find(Masks)) = 1; %Set the alpha layer to only be drawn where masks are. What Masks is %multiplied by sets the opacity. set(h, 'AlphaData', Masks*0.2); end