//Automated image analysis tools for trypanosomes //============================================================================================================================= //A set of macros for use in ImageJ // ImageJ is a free and open source cross platform piece of scientific image analysis software // For more information and to download ImageJ please visit: http://rsbweb.nih.gov/ij/ // For more information about macros in ImageJ please visit: http://rsbweb.nih.gov/ij/developer/macro/macros.html //Install these macros via "Plugins>Macros>Install" or "Ctrl+Shift+M" // //Copyright 2011 Richard J Wheeler (www.richardwheeler.net) //This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as //published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. //This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty //of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. //You should have received a copy of the GNU General Public License along with this program; if not, see //http://www.gnu.org/licenses. var slice_phase=3; var slice_dapi=1; var slice_pi=2; var image_scale=6.236; var distort_scale=1; var distort_xori=0; var distort_yori=0; var dapi_nucleus=1000; var dapi_kinetoplast=1000; var dapi_background=200; var pi_nucleus=1000; var pi_kinetoplast=2000; var pi_background=200; var analyseall=true; //Macro - Image Setup Tool //============================================================================================================================= //Global variables changed //Slice numbers // slice_phase // slice_dapi // slice_pi //Image scale // image_scale macro "Image Setup Action Tool -C888L88fcLfc8fL8f1cL1c88C00fL84f8Lf88bL8b18L1884Cf00L80f4Lf488L8814L1480" { setBatchMode(true); Dialog.create("Image Setup"); Dialog.addNumber("Phase slice number:", slice_phase, 0, 5, ""); Dialog.addNumber("DAPI slice number:", slice_dapi, 0, 5, ""); Dialog.addNumber("PI slice number:", slice_pi, 0, 5, ""); Dialog.addNumber("Image scale:", image_scale, 3, 5, "px/um"); Dialog.show(); slice_phase=Dialog.getNumber(); slice_dapi=Dialog.getNumber(); slice_pi=Dialog.getNumber(); image_scale=Dialog.getNumber(); setBatchMode(false); } //Macro - Measure Chromatic Aberation Tool //============================================================================================================================= //Global variables used //Slice numbers // slice_dapi // slice_pi //Global variables modified //PI channel distort variables // distort_scale // distort_xori // distort_yori var mcattolerance=200; var mcatmaxdist=5; macro "Measure Chromatic Aberation Action Tool -Cf88o1022Cf00o8177C00fo2322C88fo9577C000L0fffL0c0fL4d4fL8c8fLcdcfLfcff" { setBatchMode(true); //Display options printresults=false; drawplot=false; scalefactor=20; arrowwidth=8; Dialog.create("Measure Chromatic Aberation"); Dialog.addCheckbox("Analyse all images currently open", analyseall); Dialog.addMessage("Analysis options:"); Dialog.addNumber("Noise tolerance:", mcattolerance, 0, 5, ""); Dialog.addNumber("Maximum pairing distance:", mcatmaxdist, 0, 5, "px"); Dialog.addMessage("Output options:"); Dialog.addCheckbox("Print data to log", printresults); Dialog.addCheckbox("Make image plot of distortion", drawplot); Dialog.addNumber(" Scale factor:", scalefactor, 0, 5, "px/px"); Dialog.addNumber(" Arrow width:", arrowwidth, 0, 5, "px"); Dialog.show(); analyseall=Dialog.getCheckbox(); mcattolerance=Dialog.getNumber(); mcatmaxdist=Dialog.getNumber(); printresults=Dialog.getCheckbox(); drawplot=Dialog.getCheckbox(); scalefactor=Dialog.getNumber(); arrowwidth=Dialog.getNumber(); if (analyseall==true) { images=newArray(nImages()); for (n=0; nhmax) { mode=a; hmax=histogram[a]; } } sumdmode=sumdmode+mode+1; setSlice(slice_pi); getRawStatistics(area, mean, min, max, stdev, histogram); hmax=0; modepos=0; for (a=0; ahmax) { mode=a; hmax=histogram[a]; } } sumpmode=sumpmode+mode+1; } //Calculate average backgrounds tdapi_background=sumdmode/lengthOf(images); tpi_background=sumpmode/lengthOf(images); ratioso=newArray(0); dvalueso=newArray(0); pvalueso=newArray(0); for (i=0; iratiosmean-nstdev*ratiosstdev && ratioso[n]0) { nchanges=0; for (n=0; n2) { setPixel(x, y, 0); } } } } //Find all white pixels in the skeleton image with only 1 neighbour //These pixels are the branch ends nterm=0; for (x=1; xminbranch+1) { finished=1; } else { finished=0; visitx[leng]=cx; visity[leng]=cy; cx=ctx; cy=cty; } } //Erase the branch if under the minimum length if (leng<=minbranch) { for (m=0; m=w-borderdist || sy+sh>=h-borderdist) { setResult("Touching Edge (bool)", cellno, 1); } else { setResult("Touching Edge (bool)", cellno, 0); } //Analyse kinetoplasts particleno1=0; for (xa=sx; xa=3) { nbranch++; } maxwidth=maxOf(maxwidth, getPixel(xa, ya)); } } } } setResult("Skeleton length", cellno, nskeleton); setResult("Skeleton termini", cellno, ntermini); setResult("Skeleton branches", cellno, nbranch); setResult("Cell length (um)", cellno, (nskeleton+sumtermini)/image_scale); setResult("Cell width (um)", cellno, maxwidth/image_scale); //Analyse KN position relative to skeleton selectImage(masks); setSlice(4); if (ntermini==2 && nbranch==0) { skelex=newArray(nskeleton); skeley=newArray(nskeleton); skeled=newArray(nskeleton); xc=tx; yc=ty; skelepx=0; while (skelepx=0; a--) { if (array[a]==value) { index=a; } } return index; } //Macro - K/N Count Summary //============================================================================================================================= //Requires data in data table macro "K/N Count Summary Action Tool -C000T08081T4808KT88081Tc808NT0f081T4f08KT8f082Tcf08N" { exctouchedge=true; excbranchskele=true; Dialog.create("K/N Count Summary"); Dialog.addCheckbox("Exclude cells touching image edge", exctouchedge); Dialog.addCheckbox("Exclude cells with branched skeletons", excbranchskele); Dialog.show(); exctouchedge=Dialog.getCheckbox(); excbranchskele=Dialog.getCheckbox(); c1k1n=0; c1k2n=0; c2k1n=0; c2k2n=0; c1k0n=0; notcell=0; other=0; touchedge=0; branched=0; for (n=0; n