// ---------------------------------------------------------------------------------------------- // This macro converts an image with float values between 0 and 1 into an 8-bit image. // Then it calculates a binary mask given a certain threshold. // Credits: // - Reference: DeepImageJ: A user-friendly environment to run deep learning models in ImageJ, // E. Gómez-de-Mariscal, C. García-López-de-Haro, W. Ouyang, L. Donati, E. Lundberg, M. Unser, A. Muñoz-Barrutia, D. Sage, // Nat Methods 18, 1192–1195 (2021). https://doi.org/10.1038/s41592-021-01262-9 // ---------------------------------------------------------------------------------------------- // clip the range of values to the [0,1] range // THIS CODE IS MODIFIED FROM ORIGINAL 8bitbinarise macro macro "ganglia_binarise" { //check if argument is passed, if not asks user to select label image //if(getArgument()=="") //{ // waitForUser("Select the prediction from deepImageJ"); // multi_ch_prediction=getTitle(); //} //else //{ // multi_ch_prediction=getArgument(); //} multi_ch_prediction=getTitle(); selectWindow(multi_ch_prediction); run("Select None"); run("Duplicate...", "title=ganglia_prediction duplicate channels=1"); close(multi_ch_prediction); selectWindow("ganglia_prediction"); //custom code end getStatistics(_, _, min, max, _, _); run("Subtract...", "value=" + min); diff = max - min + 1e-20; run("Divide...", "value=" + diff); // Convert the image to 8-bit run("Multiply...", "value=" + 255); setMinAndMax(0, 255); run("8-bit"); // Threshold the output. optimalThreshold = 187.05; setThreshold(optimalThreshold, 255); setOption("BlackBackground", true); run("Convert to Mask"); }