CellAndSpotDetection_Improved.ijm 1.58 KB
Newer Older
Christian Tischer's avatar
Christian Tischer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
// close all windows
closeEverything();

// hide windows during run (much faster!!)
//setBatchMode(true);

// find cells
open("/Users/tischi/Dropbox/Presentations_Courses/2015--Tischi--Kopenhagen/0000--PracticalImagej/data/autophagosomes/autophagosomes_raw.tif");
run("Gaussian Blur...", "sigma=10");
rename("blurredImage");
run("Find Maxima...", "noise=50 output=[Segmented Particles]");
rename("cells");
selectWindow("blurredImage");
setThreshold(230, 714);
setOption("BlackBackground", false);
run("Convert to Mask");
rename("foreground");
imageCalculator("AND create", "foreground","cells");
run("Analyze Particles...", "size=100-Infinity exclude add");

// find spots
open("/Users/tischi/Dropbox/Presentations_Courses/2015--Tischi--Kopenhagen/0000--PracticalImagej/data/autophagosomes/autophagosomes_raw.tif");
rename("raw");
run("Duplicate...", "title=median_bg");
run("Median...", "radius=5");
imageCalculator("Subtract create", "raw","median_bg");
run("Find Maxima...", "noise=70 output=[Single Points]");
run("Divide...", "value=255");
rename("spots.tif");

// measure spots and save results
selectWindow("spots.tif");
roiManager("Measure");
saveAs("Results", "/Users/tischi/Dropbox/Presentations_Courses/2015--Tischi--Kopenhagen/0000--PracticalImagej/data/autophagosomes/spot_count.csv");


// functions ////////////////////////////////////////////////

function closeEverything() {
	
  // closes all image windows 
  close("*");

  // closes all non-image windows
  list = getList("window.titles"); 
  for (i=0; i<list.length; i++) { 
	winame = list[i]; 
    selectWindow(winame); 
    run("Close"); 
  } 
	
}