/* 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/) This macro identifies vessels of different caliber in square-based image stacks and map them to 6 new output stacks on the basis of a set of predefined thresholds. As a first step this macro filters an input stack removing all surfaces less than an increasing set of thresholds and saving a full stack for every filtering step. This passage is performed in 3D rotating the input volume by means of the TransformJ utility and using the standard ImageJ Analyze Particles command to perform filtration on each cartesian plane. Filtered stacks are then tilted back to their original orientation and merged using the intersection operator AND. Serial subtraction of increasingly filtered volumes provides a set of stacks mapping the location of vascular components with cross sections comprised between 2 consecutive filter thresholds. In this macro, thresholds are defined in geometrical sequence starting with the value of 4 (values 4, 8, 16, 32, 64, 128, 256). Given the scale of the image, these thresholds may represent vessels with different calibers and functions. */ macro "FiltraCubi 3D" {volfilter();} function volfilter() { requires("1.42l"); // Dialog window to inform of pre-setted parameters Dialog.create("Macro Settings"); Dialog.addMessage("Calibrometry of square-based volumes\n"); Dialog.addMessage("\n"); Dialog.addMessage("Thresholds are based on: 4\n"); Dialog.show(); prosoglia = newArray(4,8,16,32,64,128,256); // Start stopwatch getDateAndTime(year, month, week, day, hour, minu, sec, msec); mese = month+1; setBatchMode(true); // Ask for folder collecting the volumes to filter dir1 = getDirectory("Select the analysis folder"); dirtit = File.getName(dir1); list = getFileList(dir1); // Ask for the folder where to save the filtered volumes 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"+inTitle); close(); } // End of the macro setBatchMode(false); showMessage("End of the Elaboration"); }