I have another question for you experts.
What I want to do:
- Duplicate an image (with its ROI, both given) twice and name the duplicates differently.
- Threshold one of them, copy the thresholded ROI and paste it on the other one.
- Measure (and get other parameters) from this last duplicate’s ROI.
- Create a column in the measurements table. Its value is the division of other two values from the table.
- Save everything in a new folder in the directory of the original image.
What I have done:
currentImage = getTitle(); dir = getDirectory("image"); //Remove the .tif at the end and add Threshold or EVAL instead currentImageLength = lengthOf(currentImage); currentImage = substring(currentImage, 0, currentImageLength-4); // the -4 gets rid of the .tif run("Duplicate...", "title="+currentImage +"_Threshold.tif"); Duplicate_Threshold= getTitle(); run("8-bit"); //convert to 8bit run("Duplicate...", "title="+currentImage +"_EVAL.tif"); Duplicate_EVAL= getTitle(); run("8-bit"); //convert to 8bit //Threshold for Duplicate_Threshold selectWindow(Duplicate_Threshold); setAutoThreshold("Default dark"); run("Threshold..."); run("Threshold..."); setThreshold(107, 255); setOption("BlackBackground", true); run("Close") //Copy the mask and paste it at Duplicate_EVAL run("Convert to Mask"); run("Copy"); selectWindow(Duplicate_EVAL); run("Paste"); //Measure parameters run("Measure"); run("Thickness", "thickness spacing"); run("Volume Fraction", "algorithm=Voxel surface=6 use"); //Calculate Tb.N BVdurchTV= getResult("BV/TV", 14); Tb.Th=getResult("Tb.Th Mean (mm)", 6); Tb.N= (BV/TV)/Tb.Th; setResult("Tb.N (1/mm)", 15, Tb.N); /*saveAs("Tiff", dir + Duplicate_Threshold); saveAs("Tiff", dir + Duplicate_EVAL); saveAs("Results", dir + CurrentImage);
- I get an error in the line 36:
Row(14) out of range in line 36.
BVdurchTV= getResult(“BV/TV”, 14<)>;
The rows’ numbers I have counted manually. I do not know if there is a better way.
For the calculations I have taken the names of the columns.
- I don’t know how to create a folder and save the data there.
- I want to run this program with more pictures and save the data in the same file. Will this work or give me some problems?
I want to say that I have really tried before asking you. I have been reading https://imagej.nih.gov/ij/developer/macro/functions.html#setResult and http://imagej.1557.x6.nabble.com/How-to-create-a-customised-results-table-and-add-data-to-it-within-a-macro-td5000701.html but sometimes I get lost. But I am getting better. Slowly .
Thank you so much, as always