Commit 7df7da5e authored by rhaase's avatar rhaase

Merge branch 'imagej_macro2' into 'master'

Imagej macro2

See merge request !3
parents ad6411ee 0fb33929
// configuration
folder = "C:/structure/teaching/lecture_applied_bioimage_analysis/05_example_data/rounding_assay/";
image_file = "rounding_assay0035.tif";
result_csv_file = "summary.csv";
// configure measurement
run("Set Measurements...", "fit shape redirect=None decimal=3");
// process imagge
open(folder + image_file);
setAutoThreshold("MaxEntropy dark");
setOption("BlackBackground", true);
run("Convert to Mask");
// get rid of single pixels
run("Erode");
run("Dilate");
// measure properties
run("Analyze Particles...", "summarize");
// save the result table
IJ.renameResults("Summary", "Results");
saveAs("Results", folder + result_csv_file);
// configuration
folder = "C:/structure/teaching/lecture_applied_bioimage_analysis/05_example_data/rounding_assay/";
result_csv_file = "summary.csv";
// configure measurement
run("Set Measurements...", "fit shape redirect=None decimal=3");
// retrieve all files in the folder in an array
filelist = getFileList(folder);
for (i = 0; i < lengthOf(filelist); i++) {
image_file = filelist[i];
if ( endsWith(image_file, ".tif")) {
// process imagge
open(folder + image_file);
setAutoThreshold("MaxEntropy dark");
setOption("BlackBackground", true);
run("Convert to Mask");
// get rid of single pixels
run("Erode");
run("Dilate");
// measure properties
run("Analyze Particles...", "summarize");
close();
}
}
// save the result table
IJ.renameResults("Summary", "Results");
saveAs("Results", folder + result_csv_file);
path = "C:/structure/teaching/lecture_applied_bioimage_analysis/06_example_code/test.csv";
headline = "Number, number squared";
File.append(headline, path);
for (i = 0; i < 10; i++) {
contentline = "" + i + ", " + pow(i, 2);
File.append(contentline, path);
}
// This script analyses a time lapse of images showing yeast cells.
// It measures their size and visualises
// cells in different colors depending on their features:
// * red: too small
// * green: others
//
//
// Robert Haase, rhaase@mpi-cbg.de
// May 2019
// open an image from the rounding assay
open("C:/structure/teaching/lecture_applied_bioimage_analysis/05_example_code_and_data/rounding_assay/rounding_assay0004.tif");
// save the window title for later - we want to switch to this image
original_image_title = getTitle();
// duplicate the image and segment it
run("Duplicate...", " ");
setAutoThreshold("Triangle dark");
run("Convert to Mask");
// binary closing
run("Dilate");
run("Dilate");
run("Erode");
run("Erode");
// connected components analysis -> send results to ROI Manager
run("Analyze Particles...", " show=Nothing add");
// switch back to original image
selectWindow(original_image_title);
roiManager("Show None");
number_of_regions = roiManager("count");
for (i = 0; i < number_of_regions; i++ ) {
// measure area ( = pixel count)
run("Set Measurements...", "area redirect=None decimal=3");
roiManager("Select", i);
roiManager("Measure");
pixel_count = getResult("Area", nResults - 1);
// visualise if ROIs are too small or not
if (pixel_count > 10) {
Overlay.addSelection("green");
} else {
Overlay.addSelection("red");
}
}
// clean up after the job is done
if (number_of_regions > 0) {
roiManager("deselect");
roiManager("delete");
}
run("Clear Results");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment