Posted by
roberto aranibar on
URL: http://imagej.273.s1.nabble.com/Built-in-Macro-Functions-tp3701725.html
Dear ImageJ Community
Ive spent a considerable amount of time trying to figure the following
problem out, but I have not gotten very far. If there is anyone out there
who is familiar with the built-in macro functions in ImageJ and macro
programming, I could really use your help
Are there any built-in functions that allow you to get the index and name of
an ROI that is selected in the ROI manager, and then find a number that is
contained in the ROI name? The number could be 1 to 4 digits long, and it
will not always begin at the same string index of the ROI name.
Below is some pseudo-code for what Im trying to do. After selecting an ROI
in the ROI Manager, I want to find out a number in the ROI name and rename
the remainder of the ROIs in the list based on that number.
i=index of a selected ROI in the ROI Manager; (e.g., i = 867)
string=name of ROI at index i in the ROI Manager; (e.g., string = a508n)
index1=index of first number in string; (e.g. 1 if string is a508n,
assuming indexing begins at 0)
index2= index of last number in string; (e.g. 3 if string is a508n)
j=parseInt(substring(string,index1,index2))+1; (for previous e.g., j = 509)
i++;
while(i<=roiManager("count")) {
roiManager("Rename","a"+j+"n");
i++;
}
Thanks so much in advance,
Roberto
_________________________________________________________________
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG