/* WormBox */ macro "Unused Tool - " {} macro "Load ROI for image Action Tool - C520D4bDa5DaeC210Da7Ca53D5cD5dD7bC631D5eC420DafC777D66C530D99Da4C420D22D31D4eD5fD91D9aDa2Da3Da6DcaCd75D6dC842D49DadDcdDdeC222D56CaaaD47C520D02D06D11D18D20D3fD9fDa0Db1Db8DdaDefDfcC410D26Cb74D5aC842D4aD5bD8aD97C520D39D3aD3bCd86D33C631D41D6fD7fD81D8fD98DbfDcbDccDcfDdfDeeCd75D59D69D6cD79D7cD7dD85D86D87D8cD8dD95D9cC953D6bD8eC444D46CcccD67C410D4cD50D70Ca63D89C731D25Cd85D94C531DedC952D6eCda9D74C420D4dD60Cc75D42C842D32D51D71Cd97D43D53D63D73D83C953DbbCedcD75C310D14DfeC875D37C642D29D38C988D57Cda9D34D58Cc75D88D9dDabCd86D62D84CcccD65Cb64D7aDbcC842D92D9eDbeCc86D72C953D24D8bD9bCebaD77Cc75D82D93DacCa53D7eDceCeeeD35D64C631DbaDddC888D55CcbbD36Cc74D6aCb64D96DbdC731D23Cd86D78C853D61CebaD44CfddD76Cb98D48CdccD45Cc86D52CecbD54D68C741Daa" { loadWorm(); } macro "Load ROI for image [1]" { loadWorm(); } macro "Save image data Action Tool - Cce8D9eC68dD8fDcfCdefD28D37C48cD08D09Dc5CcefD22C8adD96CfffD0fD1fD2fD3fD4fD5fD82D83D87D88D89D99Da7Da8Da9Db0Db7Db8Db9Dc0Dc1Dc7Dc9Dd0Dd1Dd2Dd3Dd4Dd5Dd7Dd9De0De1De2De3De4De5Df0Df1Df2Df3Df4Df5C8b5D9dDcdCcdfD52D62D63D64D75C5bfD3aCfffD12D13D14D15Da4Db5C58cD6cD6eCdefD25D26D29D35D36D38D39D45D46D47D48D49D56D57D58D59CabeD79De7C36bD0dD0eD6fCbdfD74C79dD76DecCeffD16D17D18D19D1dD21D31D41D51D61C48cD10D20D30D40D50D60CcefD23D24D32D33D34D42D43D44D53D54D55D65D93Da3C8beDb3C37cD90CeefDb4C7adD8aDaaDabDbaDbbDcaCfffDc8Dd8C68cDa6DdfC9dfD3bD4bD5bC36bD1eD2eD3eD4eD5eCefeD9cDacDbcDccC69dDa1Db2CdefD27C48cD02D03D04D05D06D07D70D80C8aeD8bD9bC46aDefCeefD1bC6bfD3cD4cD5cC68cDf8CbceD7eC37bD0cCefeD8dC78eD9fC9beD7cC58bDfaCeffD11D71D8cD94DdcC6bfD2cC69cD98Db6CbdfD72D73D85C36bDa0Db1Dc2CdfaDaeDbeC69dD66C48cD01C8adDe9C9c6DadC5bfD2aD4aD5aC58cD68D7fCbceD97CdefD1cD2dD3dD4dD5dD84C79dDcbDdaDeaDedC8aeDe8C47cD00D0aDc4CeffD1aCefeDddC79dD86Dc6Dd6DebC7beD91Da2C47bDc3C68cD67D6aD6bDe6Df7CbdfD95Da5C9beD7dC57cD6dDf9C6cfD2bCbdfD92C36aDfdDfeCce8DceC8adD9aDeeC9ceD78CdefD81C79dDdbC37cD0bC47bDfcCbcfD77CffdD8eC68dDafDbfC9c7DbdC58cD69C9beD7bCffeDdeC57bDfbC9beD7aC25aDf6" { saveWorm(); } macro "Save image data [2]" { saveWorm(); } macro "Count a structure Action Tool - CfffD00D01D02D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD0fD10D11D12D13D14D15D16D17D18D19D1aD1bD1cD1dD1eD1fD20D21D22D23D24D25D26D27D28D29D2aD2bD2cD2dD2eD2fD30D31D33D34D35D36D37D38D39D3aD3dD3eD3fD40D41D45D46D47D48D49D4dD4eD4fD50D51D56D57D5dD5eD5fD60D61D6dD6eD6fD70D71D7aD7dD7eD7fD80D81D84D88D89D8aD8dD8eD8fD90D91D94D95D96D97D98D99D9dD9eD9fDa0Da1Da4Da5Da6Da7Da8Da9DaaDadDaeDafDb0Db1Db5Db6Db7Db8DbdDbeDbfDc0Dc1Dc2Dc3Dc4Dc5Dc6Dc7Dc8Dc9DcaDcbDccDcdDceDcfDd0Dd1Dd2Dd3Dd4Dd5Dd6Dd7Dd8Dd9DdaDdbDdcDddDdeDdfDe0De1De2De3De4De5De6De7De8De9DeaDebDecDedDeeDefDf0Df1Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDffCaaaD58D67D85Da3Db3C999D3cD4bD5aD5bD69D6aD79CbbbD32D42D43D52D62C888D6cD7bD8bD9aCbbbD44D55D63D72D73D82D92C999D3bD4aD59D68D77D78D86D87Db4CcccD54D64C777D7cD8cD9bDb9CaaaD66D74D75D83D93Da2Db2C888D4cD5cD6bCcccD65D76C777D9cDabDacDbaDbbCeeeD53" { countWorm(); } macro "Count a structure data [3]" { countWorm(); } macro "Add extra landmarks Action Tool - CadaD36D93C7a6D18CfffD00D01D02D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD0fD10D11D12D13D1cD1dD1eD1fD20D21D22D2dD2eD2fD30D31D3eD3fD40D4fD50D57D58D5fD60D67D68D6fD70D75D76D77D78D79D7aD7fD80D85D86D87D88D89D8aD8fD90D97D98D9fDa0Da7Da8DafDb0DbfDc0Dc1DceDcfDd0Dd1Dd2DddDdeDdfDe0De1De2De3DecDedDeeDefDf0Df1Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDffC6a5D2bDc2CbdaD43D92C8c7D6dDb3C483D5eCbdaD26D28D34D3aD4bD5cDc5C7c6D59C7b5DabDbaCcecDa3C9c8D6cD9cC383D8eDe9CbdaDacDbbDcaC7b6D3bD66Da2Dc4C7a5D1aCbebD27D63C8c8D46D74C594Dd4C8b7D9dDd9C7b6D5bD6aDa6CdedD35Cad9D7dC382D9eDaeDbdDccDdbDeaC7b6D7cD8cDc8C6a5D96Db1DbcDcbCbeaDb4C8c7D38D65C594D4dDe4C8b7D14D23D32D41D51C7b5D5aD6bD7bD99D9aDa9Db6Db7Db8Db9CcecD82C9d8Dc6C483D6eDdaDe6De7C8b7D15D24D33D42C7a6D19D91Da1CcecD62C9d8D37D39D55D84D94C595Dc3C8c7D48CdfdD44Cad9Dd7Dd8C7b6D17C6a5D2aC8c7D47D56D95C494D4eDe5C7c6D49Da5Db5Dc7C9c8D29C383De8C6b5D8bD9bDaaC9c8Dc9C594D3cD3dDd3Cad9D45D83C9c8D25Dd6C594D5dDd5CdecD72Cac9D52D8dC695D2cCefdD53Cad9D73C7b6D4cD81C6a5D69C7c6D4aC9d9D54C8b6D16D61D71C6a5D1bDb2C483D7eDadC8d8Da4C9c8D64" { addExtra(); } macro "Add extra landmarks [4]" { addExtra(); } // Fiji only (or ImageJ+Jython). macro "Analyze data Action Tool - Cf55D0aD2cC727D4eCfffD00D01D02D03D04D0fD10D11D12D13D14D1fD20D21D22D23D24D2fD30D31D32D33D34D3fD40D41D42D43D44D4fD50D5fD60D6fD70D7fD80D8fD90D9fDa0DafDb0Db1Db2Db3Db4Db5Db6Db7DbfDc0Dc1Dc2Dc3Dc4Dc5Dc6Dc7DcfDd0Dd1Dd2Dd3Dd4Dd5Dd6Dd7DdfDe0De1De2De3De4De5De6De7DefDf0Df1Df2Df3Df4Df5Df6Df7DffC16dD59Da6Cf88D27C7aeD6aD86D98C12cD8eD9eDadCf77D07D25D29C7b8DcbC58dD7dD9cCfaaD19D1aD47D48C8beD67D74D83D95C137DfeCf66D3aC737D2eC48dD7bCf99D1dD4bC7aeD69D76C14cD5dDaaCf77D28CacaDeaC69eD6cD88CfbbD26C9beD65D93C494Df9Cf65D3bCf34D0dC48dD56D7cD8bDa3Cf99D2dC6aeD71C13cD5eDabCf77D05D06D15D38C9c9DddDecC59eD54D6dD79D9bDa1CfbbD17D18D36D46C9beD66D73D94C247DbeDceCf76D35D39C7b7DdbC58dD7aD89D8dD9dCfaaD1bD49C8aeD68D75D84D96C15cD5bDa8Cf87D37CadbDd9C69eD53D78D91D9aCfbbD16CacfD63D82C383DfbC6a7DdcC37dD57D8cDa4Cf99D3dD4cD4dC13cD6eD7eDacC8b8DcaC58eD55Da2C02bDaeCf66D08D2aD45C69eD6bD77D81D87D99C48dD8aCfa9D1cD4aC7aeD85D97C14cD5cDa9CadaDbbDe9CaceD64D92C5a5De8Cf66D09D2bCf55D0bC7aeD51D52D61C9c9DcdC6b5Dc8C16dD5aDa7CbdbDb9CacfD72C372DfcC737D3eC27dD58Da5C7b8DdaC147DdeDeeC738D1eCacaDbcC5a4Df8Cf44D0cCbdbDbaDc9C483DfaC7b7DccC9c9DedC6b5Dd8Cf55D3cC9caDbdDebC6b6Db8CacfD62C848D0e" { run("WormBox Analyzer"); } macro "Analyze data [5]" { run("WormBox Analyzer"); } //TODO Write return values for all functions. function getFilename(title) { /* * Parse window title to get filename without extension. * * Exit if filename has extra dots in it. */ temp = split(title, "."); listSize = temp.length; if ( listSize > 2 ) { exit("Filename should not have \".\" characters (except preceding the extension):\n \n" + title + "\n \nPlease rename the file and try to load WormBox again."); } name = temp[0]; return name; } function getExtension(title) { /* * Parse window title to get the filename extension. */ temp = split(title, "."); extension = temp[temp.length-1]; if (extension != "tif" || extension != "TIF") { showMessage("Warning", title + " is not a TIFF file. After measurements, it \nwill be saved as .tif to keep scale settings."); } return extension; } function isScaled(title) { /* * Check if a scale has been set on the current image. * * If not, ask user to interact. */ selectImage(title); getPixelSize(unit, pixelWidth, pixelHeight, pixelDepth); if (pixelWidth == 1 || pixelWidth == 1 || unit == "pixels" || unit == "" || unit == " ") { setTool("line"); waitForUser("Critical issue!", "It looks like " + title + " scale \nis not set or the unit name is missing:\n \nPixel width: " + pixelWidth + "\nPixel height: " + pixelHeight + "\nPixel depth: " + pixelDepth + "\nUnit: " + unit + "\n \nWith this window open, set the scale using \nAnalyse > Set Scale... and then hit OK to continue."); getPixelSize(unit, pixelWidth, pixelHeight, pixelDepth); if (pixelWidth == 1 || pixelWidth == 1 || unit == "pixels" || unit == "" || unit == " ") { exit("Scale was not set. Impossible to continue... \nSet the scale before running WormBox again. Bye!"); } } } function countWorm() { /* * Workflow to count structures in the images. */ // If ROI Manager is open, user possibly forgot to save. So, save. roiOpen = isOpen("ROI Manager"); if ( roiOpen == 1 ) { saveWorm(); } // Load landmarks. loadWorm(); // Set the interface to count structures. run("Select None"); setTool("multipoint"); waitForUser("Without closing this window:\n \n1. Count the number of structures by clicking on the image.\n \n2. When finished, press OK and give a name for this structure."); setKeyDown("alt"); roiManager("Add"); // Save new landmarks. saveWorm(); } function getHeightUnit() { /* * Fill default landmarks within the image dimensions. Subtracts 20 pixels * to avoid borders. */ height = getHeight(); hUnit = (height-20)/n; return hUnit; } function loadWorm() { /* * Should be run after image is opened. * * Check if the image was scaled, ask user if not. * * Try to load the landmarks: image ROI, default ROI, or get input from * user to build a default ROI; in this order. * * Let user modify landmarks. */ // Necessary to load ROI Manager with Edit Mode activated. requires("1.45m"); // If ROI Manager is open, close it to avoid landmark duplication. roiOpen = isOpen("ROI Manager"); if ( roiOpen == 1 ) { selectWindow("ROI Manager"); run("Close"); } // Read window title to get the image name. title = getTitle(); // Check if image is properly scaled. isScaled(title); // Get extension from filename. extension = getExtension(title); // Get filename without extension. name = getFilename(title); // Get image folder. dir = getDirectory("image"); // Define full image path without extension. namePath = dir + name; // Define ROI file for image. roiset = name + ".zip"; // Define path to ROI file. roisetPath = dir + roiset; // Define default ROI template filename. roiTemplate = "RoiSet.zip"; // Define default ROI template path. roiTemplatePath = dir + roiTemplate; // Clear selection before anything. run("Select None"); // Load ROI Manager with "show all" and "name as labels". run("ROI Manager..."); roiManager("UseNames", "true"); roiManager("Show All"); roiManager("Show All with labels"); // Try to open image roi, then default template, else provide a new // template. if (File.exists(roisetPath)) { // Load image ROI file "filename.zip" roiManager("Open", roisetPath); } else { if (File.exists(roiTemplatePath)) { // Load default template "RoiSet.zip" roiManager("Open", roiTemplatePath); } else { // Call default template builder. Dialog.create("Create a template"); Dialog.addNumber("Number of landmarks", 10); Dialog.show(); // Get number of landmarks from the user. n = Dialog.getNumber(); // Get image dimensions to calculate unit. width = getWidth(); wUnit = width / 2; hUnit = getHeightUnit(); //XXX Small image dimensions might overflow landmarks. for (i=0; i> tif). //XXX Ideally it should preserve the extension. saveAs("tiff", namePath); } /* * TODO: * - Merge add landmark code into a single callable function. * - Expose paths whenever calling loadWorm. */