//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 j=i+1; 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]+ListImJcn[0]; run("Image Sequence...", "open=[Junction] sort"); run("Set Scale...", "distance=1 known="+xypix+" pixel=1 unit=um"); extractChannel_RGB(channel); } //----------------------------- //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("Analyze Particles...", "size=20-Infinity pixel show=[Bare Outlines] display exclude stack"); //Saving the image of the segemented junction, and the results of detected surfaces per image pathjctn=pathsave+"Junction"+j+"/"; File.makeDirectory(pathjctn); selectWindow("Drawing of stack"); saveAs("Tiff", pathjctn + "DrawingJunction" +j+".tif"); selectWindow("DrawingJunction"+j+".tif"); close(); selectWindow("Results"); //Calculation of junction volume n=getValue("results.count"); a=0; post=0; for(k=0; k