Dear all
I am quite new on writing Macro on ImageJ and I cannot figure out 2 options I would like to include. this is my MAcro and it works perfectly but I would like to add 2 things see at the end of the macro: dir1 = getDirectory("Choose source directory"); dir2 = getDirectory("Choose destination directory"); list = getFileList(dir1); //setBatchMode(true); sigma = getNumber("sigma?", 20); min = getNumber("min?", 200000); for (i=0; i<list.length; i++) { print(i); showProgress(i+1, list.length); path = dir1 + list[i]; open (path); run("Grays"); print("Grays have been run"); run("Find Edges"); print("Edges done"); run("Gaussian Blur...", "sigma"); print ("Gaussian Blur was done with parameter "+sigma); run("Auto Threshold", "method=Triangle white"); print("Auto Threshold done with Triangle"); run("Properties...", "channels=1 slices=1 frames=1 unit=px pixel_width=1 pixel_height=1 voxel_depth=1.0000000 frame=[0 sec] origin=0,0"); print("Properties adjusted"); run("3D Objects Counter", "threshold=128 slice=0 min.=min max.=1440744 objects statistics"); //run("Brightness/Contrast..."); print("3D object Counter"); //close window automatically when no object found run("Apply LUT"); SavePath = dir2 + "spot_"+i+".TIF"; saveAs("TIFF", SavePath); //remove close all if it is in a batch mode close(); close(); } dir4 = getDirectory("Choose source nuclei directory"); dir3 = getDirectory("Choose Nuclei directory"); list = getFileList(dir4); for (i=0; i<list.length; i++) { print(i); showProgress(i+1, list.length); path = dir4 + list[i]; open (path); run("8-bit"); run("Invert LUT"); run("Subtract Background...", "rolling=30"); SavePath = dir3 + "nuclei_"+i+".TIF"; saveAs("TIFF", SavePath); //remove close all if it is in a batch mode close(); } My files are named array0001_B, array0001_D and array0001_R and so on. On the first part of the macro I would like to add the "if" in order to open only the images that ends with B...but it doesn't work as the macro open all the files anyway. what is wrong? path = dir1 + list[i]; if (endsWith(path, "B.TIF")){ open (path); } At the end of the macro I also would like to save a string as a txt file but it never work out. This is how I wrote it: //To run Farsight dir1 = getDirectory("Choose source directory"); list = getFileList(dir1); for (i=0; i<list.length; i++) { path = dir1 + list[i]; if (endsWith(path, "D.TIF")){ RunSegmentation = "cd dir1 segment_nuclei "+list[i]+" nuclei_"+i+"TIF" run("Text...", "save=[dir1]"); saveAs("text",RunSegmentation); thanks in advance for all your help Valeria -- Valeria Berno,PhD Microscopy Facility Manager MRC Centre for Regenerative Medicine SCRM building The University of Edinburgh Edinburgh bioQuarter 5 Little France Drive Edinburgh EH16 4UU Tel Office 0131 6519521 The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Valeria:
1. try to change "B.TIF" in "B.tif"; 2. I would assign this value to variable: RunSegmentation=dir1+"segment nuclei "+list[i]; Hope this would work, Best regards, Rocco
Senior Microscopist
Crick Advanced Light Microscopy facility (CALM) The Francis Crick Institute 1 Midland Road, NW1 1AT, London (UK) https://roccodant.github.io/ |
Free forum by Nabble | Edit this page |