Region of Interest (ROI) File Format

This page details the format of a Jim ROI file in Backus -Naur Form (BNF) notation. This is intended for those who wish to build their own syntactically correct parser to interpret ROI files. See the BNF section for a description of the notation.

An ROI file is a plain text file, consisting of a list of ROIs (<ROI-list>). In the ROI file, white space is used to separate the elements within an ROI. White space may consist of space characters, tab characters or new-line characters. The amount of white space is not significant. Individual elements that may contain white space are enclosed in double quotes ("). Literal string elements are shown in non-italic font below.

<ROI-list> ::= <ROI-spec>|<ROI-list><ROI-spec>|<null>
<ROI-spec> ::= Begin <ROI-name-spec> ROI <build-spec> <annotation-spec> <colour-spec> <source-spec> <slice-spec> <history-list> <statistics-spec> <shape-spec> End <ROI-name-spec> ROI
<ROI-name-spec> ::= Text|Marker|Line|CurvedLine|Rectangular|Elliptical|Irregular|Spline|OpenSpline|Hollow
<build-spec> ::= Build version=<version-spec>
<annotation-spec> ::= Annotation=<string-spec>
<colour-spec> ::= Colour=<num-spec>
<source-spec> ::= Source=<string-spec>
<slice-spec> ::= Slice=<num-spec>
<history-list> ::= <history-spec>|<history-list><history-spec>
<statistics-spec> ::= Statistics: Area=<num-spec>; Mean=<num-spec>; Std Dev=<num-spec>; Min=<num-spec>; Max=<num-spec>|
Statistics: Area=<num-spec>; Mean=<num-spec>; Std Dev=<num-spec>; Min=<num-spec>; Max=<num-spec>;Length=<num-spec>

<version-spec> is a string of ASCII text characters enclosed in double quotation marks (") giving the build version of Jim. The build version is of the form "MajorVersion_MinorVersion", e.g., "8.0_1"

<string-spec> is a string of ASCII text characters enclosed in double quotation marks (").

<num-spec> is a numerical value that may be either in integer or floating point format, depending on the context. The colour of an ROI is specified by an integer between 0 and 8 inclusive, where a value of 0 indicates should be drawn using the default ROI drawing colour, and the colour depends on the selection state of the ROI. A colour value between 1 and 8 indicates which colour from the palette of user-defined ROI colours is used to draw the ROI.

The specification for a <history-list> is given in the audit trail section.

The shape of an ROI is defined in the <shape-spec>, and is different for each of the types of ROI. The <shape-spec> found within an ROI will match the name (Text|Marker|Line|CurvedLine|Rectangular|Elliptical|Irregular|Hollow) found in the <ROI-spec>.

The second version of the <statistics-spec> is for line ROIs (curved and straight) that have an additional length statistic.

<shape-spec> ::= Begin Shape <geom-spec> End Shape
<geom-spec> ::= <text-spec>| <marker-spec>| <line-spec>| <curved-line-spec>| <rectangular-spec>| <elliptical-spec>| <irregular-spec> <spline-spec> <hollow-spec>
<text-spec> ::= X=<num-spec>; Y=<num-spec>
<marker-spec> ::= X=<num-spec>; Y=<num-spec>
<line-spec> ::= X1=<num-spec>; Y1=<num-spec>; X2=<num-spec>; Y2=<num-spec>
<rectangular-spec> ::= X=<num-spec>; Y=<num-spec>; Width=<num-spec>; Height=<num-spec>
<elliptical-spec> ::= X=<num-spec>; Y=<num-spec>; A=<num-spec>; B=<num-spec>; Theta=<num-spec>
<curved-line-spec> ::= Points=<num-spec> <vertex-list>
<irregular-spec> ::= Points=<num-spec> <vertex-list>
<spline-spec> ::= Points=<num-spec> <vertex-list>
<hollow-spec> ::= OuterPoints=<num-spec><vertex-list><inner-list>
<inner-list> ::= <inner-spec>|<inner-list><inner-spec>
<inner-spec> ::= InnerPoints=<num-spec><vertex-list>
<vertex-list> ::= <vertex-spec>|<vertex-list><vertex-spec>|<null>
<vertex-spec> ::= X=<num-spec>; Y=<num-spec>

The X and Y positions define the top left hand corner location for a rectangular ROI, while they define the centre location for an Elliptical ROI. The angle Theta is the angle between the major axis and the x-direction. A positive rotation angle is clockwise.

Below is an example of the contents of an ROI file, containing three ROIs (rectangular, elliptical and irregular with ten vertices). The ROIs were defined from an image called "T1Head" in the directory "/home/xinapse". Note that the Irregular ROI has been modified, and uses colour 3 from the user-defined colour palette.

        Begin Rectangular ROI
          Build version="8.0_1"
          Annotation="Rectangular ROI A"
          Colour=0
          Image source="/home/xinapse/T1Head"
          Slice=1
          Created  "24 Apr 2013 16:20:32.084 British Summer Time" by Operator ID="xinapse"
          Statistics: Area=705.71351; Mean=495.9919; Std Dev=253.453636; Min=12; Max=1319
          Begin Shape
            X=7.812392; Y=10.416492; Width=29.296473; Height=24.088685
          End Shape
        End Rectangular ROI
        Begin Elliptical ROI
          Build version="8.0_1"
          Annotation="This is an Elliptical ROI b"
          Colour=0
          Image source="/home/xinapse/T1Head"
          Slice=2
          Created  "24 Apr 2013 16:21:21.473 British Summer Time" by Operator ID="xinapse"
          Statistics: Area=1172.921614; Mean=402.109715; Std Dev=194.631116; Min=57; Max=1137
          Begin Shape
            X=7.903945; Y=22.430438; A=28.927724; B=12.906392; Theta=25.159302
          End Shape
        End Elliptical ROI
        Begin Irregular ROI
          Build version="8.0_1"
          Annotation="An Irregular One c"
          Colour=3
          Image source="/home/xinapse/T1Head"
          Slice=3
          Created  "24 Apr 2013 16:21:48.683 British Summer Time" by Operator ID="xinapse"
          Modified "26 Apr 2013 12:22:40.058 British Summer Time" by Operator ID="xinapse"
          Statistics: Area=753.340233; Mean=366.765766; Std Dev=148.425423; Min=33; Max=1044
          Begin Shape
            Points=10
            X=23.925453; Y=5.518595
            X=20.365117; Y=0.623067
            X=-1.441936; Y=18.424988
            X=0.338232; Y=35.78186
            X=24.370495; Y=38.897196
            X=25.260578; Y=38.897196
            X=31.491165; Y=25.545756
            X=30.156039; Y=25.100708
            X=19.475034; Y=16.199748
            X=19.475034; Y=14.864604
          End Shape
        End Irregular ROI
      
Jim Home