Thursday, March 1, 2012

Accessing images through a xml object.

I realize that to go further toward an image processing application,  it becomes necessary to  store informations about processed images. Those informations could be stored in a xml object mirroring the tree directories on the hard disk.
Initially I hesitated between an ini file handled with configobj and a xml file. The facilities provided by Lxml convinced me to use that library.
The images are stored as follow: Project / Slide / Field / Fluorochromes/ images. A typical xml object representing a project would be:
<CytoGenet>
  <slide name="A">
    <field name="2" ROI="x0,y0,x1,y1">
      <fluorochrome name="F1">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
      <fluorochrome name="F2">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
    </field>
    <field name="1" ROI="x0,y0,x1,y1">
      <fluorochrome name="F1">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
      <fluorochrome name="F2">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
    </field>
  </slide>
  <slide name="B">
    <field name="1" ROI="x0,y0,x1,y1">
      <fluorochrome name="F1">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
      <fluorochrome name="F2">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
      <fluorochrome name="F3">
        <image position="-1,-1" name="1.TIF" exposure="0.0"/>
      </fluorochrome>
    </field>
  </slide>
</CytoGenet>
For example, we have here a project called Cytogenet, two slides: A or B. In the slide A, two microscopic fields where observed, a region of interest was recorded by its corners (x0,y0) and (x1,y1); the first field was observed with two fluorochromes F1 or F2, and one image was taken for each with a given exposure time.