//--version--1.5 2011-09-23 // Toolset for manipulating hyperstacks // William J. Ashby, Vanderbilt University, Chemical and Physical Biology var v=versionCheck(); function versionCheck() { requires("1.41f"); return 1; } var stackOrder = newArray("xyzct", "xyczt(default)", "xyctz", "xyztc", "xytcz","xytzc"); var displayMode = newArray("Color", "Composite", "Grayscale"); var zNum=0; var cNum=0; var tNum=0; var zz=0; var cc=0; var tt=0; var zArray; var width; var height; var initialize = true; var t0=0; macro "Blank Action Tool - "{ } macro "Stack to Hyperstack Action Tool - C000D00D01D02D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD0fD10D11D12D13D15D16D1bD1cD1dD1eD1fD20D21D22D23D2bD2cD2dD2eD2fD30D31D32D33D34D38D39D3aD3bD3dD3eD3fD40D41D42D43D44D48D49D4aD4dD4eD4fD50D51D52D53D54D57D58D59D5aD5dD5eD5fD60D61D62D63D64D67D68D69D6aD6dD6eD6fD77D78D79D85D86D87D88D89D8aD8bD96D97D98D99D9aDa7Da8Da9Db0Db8CfffD14D17D18D19D1aD24D2aD3cD47D70D71D80D81D82D8fD90Da0Da1Da2Da3Da4DadDaeDafDb1Db2Db3Db4Db5DbcDbdDbeDbfDc0DccDcdDd0DdaDdcDddDe0De8De9DeaDecDedDf0Df8Df9DfaDfcDfdCf00D91D92D93Dc1Dc2Dc3Dc4Dc5Dc6Dd1Dd2Dd3Dd4Dd5Dd6Dd7De1De2De3De4De5De6De7Df1Df2Df3Df4Df5Df6Df7C00fD29D8cD9eD9fDcbDceDcfDdbDdeDdfDebDeeDefDfbDfeDffC0f0D25D26D27D28D35D36D37D45D46D4bD4cD55D56D5bD5cD65D66D6bD6cD72D73D74D75D76D7aD7bD7cD7dD7eD7fD83D84D8dD8eD94D95D9bD9cD9dDa5Da6DaaDabDacDb6Db7Db9DbaDbbDc7Dc8Dc9DcaDd8Dd9"{ // In order to make my personal defaults automatically appear in the "Stack to Hyperstack…" command, the following lines of code recreate the dialog window, display my recreation and allow user modification as necessary, and then run the "Stack to Hyperstack…" with the values provided from the dialog window. // Customize the defaults below when working with multiple files of data that have identical numbers of channels, z-slices, and timepoints Dialog.create("Convert to Hyperstack"); Dialog.addChoice("Order", stackOrder); //the stackorder is found a few lines above and can be rearranged in order to put your default order first // To make this macro use your default number of channels, slices, and time frames // simply change the numbers 2, 5, and 1 in the following 3 lines of code. Dialog.addNumber("Channels (c):", 2); Dialog.addNumber("Slices (z):", 5); Dialog.addNumber("Frames (t):", 1); Dialog.addChoice("Display Mode:", displayMode); Dialog.show(); //Displays the dialog box in order to get user input for the conversion from stack to hyperstack //or hyperstack to hyperstack if you already have the data in a hyperstack //Assigning the entered values to variables ans1=Dialog.getChoice(); cNum=Dialog.getNumber(); zNum=Dialog.getNumber(); tNum=Dialog.getNumber(); ans2=Dialog.getChoice(); zArray = newArray(tNum); //Initializing zArray which stores the index of in-focus z values over time run("8-bit"); //This line could possibly be omitted after testing for compatibility with other size stacks run("Stack to Hyperstack...", "order="+ans1+" channels="+cNum+" slices="+zNum+" frames="+tNum+" display="+ans2+""); //End of dialog section initialize=true; print("\nInitialized"); } macro "F1 Set Focus Action Tool - C000C111C222D34D35D36D37D38D39D3aD3bD3cD44D48D54D58D64D68D74Da4Da5Da6Da7Da8Da9DaaDabDacC222C333C444C555C666C777C888C999CaaaCbbbCcccCdddCeeeCfffD00D01D02D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD0fD10D11D12D13D14D15D16D17D18D19D1aD1bD1cD1dD1eD1fD20D21D22D23D24D25D26D27D28D29D2aD2bD2cD2dD2eD2fD30D31D32D33D3dD3eD3fD40D41D42D43D45D46D47D49D4aD4bD4cD4dD4eD4fD50D51D52D53D55D56D57D59D5aD5bD5cD5dD5eD5fD60D61D62D63D65D66D67D69D6aD6bD6cD6dD6eD6fD70D71D72D73D75D76D77D78D79D7aD7bD7cD7dD7eD7fD80D81D82D83D84D85D86D87D88D89D8aD8bD8cD8dD8eD8fD90D91D92D93D94D95D96D97D98D99D9aD9bD9cD9dD9eD9fDa0Da1Da2Da3DadDaeDafDb0Db1Db2Db3Db4Db5Db6Db7Db8Db9DbaDbbDbcDbdDbeDbfDc0Dc1Dc2Dc3Dc4Dc5Dc6Dc7Dc8Dc9DcaDcbDccDcdDceDcfDd0Dd1Dd2Dd3Dd4Dd5Dd6Dd7Dd8Dd9DdaDdbDdcDddDdeDdfDe0De1De2De3De4De5De6De7De8De9DeaDebDecDedDeeDefDf0Df1Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDff"{ run("Set Focus [F1]"); } macro "Set Focus [F1]" { Stack.getPosition(cc,zz,tt); if(initialize){ initialize=false; if (zArray==0){ if (Stack.isHyperstack) { Stack.getDimensions(width, height, cNum, zNum, tNum); zArray=newArray(tNum); print("\nInitialized"); } else { print("Close the error window and click the Run Stack to Hyperstack button"); } } Array.fill(zArray, zz); t0=0; } for (i=t0; i=tt) print("current t="+tt+" Proceed to t>"+t0+" or re-initialize"); else t0=tt; } macro "Split Stack Action Tool - R9077C888R9977R0977"{ if (nSlices==1) exit("Stack required"); setBatchMode(true); stack1 = getImageID; w = getWidth; h = getHeight; title = getTitle; stack2 = 0; n = zArray.length+1; Stack.getPosition(c,z,t); for (i=1; i