Last active
August 29, 2015 13:57
-
-
Save kmader/9638236 to your computer and use it in GitHub Desktop.
Some of the starting code for exercises related to the Single Object Analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% start Fiji interface | |
cur_dir=pwd; | |
Miji | |
% for some reason the miji script changes directory so this changes it back | |
cd(cur_dir); | |
% create the simulated image | |
[outImage,out_pos,out_shape,out_theta] = cell_simulator(100,10,3,0,1); | |
% send the image to FIJI | |
MIJ.createImage('test',outImage,true); | |
% set a threshold (yes the programmer spelled it incorrectly) | |
MIJ.setTreshold(0,253); | |
% convert the image to a binary image using the threshold | |
MIJ.run('Convert to Mask') | |
% invert the lookup table (LUT) so that black is 0 and white is 255 | |
MIJ.run('Invert LUT'); | |
% Use the Analyze Particles feature to count the objects | |
MIJ.run('Invert'); % it requires an inverted image (objects are 0, holes are 255) | |
MIJ.run('Set Measurements...', 'area centroid perimeter bounding fit shape stack redirect=None decimal=3'); | |
MIJ.run('Analyze Particles...', 'show=Ellipses display clear'); | |
% Get the names of the output | |
shapeColNames=MIJ.getListColumns; | |
% Get the results table | |
shapeAnalysis=MIJ.getResultsTable; | |
% get the area column from the shape analysis | |
analysisArea=shapeAnalysis(:,1); | |
% calculate the histograms for the final area distribution | |
[inCounts,inAreas]=hist(pi*out_shape(:,1).*out_shape(:,2)); | |
[outCounts,outAreas]=hist(shapeAnalysis(:,1),inAreas); | |
% close all the other windows | |
close all | |
% plot the histograms in figure 1 | |
figure(1) | |
plot(inAreas,inCounts,'r-',outAreas,outCounts,'b-') | |
legend({'Model Areas','Calculated Areas'}) | |
xlabel('Pixel Count') | |
ylabel('Cell Count') | |
% show the positions in figure 2 | |
figure(2) | |
plot(out_pos(:,1),out_pos(:,2),'r.',shapeAnalysis(:,2),shapeAnalysis(:,3),'b+') | |
legend({'Model Position','Calculated Position'}) | |
xlabel('X Position') | |
ylabel('Y Position') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment