Page 1 of 1

OMERO ignoring AcquiredDate

PostPosted: Mon Jun 18, 2012 7:40 pm
by chrism
Hi,

I'm importing OME-TIFF files and OMERO is ignoring the AcquiredDate. It is set to some time point after the imported-timestamp. Here is the relevant part of my OME-XML:

Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<OME xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2011-06 http://www.openmicroscopy.org/Schemas/OME/2011-06/ome.xsd" xmlns="http://www.openmicroscopy.org/Schemas/OME/2011-06">
  <Image ID="Image:0">
    <AcquiredDate>2011-07-18T00:00:00</AcquiredDate>
    <Pixels DimensionOrder="XYCZT" ID="Pixels:0" SizeC="3" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">
      <Channel ID="Channel:0:1" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:2" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:3" SamplesPerPixel="3"/>
      <TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1"/>
    </Pixels>
...
  </Image>
</OME>



Best,

\m/ Christian

Re: OMERO ignoring AcquiredDate

PostPosted: Mon Jun 25, 2012 9:25 pm
by mlinkert
Hi Christian,

I'm importing OME-TIFF files and OMERO is ignoring the AcquiredDate. It is set to some time point after the imported-timestamp. Here is the relevant part of my OME-XML:


This has already been fixed, so upgrading to OMERO 4.4 (when it is released) should solve the problem.

Please note, though, that the Channel definitions in your example are slightly incorrect:

Code: Select all
<Pixels DimensionOrder="XYCZT" ID="Pixels:0" SizeC="3" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">
      <Channel ID="Channel:0:1" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:2" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:3" SamplesPerPixel="3"/>


If you have a single RGB plane, that should be:

Code: Select all
<Pixels DimensionOrder="XYCZT" ID="Pixels:0" SizeC="3" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">
      <Channel ID="Channel:0:1" SamplesPerPixel="3"/>


If you have three separate grayscale planes, each of which corresponds to a channel:

Code: Select all
<Pixels DimensionOrder="XYCZT" ID="Pixels:0" SizeC="3" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">
      <Channel ID="Channel:0:1" SamplesPerPixel="1"/>
      <Channel ID="Channel:0:2" SamplesPerPixel="1"/>
      <Channel ID="Channel:0:3" SamplesPerPixel="1"/>


And if you have three separate RGB planes, each of which corresponds to a channel:

Code: Select all
<Pixels DimensionOrder="XYCZT" ID="Pixels:0" SizeC="9" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8">
      <Channel ID="Channel:0:1" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:2" SamplesPerPixel="3"/>
      <Channel ID="Channel:0:3" SamplesPerPixel="3"/>


In other words, the value of SizeC should always be the sum of the values of SamplesPerPixel.

Regards,
-Melissa

Re: OMERO ignoring AcquiredDate

PostPosted: Tue Jun 26, 2012 4:14 pm
by chrism
Dear Melissa,

Thank you for your advice. I am importing multipage TIFF files, each page/file containing a single RGB plane. So your first suggestion works for me. Do you know, why I haven't run into problems with my incorrect Channel definitions?

Regarding my AcquiredDate issue:

Fine, that there is a fix in the next release. As a workaround I have written a small Python-Script to change the date using a list of image files with correct dates. Maybe it will be useful for someone else ...

Code: Select all
from omero.gateway import BlitzGateway
from omero.rtypes import RTimeI
import dateutil.parser
import time

# correct dates were extracted from original TIFF files with the following zsh line
#
# for f in **/*00??.tif ; do tiffinfo $f &> /dev/null | grep DateTime | sed "s#  DateTime: \([0-9][0-9][0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\) #$f \1-\2-\3T#g" >> dates.txt; done
#
# example line in dates.txt:
# 001/V0/a_ua_re_prox_0001.tif 2011-07-18T10:22:37

f = open("dates.txt" , "r")
content = f.readlines()
nf = {}
for c in content:
    [name,file] = c.split()
    nf[name.replace('/','\\').replace('.tif','.ome.tif')] = file

# dataset to process
datasets = [1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1667, 1668]
conn = BlitzGateway("user","password",host="hostname")
conn.connect()
update = conn.getUpdateService()
for i in datasets:
    d = conn.getObject("Dataset", i)
    for im in d.listChildren():
        name = im.getName()
        date = nf[name]
        t = dateutil.parser.parse(date)
        ts = long(time.mktime(t.timetuple()))
        im.setAcquisitionDate(RTimeI(ts * 1000))
        update.saveObject(im._obj)


Best regards,

\m/ Christian

Re: OMERO ignoring AcquiredDate

PostPosted: Thu Jun 28, 2012 3:00 pm
by mlinkert
Hi Christian,

Thank you for your advice. I am importing multipage TIFF files, each page/file containing a single RGB plane. So your first suggestion works for me. Do you know, why I haven't run into problems with my incorrect Channel definitions?


If the Channel definitions are incorrect, Bio-Formats will attempt to guess what you really meant using other metadata in the file. In this specific case, it probably guessed correctly, but it's still a good idea to make sure that the definitions are correct.

Regards,
-Melissa