Hello
I'd like to batch rename multiple (~200) ROIs, from the format: xxxx-yyyy-zzzz to only yyyy, so I can overlay and flatten those names (in my case, numbers from 0001-0200) but I couldn't find any way to do so. Searching the mailing list archives for help leaded me to a dead link ( https://list.nih.gov/cgi-bin/wa.exe?A2=IMAGEJ;62bed06c.0710) What I could extract is that if I rename the ROI file itself, the ROI manager will list it with the file name, but ImageJ will print the original on the overlay. The name is stored internally in each ROIs, so I tried to edit the ROI file with a text editor and rename the name there (so I can later run some kind of a batch find-replace on them), but that turned out corrupt the file itself. After setting More -> Options -> Use ROI names as labels I have to manually select each ROIs one by one and hit update, so the printed ROI name uses the filename or now in this case ROI name in the manger window. This works, however, as noted, I have to do it one by one. Is there any other way to do this faster? Thank you for your help! Regards, Ákos Ruszkai |
Dear Akos,
It doesn't seem possible to extract substrings from roiManager names. But, you could set base names using getTitle(); with subString(string,Index1, index2); or user entered with getNumber("prompt",default value); then increment them. Here is a modified snippet from one of my macros that may help. This example renames the rois as 1234, 1235,1236..., then invokes UseNames and updates the rois: bproi = roiManager("count"); name=1234; for (i=0;i<bproi;i++){ roiManager("select", i); roiManager("rename",name+i); } roiManager("UseNames","true"); for (i=0;i<bproi;i++){ roiManager("select", i); roiManager("Update"); } roiManager("Show All"); run("Flatten"); Regards, Glen Glen MacDonald Core for Communication Research Virginia Merrill Bloedel Hearing Research Center Box 357923 University of Washington Seattle, WA 98195-7923 USA (206) 616-4156 [hidden email] On Feb 1, 2012, at 5:59 AM, Ruszkai Ákos wrote: > Hello > > I'd like to batch rename multiple (~200) ROIs, from the format: > xxxx-yyyy-zzzz to only yyyy, so I can overlay and flatten those names (in > my case, numbers from 0001-0200) > but I couldn't find any way to do so. Searching the mailing list archives > for help leaded me to a dead link ( > https://list.nih.gov/cgi-bin/wa.exe?A2=IMAGEJ;62bed06c.0710) > > What I could extract is that if I rename the ROI file itself, the ROI > manager will list it with the file name, but ImageJ will print the original > on the overlay. The name is stored internally in each ROIs, so I tried to > edit the ROI file with a text editor and rename the name there (so I can > later run some kind of a batch find-replace on them), but that turned out > corrupt the file itself. > After setting More -> Options -> Use ROI names as labels I have to manually > select each ROIs one by one and hit update, so the printed ROI name uses > the filename or now in this case ROI name in the manger window. This works, > however, as noted, I have to do it one by one. > Is there any other way to do this faster? > Thank you for your help! > > Regards, > > Ákos Ruszkai |
This seems to work.
for ( i =0; i < roiManager("count"); i++) { roiManager ("select", i); yyyy= split( call( "ij.plugin.frame.RoiManager.getName", i ), "-" ); roiManager( "Rename", yyyy[1] ); } On 2/1/12 1:39 p.m., Glen MacDonald wrote: > Dear Akos, > It doesn't seem possible to extract substrings from roiManager names. > But, you could set base names using getTitle(); with subString(string,Index1, index2); or user entered with getNumber("prompt",default value); then increment them. > > Here is a modified snippet from one of my macros that may help. This example renames the rois as 1234, 1235,1236..., then invokes UseNames and updates the rois: > > bproi = roiManager("count"); > name=1234; > for (i=0;i<bproi;i++){ > roiManager("select", i); > roiManager("rename",name+i); > } > roiManager("UseNames","true"); > for (i=0;i<bproi;i++){ > roiManager("select", i); > roiManager("Update"); > } > roiManager("Show All"); > run("Flatten"); > > > Regards, > Glen > Glen MacDonald > Core for Communication Research > Virginia Merrill Bloedel Hearing Research Center > Box 357923 > University of Washington > Seattle, WA 98195-7923 USA > (206) 616-4156 > [hidden email] > > > > > > > > > On Feb 1, 2012, at 5:59 AM, Ruszkai Ákos wrote: > >> Hello >> >> I'd like to batch rename multiple (~200) ROIs, from the format: >> xxxx-yyyy-zzzz to only yyyy, so I can overlay and flatten those names (in >> my case, numbers from 0001-0200) >> but I couldn't find any way to do so. Searching the mailing list archives >> for help leaded me to a dead link ( >> https://list.nih.gov/cgi-bin/wa.exe?A2=IMAGEJ;62bed06c.0710) >> >> What I could extract is that if I rename the ROI file itself, the ROI >> manager will list it with the file name, but ImageJ will print the original >> on the overlay. The name is stored internally in each ROIs, so I tried to >> edit the ROI file with a text editor and rename the name there (so I can >> later run some kind of a batch find-replace on them), but that turned out >> corrupt the file itself. >> After setting More -> Options -> Use ROI names as labels I have to manually >> select each ROIs one by one and hit update, so the printed ROI name uses >> the filename or now in this case ROI name in the manger window. This works, >> however, as noted, I have to do it one by one. >> Is there any other way to do this faster? >> Thank you for your help! >> >> Regards, >> >> Ákos Ruszkai > . > |
---------- Forwarded message ----------
From: Ruszkai Ákos <[hidden email]> Date: 4 February 2012 00:23 Subject: Re: Re: Rename multiple ROIs To: Bill Mohler <[hidden email]> On 3 February 2012 17:50, Bill Mohler <[hidden email]> wrote: > Ruszkai > > > This seems to work. > > for ( i =0; i< roiManager("count"); i++) { > roiManager ("select", i); > yyyy= split( call( "ij.plugin.frame.RoiManager.**getName", i ), "-" ); > roiManager( "Rename", yyyy[1] ); > } > > > Thank you very much, this macro works like charm! Also thank you for Glen too for looking into my issue! Regards, Ákos |
Free forum by Nabble | Edit this page |