Regarding separator, I always use tabulator between cells. Then programs like Excel do not try to interpret the comma as a decimal separator, like in Norway where I live.
describes the binary format in this comment at the top of the file.
But I agree it would have made things simpler if it was an ASCII based format.
I guess this is an inheritance from NIH image, to make it compatible with ROIs from this.
/** This class decodes an ImageJ .roi file.
.roi file header. Two byte numbers are big-endian
signed shorts. The JavaScript example at
18-33 x1,y1,x2,y2 (straight line) | x,y,width,height (double rect) | size (npoints)
Sent: 5. mars 2021 01:12
I wrote a Java plugin to convert a (polygon) ROI to a 2-column x,y .csv file.
My situation is slightly complicated by the fact that I try to make these things work in Locales where ',' is not acceptable as a field separator (like, say, GERMAN). I also prefer Java, where I'm more comfortable. Also...(applicable only to the latest suggestion) I live on Macs, so Windows scripts are twice removed from my comfort zone.
It's still a little clunky, and a bit long to post - but I'd be happy to share. I might even put it up on my ImageJ Update site.
If it arises, I might be tempted to generalize this to more than simple PolygonRoi - but only if I actually need it!
Today, I'm busy writing the code that needed the ROIs in Java-readable format in the first place.
And...adding a bullet to my pre-data-collection consultation checklist: do not save essential data in proprietary, undocumented file formats!
> On Mar 4, 2021, at 15:08, Stein Rørvik <
[hidden email]> wrote:
>
> What about implementing this as a hybrid script?
>
> If you are on Windows, the below code should do.
> Save the text between the two long lines as MyMacro.cmd, put it in the ImageJ folder, and drop your ROI file onto it.
>
> The trick is that ImageJ treats the script file as a macro, and Windows treats it as a command ("batch") file.
> All you need is to point it to a minimal Java runtime and the ij.jar file, or have these in the same folder as the script.
>
> ----------------------------------------------------------------------
> -------------------------------------------------
> rem = "Hybrid script with Windows commands and ImageJ macro in the
> same file"; /* ::To use, place this file wherever desired and drop
> whatever desired onto it ::The ImageJ macro below will be executed
> using the dropped filenames, filepaths or parameters as input
> arguments ::ImageJ will consider the Windows part as a comment
> ::Windows will skip the ImageJ parts
>
> ::----- start of Windows command script ----- @echo off cls
>
> ::set MacroFile to this file
> set MacroFile=%~f0
> set MacroFile=%MacroFile:\=/%
> ::set Parameters to dropped file
> set Parameters=%~1
> set Parameters=%Parameters:\=/%
> ::create a Java command line
> set Command=jre\bin\java -jar -Xmx1024m ij.jar -eval
> "runMacro('%MacroFile%', '%Parameters%');" -batch ::execute it
> %Command% ::wait for user response before closing pause goto :EOF
> ::----- end of Windows command script ----- */
>
> //----- start of ImageJ macro script -----
>
> strArgument=getArgument();
> print("Arguments:\t" + strArgument);
> open(strArgument);
> Roi.getCoordinates(x,y);
> print('ROI coordinates');
> for (i=0;i<x.length; i++)
> print(i,x[i],y[i]);"
>
> //----- end of ImageJ macro script -----
> ----------------------------------------------------------------------
> -------------------------------------------------
>
> -----Original Message-----
> Sent: 3. mars 2021 18:02
> Subject: Re: print Roi?
>
> Thank you for the reply.
>
> Answering my own question - I eventually found a demonstration macro, from which I extracted this:
>
> ================
> Roi.getCoordinates(x,y);
> print("ROI coordinates");
> for (i=0;i<x.length; i++)
> print(i,x[i],y[i]);
> ================
>
> I would have preferred a stand-alone (preferably Java) program to read the .roi file and print the coordinates, but for my current purposes it was acceptable to drag&drop the .roi files onto a running FIJI and then run the above macro. I only had 10 files to process, so doing this manually was acceptable.
>
> Actually, I was trying to montage several data files, where the raw data consisted of:
>
> a) a .csv file giving coordinates for points to be plotted
> b) an .roi file giving the location and boundary of the sampled area
>
> Where the points in a) were expressed in local coordinate systems, relative to the top, left corner of the Roi.
>
> Alas, I had no control over the data collection.
>
> I would have preferred to write a stand-along Java program to read a collection of these raw data file pairs, but could not find information on the file format for an .roi file.
>
> Is there documentation on the format of an .roi file?
>
> --
> Kenneth Sloan
>
[hidden email]
> Vision is the art of seeing what is invisible to others.
>
>
>
>
>
>> On Mar 2, 2021, at 22:52, Fred Damen <
[hidden email]> wrote:
>>
>> Greeting Kenneth,
>>
>> Analyze>Tools>ROI Manager::More>>open...
>> ::Properties::List Coordinates then OK
>> Note: On a Oval ROI the listed coordinates are an interpolated
>> version of the displayed vertices.
>> FloatPolygon fp = Roi.getFloatPolygon(); If you want to read the
>> actual .roi file and list the contents, there are MATLAB scripts out
>> there that do this, i.e., easy to read.
>>
>> ::More>>::List
>> This answers one of my previous bonus questions, i.e., GUI display of
>> bounding box in voxel/pixel coordinates.
>>
>> Fred
>>
>> Produces the definition of the
>> On Tue, March 2, 2021 4:04 pm, Kenneth Sloan wrote:
>>> I have many (polygon) ROIs stored as .roi files.
>>>
>>> How can I print the coordinates of the vertices of the ROI?
>>>
>>> --
>>> Kenneth Sloan
>>>
[hidden email]
>>> Vision is the art of seeing what is invisible to others.
>>>
>>> --
>>> ImageJ mailing list:
>>>
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fima>>> g
>>> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fim>>> ag> ej.nih.gov
>>> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fej.nih.gov%2F&data=04%7C01%7Cstein.rorvik%40sintef.no%7C44c51e4ac6bc405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637505186106229027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=PPnokGOut%2FarwL9hKuIIFtQNPfflUFmM1wVuLBIo9fY%3D&reserved=0>%2Fij%2Flist.html&data=04%7C01%7Cstein.rorvik%40sintef.
>>> no%7C4627ec1073f24f45c66408d8de666167%7Ce1f00f39604145b0b309e0210d8b
>>> 3
>>> 2af%7C1%7C0%7C637503878617041326%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
>>> w
>>> LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sd
>>> a
>>> ta=4SWvYMBBCcGFYje7buK4gpjce7DlYgZLr8DEQGfsxdY%3D&reserved=0
>>>
>>
>> --
>> ImageJ mailing list:
>>
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag>> e
>> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fima>> ge> j.nih.gov
>> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fj.n>> ih.gov%2F&data=04%7C01%7Cstein.rorvik%40sintef.no%7C44c51e4ac6bc4
>> 05e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C6375
>> 05186106229027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2
>> luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=7jcfTUGOsmdbbzr
>> xF51sWVkmBfJMRdjWZs3nOBoyKvY%3D&reserved=0>%2Fij%2Flist.html&
>> data=04%7C01%7Cstein.rorvik%40sintef.no
>> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F40s>> intef.no%2F&data=04%7C01%7Cstein.rorvik%40sintef.no%7C44c51e4ac6b
>> c405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C63
>> 7505186106229027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoi
>> V2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=GfvFgNlxJ%2Bh
>> 2raHj0rHesVsuhr22WHbKszFRIK9YloY%3D&reserved=0>
>> %7C4627ec1073f24f45c66408d8de666167%7Ce1f00f39604145b0b309e0210d8b32a
>> f
>> %7C1%7C0%7C637503878617041326%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA
>> w
>> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4
>> S
>> WvYMBBCcGFYje7buK4gpjce7DlYgZLr8DEQGfsxdY%3D&reserved=0
>
> --
> ImageJ mailing list:
>
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimage> j.nih.gov%2Fij%2Flist.html&data=04%7C01%7Cstein.rorvik%40sintef.no
> %7C44c51e4ac6bc405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32af
> %7C1%7C0%7C637505186106229027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fP
> LSbdnWGqRi%2BiLKoVDdRIm14eFbst1JOLLFj%2FLulrk%3D&reserved=0
> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag> ej.nih.gov%2Fij%2Flist.html&data=04%7C01%7Cstein.rorvik%40sintef.n
> o%7C44c51e4ac6bc405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32a
> f%7C1%7C0%7C637505186106234005%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA
> wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0
> 1m8pMi8Q%2BDVdsf5%2BcAhh5X0pzKtuNcBvUlDoDcszsY%3D&reserved=0>
>
> --
> ImageJ mailing list:
>
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimage> j.nih.gov%2Fij%2Flist.html&data=04%7C01%7Cstein.rorvik%40sintef.no
> %7C44c51e4ac6bc405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32af
> %7C1%7C0%7C637505186106234005%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=01
> m8pMi8Q%2BDVdsf5%2BcAhh5X0pzKtuNcBvUlDoDcszsY%3D&reserved=0
> <
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag> ej.nih.gov%2Fij%2Flist.html&data=04%7C01%7Cstein.rorvik%40sintef.n
> o%7C44c51e4ac6bc405e57e408d8df96cebf%7Ce1f00f39604145b0b309e0210d8b32a
> f%7C1%7C0%7C637505186106234005%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA
> wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0
> 1m8pMi8Q%2BDVdsf5%2BcAhh5X0pzKtuNcBvUlDoDcszsY%3D&reserved=0>