Beta Version CountMe

by

 

for minicell image analysis

CountMe("array with known minicell counts",
%{ 
version1.
 
Works with ProcessMe and ProcessNewImages Scripts  


October 25th 2013. Contact: Chris Cai, University of Virginia iGem 

command line syntex
function YayData = CountMe("array with known minicell counts",
"folder title with calibration images", "folder title with new images") 


Description 
-Pass to this program  images of minicells with known counts. 
-This program will then use a Support Vector Machine program to count
minicells in images with UNKNOWN counts 

Program Steps   

1) read in images in open file.
Known Minicells counts will be passed using maxsize array. 
    -The convention for this array is ...
    [number of minicells, total cells; number of minicells, total
    cells....etc.]
    -this program reads in all jpg files in the current folder as CALIBRATION
    IMAGES 
    -have all the calibration images in a folder titled 'calibration' 
    -have all the analysis images in a folder titled "analysis' 

2) process images with 
    -contrast adjustment,
    -thresholding,
    -structural element (to remove glare) 
    -and other techniques 

3)Read in unknown images 
 
4) Process unknown images using the techniques above and return
predictions. 




%} 



function YayData = CountMe(maxsize,calibrationFolder,analysisFolder) 

[m,n]=size(maxsize); 

numCells=[]; 
iter=1; 

%convert the number of known minicells to a format accepted by the SVM 

for q=1:m 
    runningMiniCount=maxsize(q,1); 
    runningZeroCount=maxsize(q,2)-maxsize(q,1); 
    
    for z=1:numel(runningZeroCount) 
        
        numCells(iter)=0; 
        iter=iter+1; 
    end 
    
    for h=1:numel(runningMiniCount)
        numCells(iter)=1; 
        iter=iter+1; 
    end 
    
end 



%%Minicell Counting! 
clc; % Clear command window.
clear all; % Get rid of variables from prior run of this m-file.
disp('About to Count some Muthafucking Minicells. Wait a long ass time'); % Message sent to command window.
tic
workspace; % Show panel with all the variables. 

% Read in multiple images for calibration. Store in a cell array 



calibrationFiles = dir(calibrationFolder);      
nfiles = length(calibrationFiles); % Number of files found
calibration=cell(nfiles,1); 

for ii=1:nfiles
   currentfilename = calibrationFiles(ii).name;
   currentimage = imread(currentfilename);
   calibration{ii} = currentimage;
end


%% 
%*************************************************************************

%image analysis of calibration is outsourced to other function. 
%Must process images so true counts have corresponding rows 
caliMat1=[]; 
caliMat2=[]; 
caliMat=ProcessMe(calibration, numCells); 

%**************************************************************************
%% 
% train the SVM 

training=caliMat(:,1); 
Group=caliMat(:,2);  

SVMStruct = svmtrain(training,Group) ; 

 %calibrate the machine. Currently set for default values. 
 
 
 %Now read in images that you want to count.  Run them through the same
 %analysis 
  
 analysisFiles = dir(analysisFolder);      
nfiles2 = length(analysisFiles); % Number of files found
analysis=cell(nfiles2,1); 

for jj=1:nfiles2
   currentfilename = canalysisFiles(ii).name;
   currentimage = imread(currentfilename);
   analysis{jj} = currentimage;
end
countMeMat=ProcessNewImages(countMe);  

 
 % Now that you've processed the new images, run them through the SVM 

YayData = svmclassify(SVMStruct,countMeMat);  



toc 

Contact us