/* This ImageJ macro filters volumes in 3D using Analyze Particles and TransformJ. To operate it you need to download and install the TransformJ package (Erik Meijering: http://www.imagescience.org/meijering/software/transformj/) It filters elements having Cartesian surfaces XY, YZ and ZX lower than an independent threshold defined by the operator for each of the 3 planes. It works with isotropic, binary stacks made by a set of square (mandatory!) images and filters cubic as well as prismatic volumes. v. 0.1.0 del 24/12/2010 v. 0.2.0 del 30/12/2010 now works with prisms This macro filters all the volumes, with equal dimensions, grouped in a folder. */ macro "FiltraCubi 3D" {volfilter();} function volfilter() { requires("1.42l"); // Setup Dialog.create("Setup"); bool = newArray("OR","AND"); sogliaX = 4; sogliaY = 4; sogliaZ = 4; Dialog.addMessage("Size filtering of cubic volumes\nSet the minimum size of pixels for each plane"); Dialog.addMessage("\n"); Dialog.addNumber("\t\tPlane XY: ", sogliaZ); Dialog.addNumber("\t\tPlane YZ: ", sogliaY); Dialog.addNumber("\t\tPlane XZ: ", sogliaX); Dialog.addChoice("Choice for filtering",bool,"OR") Dialog.addMessage("OR: it will remove objects with surfaces under\n\tthreshold in all the 3 planes."); Dialog.addMessage("AND: it will remove objects with surfaces under\n\tthreshold in at least 1 plane."); Dialog.show(); sogliaZ = Dialog.getNumber(); sogliaY = Dialog.getNumber(); sogliaX = Dialog.getNumber(); mod = Dialog.getChoice(); if (mod == "AND") { } else{ if (mod == "OR") { } else { exit("Filtering choice unknown!"); } } // Set date and time getDateAndTime(year, month, week, day, hour, minu, sec, msec); mese = month+1; setBatchMode(true); // Choice of the source folder dir1 = getDirectory("Select input folder"); dirtit = File.getName(dir1); list = getFileList(dir1); // Choice of the folder where to save the filtered stacks. dir2 = getDirectory("Where should I save the filtered stacks?"); for (st=0; st DimZ) { setSlice(DimZ); for (i=0; i0) { setSlice(DimX); for (i=0; i