/** * Zebrafish Embryo Tools * Collaborator: * Eduardo RIOS MORRIS * * Normalize the orientation of the images of the Zebrafish * embryos, find the point of injection of tumor cells and * measure the distribution of Cy3 stained tumor foci. * * ImageJ implementation inspired by the protocol described in: * Ghotra VPS, He S, de Bont H, van der Ent W, Spaink HP, van de Water B, et al. * Automated Whole Animal Bio-Imaging Assay for Human Cancer Dissemination. * RĂ©nia L, editor. PLoS ONE. 2012 Feb 8;7(2):e31281. * (c) 2014, INSERM * written by Volker Baecker at Montpellier RIO Imaging (www.mri.cnrs.fr) * */ var helpURL = "http://dev.mri.cnrs.fr/wiki/imagej-macros/Zebrafish_Embryo_Tools" var _THRESHOLD_METHOD = "Mean"; var _MIN_OBJECT_SIZE = 80; var _HORIZONTAL_ORIENTATION = true; var _VERTICAL_ORIENTATION = true; var _USE_FILTER = true; var _MEAN_FILTER_RADIUS = 2; var _LENGTH_RATIO = 0.75; var _BOX_RADIUS_HORIZONTAL = 20; var _BOX_HEIGHT = 80; var _FILE_EXT = ".tif"; var _OUT_FOLDER = "normalized"; macro "MRI Zebrafish Embryo Tools Help Action Tool - C000D0fD34D66Db0Db1DbfDc0Dc1DceDcfDd0Dd1Dd2DddDdeDdfDe0De2De3DedDeeDefDf4Df6Df7Df8DfdDfeDffC080D00D0eD17D19D2aD39D46D54D55D60D62D71D72D84D95D96D98DaaDb9Dd8C030D25D29D3fD47D48D4fD56D65D68D73D79D91D94Da2Da5Da9Db5Db6Db7De8C0e0D03D07D11D12D13D21D22D2eD36D3bD3eD4eD5aD9bDabDbcDcaDccDdaC020D2fD44D63D69D78D80D83D87D88D90D93Da1Da3Db2Db3Dc3Dd3Dd4De5De6De7C0b0D01D10D16D20D30D31D32D40D4aD61D64D6bD74D7aD8bDbaDc8Dd9C060D35D3aD50D52D59D67D70D77D82D85D86D89D97D9aDa6Da7Da8C1f0D09D0dD1aD1cD2bD2cD4cD4dD5eD6eD7eD8cD9dDebC010D1fD43D53D58Da0Da4Dc2De1De4Df0Df1Df2Df3Df5C090D15D23D26D27D38D42D45D49D51D7bD8aD8fD99DaeDc7Dd6DdcC040D18D24D28D33D57D75D76D81D92Db4Db8DbeDcdDe9C0f0D04D05D06D1dD2dD3cD3dD9cDacDadDbbDcbDdbC110DafDf9DfcC0c0D02D14D1eD37D41D4bD5bD6aDbdDc6Dc9DeaC240D5fD6fD7fD9fDc4Dc5Dd5Dd7DecDfaDfbC3f0D08D0aD0bD0cD1bD5cD5dD6cD6dD7cD7dD8dD8eD9e"{ run('URL...', 'url='+helpURL); } macro "Normalize Orientation (f1) Action Tool - C000T4b12n" { normalizeImage(); } macro "Batch Normalize images (f2) Action Tool - C000T4b12b" { batchNormalizeImages(); } macro "normalize orientation [f1]" { normalizeImage(); } macro "batch normalize images [f2]" { batchNormalizeImages(); } macro "Normalize Orientation (f1) Action Tool Options" { Dialog.create("Normalize Orientation Options"); Dialog.addChoice("thresholding method: ", newArray("Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"), _THRESHOLD_METHOD); Dialog.addNumber("min. object size: ", _MIN_OBJECT_SIZE); Dialog.addCheckbox("normalize horizontal orientation", _HORIZONTAL_ORIENTATION); Dialog.addCheckbox("normalize vertical orientation", _VERTICAL_ORIENTATION); Dialog.addCheckbox("smooth image", _USE_FILTER); Dialog.addNumber("radius of filter: ", _MEAN_FILTER_RADIUS); Dialog.addNumber("fish length ratio: ", _LENGTH_RATIO); Dialog.addNumber("horizontal radius of box", _BOX_RADIUS_HORIZONTAL); Dialog.addNumber("height of box", _BOX_HEIGHT); Dialog.show(); _THRESHOLD_METHOD = Dialog.getChoice(); _MIN_OBJECT_SIZE = Dialog.getNumber(); _HORIZONTAL_ORIENTATION = Dialog.getCheckbox(); _VERTICAL_ORIENTATION = Dialog.getCheckbox(); _USE_FILTER = Dialog.getCheckbox(); _MEAN_FILTER_RADIUS = Dialog.getNumber(); _LENGTH_RATIO = Dialog.getNumber(); _BOX_RADIUS_HORIZONTAL = Dialog.getNumber(); _BOX_HEIGHT = Dialog.getNumber(); } macro "Batch Normalize images (f2) Action Tool Options" { Dialog.create("Batch Processing Options"); Dialog.addString("image extension: ", _FILE_EXT); Dialog.addString("name of output folder: ", _OUT_FOLDER); Dialog.show(); _FILE_EXT = Dialog.getString(); _OUT_FOLDER = Dialog.getString(); } function normalizeImage() { setBatchMode(true); id = getImageID(); createWorkingImageAndSelection(); run("Set Measurements...", "fit redirect=None decimal=3"); run("Measure"); angle = getResult("Angle", nResults-1); close(); selectImage(id); run("Rotate... ", "angle="+angle+" grid=1 interpolation=Bilinear enlarge"); if (_HORIZONTAL_ORIENTATION) normalizeHorizontalOrientation(); if (_VERTICAL_ORIENTATION) normalizeVerticalOrientation(); run("Select None"); setBatchMode("exit and display"); } function batchNormalizeImages() { print("\\Clear"); sourceDir = getDirectory("Choose the source directory"); files = getFileList(sourceDir); images = filterImageFiles(files); logStart("batch normalize zebra fish embryos"); File.makeDirectory(sourceDir + _OUT_FOLDER); for (i=0; i1) run("Stack to RGB"); else run("Duplicate...", " "); run("8-bit"); if (_USE_FILTER) run("Mean...", "radius="+_MEAN_FILTER_RADIUS); setAutoThreshold("Mean dark"); run("Analyze Particles...", "size="+_MIN_OBJECT_SIZE+"-Infinity show=Masks exclude in_situ"); run("Close-"); run("Fill Holes"); run("Analyze Particles...", "size="+(10*_MIN_OBJECT_SIZE)+"-Infinity show=Masks exclude in_situ"); run("Create Selection"); } function normalizeHorizontalOrientation() { id = getImageID(); createWorkingImageAndSelection(); run("Set Measurements...", "centroid center redirect=None decimal=3"); close(); selectImage(id); run("Restore Selection"); run("Measure"); xCentroid = getResult("X", nResults-1); xCenterOfMass = getResult("XM", nResults-1); if (xCenterOfMass=0 && !found; y--) { value = getPixel(xs, y); if (value==255) { found=true; yMax = y; } } found = false; yMin = 0; for (y=0; ylowerIntensity) run("Flip Vertically"); } function filterImageFiles(files) { images = newArray(0); for (i=0; i