Changeset 7972
- Timestamp:
- 04/14/12 23:37:07 (8 years ago)
- Location:
- trunk/projects/flow-cytometry/src/main/java/loci/apps/flow
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/projects/flow-cytometry/src/main/java/loci/apps/flow/Find_Particle_Areas.java
r7971 r7972 7 7 import ij.plugin.Duplicator; 8 8 import ij.plugin.filter.PlugInFilter; 9 import ij.plugin.frame.RoiManager;10 9 import ij.process.ImageProcessor; 11 10 import ij.text.TextWindow; … … 23 22 private Duplicator duplicator; 24 23 private TextWindow twindow; 24 25 25 26 26 /** … … 60 60 gd.addNumericField ("Size_Minimum", 0, 0); 61 61 gd.addCheckbox("Exclude_Particles_on_Edge",true); 62 gd.addCheckbox("Show summedareas",false);63 gd.addCheckbox("Run Plugin Over EntireStack", false);64 62 gd.addCheckbox("Show_summed_areas",false); 63 gd.addCheckbox("Run_Plugin_Over_Entire_Stack", false); 64 65 65 gd.showDialog(); 66 66 if (gd.wasCanceled()) return; … … 73 73 doTheSum= gd.getNextBoolean(); 74 74 dofullStack = gd.getNextBoolean(); 75 75 76 76 //begin core program 77 77 Interpreter.batchMode=true; 78 78 79 //check option for analyze full stack first, bypass other methods if so.79 //check option for analyze full stack, bypass other methods if so. 80 80 //uses original stacked image, not single image 81 81 if (dofullStack){ … … 91 91 doTheSum(true); 92 92 93 imp.flush();94 93 imp.close(); 95 94 } 96 97 95 Interpreter.batchMode=false; 96 98 97 } catch(Exception e){ 99 98 IJ.showMessage("Error with plugin."); 100 99 e.printStackTrace(); 100 Interpreter.batchMode=false; 101 101 } 102 102 } … … 225 225 } 226 226 } 227 228 229 public static float[] inWiscScanMode(ImagePlus imageToAnalyze, boolean isIntensity, boolean excludeOnEdge, double threshMin, int minSize){ 230 float[] summedPixelAreasArray; 231 try{ 232 //if image is of intensity, do related calculations, else do brightfield calculations 233 if(isIntensity){ 234 imageToAnalyze.getProcessor().setThreshold(threshMin, 255, ImageProcessor.RED_LUT); 235 IJ.run(imageToAnalyze, "Convert to Mask", null); 236 237 if(excludeOnEdge) IJ.run(imageToAnalyze, "Analyze Particles...", "size="+minSize+"-Infinity circularity=0.00-1.00 show=Masks display exclude clear include add"); 238 else IJ.run(imageToAnalyze, "Analyze Particles...", "size="+minSize+"-Infinity circularity=0.00-1.00 show=Masks display clear include add"); 239 } 240 else{ 241 IJ.run(imageToAnalyze, "Find Edges", null); 242 IJ.run(imageToAnalyze, "Find Edges", null); 243 244 IJ.run(imageToAnalyze, "Gaussian Blur...", "sigma=5"); 245 246 IJ.runPlugIn(imageToAnalyze, "Auto Threshold", "method=Minimum white"); 247 248 if(excludeOnEdge) IJ.run(imageToAnalyze, "Analyze Particles...", "size="+minSize+"-Infinity circularity=0.00-1.00 show=Masks display exclude clear include add"); 249 else IJ.run(imageToAnalyze, "Analyze Particles...", "size="+minSize+"-Infinity circularity=0.00-1.00 show=Masks display clear include add"); 250 } 251 252 //get the pixel areas for all particles in this image as array 253 ResultsTable resTab = ResultsTable.getResultsTable(); 254 if(resTab.getCounter()>0){ 255 //get the values under the column "Area" 256 return summedPixelAreasArray = resTab.getColumn(resTab.getColumnIndex("Area")); 257 } 258 }catch(Exception e){ 259 IJ.showMessage("Error with finding particles plugin"); 260 IJ.log(e.getMessage()); 261 //fall through 262 } 263 summedPixelAreasArray=new float[1]; 264 summedPixelAreasArray[0]=0; 265 Interpreter.batchMode=false; 266 return summedPixelAreasArray; 267 268 269 } 227 270 228 271 } -
trunk/projects/flow-cytometry/src/main/java/loci/apps/flow/FlowCyto.java
r7971 r7972 16 16 import java.io.IOException; 17 17 18 18 19 public class FlowCyto { 19 20 … … 27 28 // private static String s_Name, s_Experiment, s_Params, s_Date, tempImageName; 28 29 private static double pixelMicronSquared; 29 private static RoiManager rman;30 private static ResultsTable rtab;31 30 private static byte[] dummyData; 32 31 … … 55 54 56 55 try{ 57 IJ.run("Close All");56 // IJ.run("Close All"); 58 57 WindowManager.closeAllWindows(); 59 58 imagej.quit(); … … 163 162 164 163 @SuppressWarnings("static-access") 165 public static void showImage( Stringmode, int width, int height, byte[] imageData) {164 public static void showImage(int mode, int width, int height, byte[] imageData) { 166 165 try{ 167 166 long initialTime = System.nanoTime(); 168 167 bp = new ByteProcessor(width,height,imageData, theCM); 169 168 bp.createImage(); 170 mode = mode.toLowerCase(); 171 if ("brightfield".equals(mode)) { 169 170 //brightfield 171 if (mode == 1) { 172 172 stackBF.addSlice("Slice "+nSlicesBF, bp); 173 173 impBF.setStack("Brightfield Images", stackBF); … … 177 177 nSlicesBF++; 178 178 //-----------------------FOR DEBUG PURPOSES--------------------// 179 IJ.log("brightfield image "+nSlicesBF+" displayed in "+ ((System.nanoTime() - initialTime)/1000 ) +"us");179 IJ.log("brightfield image "+nSlicesBF+" displayed in "+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 180 180 //-------------------------------------------------------------// 181 181 } 182 else if ("intensity".equals(mode)) { 182 183 //intensity 184 else if (mode == 2) { 183 185 stackIN.addSlice("Slice "+nSlicesIN, bp); 184 186 impIN.setStack("Intensity Images", stackIN); … … 188 190 nSlicesIN++; 189 191 //-----------------------FOR DEBUG PURPOSES--------------------// 190 IJ.log("intensity image "+nSlicesIN+" displayed in "+ ((System.nanoTime() - initialTime)/1000 ) +"us");192 IJ.log("intensity image "+nSlicesIN+" displayed in "+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 191 193 //-------------------------------------------------------------// 192 194 } 195 196 //default 193 197 else { 194 198 stack.addSlice("Slice "+nSlices, bp); … … 206 210 207 211 @SuppressWarnings("static-access") 208 public static float[] getParticleAreas(boolean isIntensityImage, boolean excludeOnEdge, double thresholdMin, int sizeMin){ 212 public static boolean foundParticle(boolean isIntensityImage, boolean excludeOnEdge, double thresholdMin, int sizeMin, float compareTOLow, float compareTOHigh){ 213 214 //-----------------------FOR DEBUG PURPOSES--------------------// 209 215 long initialTime = System.nanoTime(); 216 IJ.log("Gating method started on slice "+nSlicesIN+" at \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 217 //-------------------------------------------------------------// 218 219 float[] summedPixelAreasArray; 210 220 Interpreter.batchMode=true; 211 221 212 222 try{ 213 214 223 if(isIntensityImage){ 215 224 try{ 216 if(excludeOnEdge) IJ.run(impIN, "Find Particle Areas", "channel=Intensity threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+" exclude_particles_on_edge"); 217 else IJ.run(impIN, "Find Particle Areas", "channel=Intensity threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+""); 218 //-----------------------FOR DEBUG PURPOSES--------------------// 219 IJ.log("plugin finished on intensity image "+nSlicesIN+" in "+ ((System.nanoTime() - initialTime)/1000) +"us"); 220 //-------------------------------------------------------------// 221 222 }catch(Exception e){ 223 if(excludeOnEdge)IJ.run(imp, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+" exclude_particles_on_edge"); 224 else IJ.run(imp, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+""); 225 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(impIN, true, excludeOnEdge, thresholdMin, sizeMin); 226 227 //-----------------------FOR DEBUG PURPOSES--------------------// 228 IJ.log("plugin finished on intensity image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 229 //-------------------------------------------------------------// 230 231 }catch(Exception e){ 232 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(imp, true, excludeOnEdge, thresholdMin, sizeMin); 233 234 //-----------------------FOR DEBUG PURPOSES--------------------// 235 IJ.log("plugin finished on ISLET DEFAULT image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 236 //-------------------------------------------------------------// 237 225 238 } 226 239 } 227 240 else { 228 241 try{ 229 if(excludeOnEdge)IJ.run(impBF, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+" exclude_particles_on_edge");230 else IJ.run(impBF, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+""); 231 //-----------------------FOR DEBUG PURPOSES--------------------// 232 IJ.log("plugin finished on brightfield image "+nSlicesBF+" in "+ ((System.nanoTime() - initialTime)/1000) +"us");242 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(impBF, false, excludeOnEdge, thresholdMin, sizeMin); 243 244 //-----------------------FOR DEBUG PURPOSES--------------------// 245 IJ.log("plugin finished on brightfield image "+nSlicesBF+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 233 246 //-------------------------------------------------------------// 234 247 235 248 }catch(Exception e){ 236 if(excludeOnEdge)IJ.run(imp, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+" exclude_particles_on_edge"); 237 else IJ.run(imp, "Find Particle Areas", "channel=Brightfield threshold_minimum="+thresholdMin+" size_minimum="+sizeMin+""); 238 } 239 } 240 241 rman = RoiManager.getInstance2(); 242 if(rman.getCount()>0){ 243 rman.runCommand("Measure"); 244 rtab = ResultsTable.getResultsTable(); 245 246 float[] areasArray = rtab.getColumn(rtab.getColumnIndex("Area")); 247 248 if(areasArray!=null){ 249 250 // rtab.reset(); 251 // rman.runCommand("Deselect"); 252 // rman.runCommand("Delete"); 253 254 //-----------------------FOR DEBUG PURPOSES--------------------// 255 IJ.log("particle areas calculated in "+ ((System.nanoTime() - initialTime)/1000) +"us"); 256 //-------------------------------------------------------------// 257 258 return areasArray; 259 } 260 261 rman.runCommand("Deselect"); 262 rman.runCommand("Delete"); 263 } 249 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(imp, false, excludeOnEdge, thresholdMin, sizeMin); 250 251 //-----------------------FOR DEBUG PURPOSES--------------------// 252 IJ.log("plugin finished on ISLET DEFAULT image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 253 //-------------------------------------------------------------// 254 255 } 256 } 257 258 //-----------------------FOR DEBUG PURPOSES--------------------// 259 IJ.log("particle areas calculated in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 260 //-------------------------------------------------------------// 261 262 for(int i=0; i<summedPixelAreasArray.length;i++) 263 { 264 if(summedPixelAreasArray[i] >= compareTOLow && summedPixelAreasArray[i] <= compareTOHigh){ 265 266 //-----------------------FOR DEBUG PURPOSES--------------------// 267 IJ.log("gating boolean -TRUE- calculated in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 268 //-------------------------------------------------------------// 269 //-----------------------FOR DEBUG PURPOSES--------------------// 270 IJ.log("_"); 271 //-------------------------------------------------------------// 272 273 return true; 274 } 275 276 277 278 } 279 280 //-----------------------FOR DEBUG PURPOSES--------------------// 281 IJ.log("gating boolean -FALSE- calculated in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 282 //-------------------------------------------------------------// 283 //-----------------------FOR DEBUG PURPOSES--------------------// 284 IJ.log("_"); 285 //-------------------------------------------------------------// 286 return false; 264 287 }catch (Exception e){ 265 //fall through 266 } 267 268 float[] defaultVal = new float[1]; 269 Interpreter.batchMode=false; 270 defaultVal[0]=0; 271 return defaultVal; 288 IJ.log("Problem in getting particle areas"); 289 IJ.log(e.getMessage()); 290 } 291 return false; 292 } 293 294 @SuppressWarnings("static-access") 295 public static float getSumOfParticleAreas(boolean isIntensityImage, boolean excludeOnEdge, double thresholdMin, int sizeMin){ 296 297 //-----------------------FOR DEBUG PURPOSES--------------------// 298 long initialTime = System.nanoTime(); 299 IJ.log("Pixel areas summing method started on slice "+nSlicesIN+" at \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 300 //-------------------------------------------------------------// 301 float summedPixelAreas=0; 302 float[] summedPixelAreasArray; 303 Interpreter.batchMode=true; 304 305 try{ 306 if(isIntensityImage){ 307 try{ 308 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(impIN, true, excludeOnEdge, thresholdMin, sizeMin); 309 310 //-----------------------FOR DEBUG PURPOSES--------------------// 311 IJ.log("plugin finished on intensity image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 312 //-------------------------------------------------------------// 313 314 }catch(Exception e){ 315 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(imp, true, excludeOnEdge, thresholdMin, sizeMin); 316 317 //-----------------------FOR DEBUG PURPOSES--------------------// 318 IJ.log("plugin finished on ISLET DEFAULT image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 319 //-------------------------------------------------------------// 320 321 } 322 } 323 else { 324 try{ 325 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(impBF, false, excludeOnEdge, thresholdMin, sizeMin); 326 327 //-----------------------FOR DEBUG PURPOSES--------------------// 328 IJ.log("plugin finished on brightfield image "+nSlicesBF+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 329 //-------------------------------------------------------------// 330 331 }catch(Exception e){ 332 summedPixelAreasArray=Find_Particle_Areas.inWiscScanMode(imp, false, excludeOnEdge, thresholdMin, sizeMin); 333 334 //-----------------------FOR DEBUG PURPOSES--------------------// 335 IJ.log("plugin finished on ISLET DEFAULT image "+nSlicesIN+" in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 336 //-------------------------------------------------------------// 337 338 } 339 } 340 341 for(int i=0; i<summedPixelAreasArray.length; i++){ 342 summedPixelAreas+=summedPixelAreasArray[i]; 343 } 344 }catch (Exception e){ 345 IJ.log("Problem in getting particle areas"); 346 IJ.log(e.getMessage()); 347 } 348 349 //-----------------------FOR DEBUG PURPOSES--------------------// 350 IJ.log("pixel areas sum calculated in \t \t \t"+ ((System.nanoTime() - initialTime)/1000000) +"ms"); 351 //-------------------------------------------------------------// 352 //-----------------------FOR DEBUG PURPOSES--------------------// 353 IJ.log("_"); 354 //-------------------------------------------------------------// 355 356 return summedPixelAreas; 272 357 } 273 358
Note: See TracChangeset
for help on using the changeset viewer.