requires("1.53f"); //MAIN CODE // Choice of Image Type //Get Images Directory and number of junction folders Imdir=getDirectory("Image Junction Folder"); jctn = getFileList(Imdir); Nbj=lengthOf(jctn); //Define a saving directory pathsave=getDirectory("Saving Folder"); types = newArray("Nikkon nd2","Leica lif or Zeiss czi","TIFF"); Dialog.create("Image Type"); Dialog.addMessage("Select the Type of Images"); Dialog.addChoice("Images", types); Dialog.show(); TypeIm=Dialog.getChoice(); if (TypeIm=="Leica lif or Zeiss czi") { TypeIm="Leica lif"; } ChanPix=selectChannelandPix(TypeIm); channel=ChanPix[0]; xypix=ChanPix[1]; zstep=ChanPix[2]; //Batchmode true to improve processing speed setBatchMode(true); for (i = 0; i < Nbj ; i++) { // Open stack of the junction images if (TypeIm == "Nikkon nd2") { ListImJcn=getFileList(Imdir); open(Imdir+ListImJcn[i]); extractChannel_bioFormat(channel); getVoxelSize(width, height, depth, unit); xypix=width; zstep=depth; } else if (TypeIm == "Leica lif") { ListImJcn=getFileList(Imdir); Junction=Imdir+ListImJcn[i]; run("Bio-Formats Importer", "open="+Junction+" autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT"); extractChannel_bioFormat(channel); getVoxelSize(width, height, depth, unit); xypix=width; zstep=depth; } else { ListImJcn=getFileList(Imdir+jctn[i]); Junction=Imdir+jctn[i]; run("Image Sequence...", "dir="+Junction+" sort"); run("Set Scale...", "distance=1 known="+xypix+" pixel=1 unit=um"); extractChannel_RGB(channel); N=lengthOf(jctn[i]); jctn[i]=substring(jctn[i],0, N-1); } //----------------------------- //Positionning in the middle of the stack for correct thresholding selectWindow("stack"); Midslice=nSlices/2+1; setSlice(Midslice); //Otsu Thresholding of the midslice setAutoThreshold("Otsu"); setOption("BlackBackground", false); run("Convert to Mask", "method=Otsu background=Dark"); run("Invert","stack"); run("Dilate","stack"); run("Duplicate...", "duplicate"); rename("stack1"); selectWindow("stack"); // Analyse of detected surfaces run("Set Measurements...", "area mean redirect=None decimal=3"); run("Analyze Particles...", "size=20-Infinity pixel show=Masks display exclude stack"); //Saving the image of the segemented junction, and the results of detected surfaces per image pathjctn=pathsave+jctn[i]; File.makeDirectory(pathjctn); selectWindow("Mask of stack"); saveAs("Tiff",pathjctn + File.separator + "Drawing" +jctn[i]+".tif"); selectWindow("Drawing"+jctn[i]+".tif"); close(); selectWindow("Results"); //Calcul du Volume de la jonction n=getValue("results.count"); a=0; post=0; for(k=0; k