/* * imageJ macro to create 4D image รก 500 stacks (= 6000 single channel images) from ImageStream images * latest release: v1.0 TE 04.08.2021 * * This macro expects single channel .tif files in folders named by the ideas software with the format ID_Ch[][].ome.tif. * The recursive function that is called in the beginning loops through folders. * For stability reasons, do not contain folders in image directories. * * From previous experience, the macro takes about 150 minutes for 270.000 input images. * */ macro "ImageStream4D Action Tool - C000C111C222C333C444D38C444DaaC444D3bD6bDa5C555D68C555D64D65DcaC555D16D67Db2C555D2bD66D9dDa7Dc5C555D92Da8Da9DadDbaDbdC555D82D8dDa2Da6Db5C555D24D42D79Dc2DcdDe3DecC555D1bD33D4dD63Dd7Dd8C555D52D5dD6cDddC555D3cDd2C555D37D7aDc6Dc9C555D23C555D12D15D41D5eD6eD76D77D78D7cD91D9eDb6Dc7Dc8DceDdeC666D07D14D1cD1eD22D25D2dD2eD31D32D3eD71D73D74D75D7bD7dD7eDaeDb1Db7Db8Db9Dd6De1C666D11D13D1dD21D3dD51D61D62D6dD72D81D8eDa1DbeDc1Dd1De2DedDeeDf4DfbC666D2cD4eDd9C666D0bC666D01D0eC666D05D1fD40D50De0Df1DfeC666D03D04D0cD20D30D3fD4fD5fD60D6fD7fD80D8fD90D9fDa0DafDc0DcfDefDf3DfcC666D02D0dD10D2fD70Db0DbfDd0DdfDfdC666D06Df2C666DdcC777Dd3Df0DffC777D00D0fDfaC777D08C777Df5C777D34C777D28C777C888D6aC888D0aC888D53C888D5cC888D17D43C888C999D4cDe4DebC999D83C999D1aD3aD8cC999D95D9aDc3C999DccC999D2aDf9C999D97C999D98D99CaaaDf6CaaaD96CaaaD69D93CaaaD9cDa3CaaaD55Db3CaaaD58DdaCaaaD54Dd5CaaaD56DacDbcCaaaCbbbD57CbbbD09D5bCbbbDf8CbbbDf7CbbbD26D36CbbbCcccDabCcccD46Da4CcccDbbCcccDb4CcccD29D47CcccD48D5aCdddD39CdddD4bCdddD35CdddDe7CdddDc4DcbCdddDe8CdddCeeeD4aCeeeD18D27D9bCeeeD94CeeeD85CeeeD87D89CeeeD88D8aCeeeD84D86D8bCeeeD59CeeeCfffD49CfffDdbDe6CfffD45Dd4De9CfffDeaCfffDe5CfffD19CfffD44"{ ///////////////// // Functions // ///////////////// function duration(start, stop){ milliseconds = stop-start; seconds = milliseconds/1000; minutes = seconds/60; hours = minutes/60; display_hours = floor(hours); display_minutes = floor(minutes - display_hours * 60); display_seconds = floor(seconds - display_minutes * 60); time = newArray(display_hours, display_minutes, display_seconds); return time; } function checkFolderIfContainsFiles(dirIn){ list = getFileList(dirIn); list = Array.sort(list); for(z = 0; z < list.length; z++){ if(File.isDirectory(dirIn + File.separator + list[z]) == true){ checkFolderIfContainsFiles(dirIn + File.separator + list[z]); } else { convert_to_hyperstack(dirIn); break; } } } function convert_to_hyperstack(dirIn){ //create output directories File.makeDirectory(dirIn + "Hyperstack" + File.separator); File.makeDirectory(dirIn + "Stacks" + File.separator); dirOutHyperstack = dirIn + "Hyperstack" + File.separator; dirOutStacks = dirIn + "Stacks" + File.separator; //file list creation. renamed_list = getFileList(dirIn); //Stack combination for(j=0; j500){ m = 500; } else { m = fileNumber; } for(k=0; k < m; k++){ open(dirOutStacks + stack_list[k]); rename(stack_list[k]); title = getTitle(); IDIndex = indexOf(title, "."); object_id = substring(title, 0, IDIndex); object_ids = Array.concat(object_ids, object_id); if(k == 0){ open(dirOutStacks + stack_list[k+1]); rename(stack_list[k]); title2 = getTitle(); IDIndex = indexOf(title2, "."); object_id = substring(title2, 0, IDIndex); object_ids = Array.concat(object_ids, object_id); run("Concatenate...", "all_open open"); success = File.delete(dirOutStacks + stack_list[k]); k = k+1; success = File.delete(dirOutStacks + stack_list[k]); } else { run("Concatenate...", "all_open open"); success = File.delete(dirOutStacks + stack_list[k]); } } rename("Hyperstack"); title = getTitle(); saveAs("tif", dirOutHyperstack + "Hyperstack_" + l); run("Close"); print("#\t" + "object_id\t"); for(n=0; n