<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
-->
</style><style type="text/css" id="owaParaStyle"></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Gary
<div><br>
</div>
<div>I've attached a Matlab routine that I wrote as an example of creating FLIM ome-tiffs.</div>
<div><span style="font-family: Times;">The attached file generates an ome-tiff from a 5D matlab array.</span><br style="font-family: Times;">
<br style="font-family: Times;">
<span style="font-family: Times;">Points to note:</span><br style="font-family: Times;">
<br style="font-family: Times;">
<span style="font-family: Times;">The data is nonsense - it looks a bit decay-like but has no meaning.</span><br style="font-family: Times;">
<span style="font-family: Times;">The array’ delays' should contain the time points of your images in ps.</span><br style="font-family: Times;">
<span style="font-family: Times;">The background in FLIMfit is set by default to 200 for “Gated’ data. You can change this using the FLIMfit GUI.</span><br style="font-family: Times;">
<br style="font-family: Times;">
<span style="font-family: Times;">To make the attached code work you will need to download bfmatlab.zip </span><br style="font-family: Times;">
<span style="font-family: Times;">& modify the path at the top of the attached file accordingly.</span></div>
<div><br style="font-family: Times;">
<span style="font-family: Times;">Then simply type:  save_as_OMEtiff_Synthetic_Gated(‘filename.ome.tiff’);</span><br style="font-family: Times;">
<br style="font-family: Times;">
<font face="Times">Hope this helps.</font><br style="font-family: Times;">
<br style="font-family: Times;">
<span style="font-family: Times;">Ian</span><br style="font-family: Times;">
</div>
<div><br>
<div><br>
</div>
<div><br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF255848" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> ome-devel [ome-devel-bounces@lists.openmicroscopy.org.uk] on behalf of Yellen, Gary [gary_yellen@hms.harvard.edu]<br>
<b>Sent:</b> Friday, October 24, 2014 8:37 PM<br>
<b>To:</b> ome-devel@lists.openmicroscopy.org.uk<br>
<b>Subject:</b> [ome-devel] OME-Tiff writing using LOCI calls from MATLAB, and ModuloAlongT annotation<br>
</font><br>
</div>
<div></div>
<div>
<div class="WordSection1">
<p class="MsoNormal">I’m exporting microscope (2p FLIM) data from MATLAB to OME-Tiff format, using LOCI Java calls from MATLAB (in emulation of the Bio-Formats exporters).  The data are not collected from any of the commercial TCSPC devices, so there is no
 ‘native’ file format other than MATLAB.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I have two issues.  </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">The first is speed:  export of 128x128 pixel uint16 planes is taking about 60 seconds per 512 planes (using LZW compression).  The native MATLAB saving speed for these same data (in matrix, not TIFF format) is 0.2 seconds.  I’d really like
 to export during acquisition, but this doesn’t seem practical with the available tools.  Is there an intermediate format that is readily converted to OME-TIFF, which I could write more quickly from MATLAB?  Or is there a way of making this more efficient,
 by writing the planes in a more consolidated way than calling writer.saveBytes for each image plane?</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">The second problem is generating a legal ModuloAlongT annotation (in hopes of trying the FLIMfit package).  I adapted some code that Melissa posted on a forum:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:forestgreen">%% for the moduloAlongT annotation:</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata = loci.formats.CoreMetadata();</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata.moduloT.start = 0;</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata.moduloT.step = 0.05;</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata.moduloT.end = 12.75;</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata.moduloT.type = loci.formats.FormatTools.LIFETIME;</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">coreMetadata.moduloT.unit =
</span><span style="font-size:10.0pt; font-family:"Courier New"; color:#A020F0">'ns'</span><span style="font-size:10.0pt; font-family:"Courier New"; color:black">;</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.0pt; font-family:"Courier New""> </span></p>
<p class="MsoNormal">… write the main part of the metadata to ‘metadata’, in the middle of which is …</p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">OMEXMLService.addModuloAlong(metadata, coreMetadata, series);</span><span style="font-size:12.0pt; font-family:"Courier New""></span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">If I stop and debug the code here, I get an apparently well-formed annotation (see below), but if I proceed to write data to the file and save it, the saved file’s metadata for the annotation looks strange (see further below).  Inside the
 annotation Value, it contains the full original metadata definition of the Experiment Type and Image (but no planes), plus an additional Structured Annotation object inside.  ImageJ2 can read the data by drag and drop, but if I use the verbose Bio-Formats
 Importer, it gives an error about the metadata:  </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="font-size:9.0pt">java.lang.RuntimeException: org.xml.sax.SAXParseException: Element type "OME" must be followed by either attribute specifications, ">" or "/>".</span></p>
<p class="MsoNormal"><span style="font-size:9.0pt"></span></p>
<p class="MsoNormal">Thanks for any advice anyone can provide on either of these subjects.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Gary</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">=================================</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">WELL-FORMED ANNOTATION during debug, retrieved using OMEXMLService.getOMEXML(metadata);</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><StructuredAnnotations></p>
<p class="MsoNormal">               <XMLAnnotation ID="Annotation:0" Namespace="openmicroscopy.org/omero/dimension/modulo"></p>
<p class="MsoNormal">               <Value></p>
<p class="MsoNormal">               <Modulo namespace="http://www.openmicroscopy.org/Schemas/Additions/2011-09"></p>
<p class="MsoNormal">                              <ModuloAlongT End="12.75" Start="0.0" Step="0.05" Type="lifetime" TypeDescription="" Unit="ns"/></p>
<p class="MsoNormal">               </Modulo></p>
<p class="MsoNormal">               </Value></p>
<p class="MsoNormal">               </XMLAnnotation></p>
<p class="MsoNormal"></StructuredAnnotations></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">STRANGE (recursive?) ANNOTATION retrieved from .ome.tif file:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><StructuredAnnotations></p>
<p class="MsoNormal" style="text-indent:.5in"><XMLAnnotation ID="Annotation:0" Namespace="openmicroscopy.org/omero/dimension/modulo"></p>
<p class="MsoNormal" style="margin-left:.5in"><Value></p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in"><OME xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2013-06</p>
<p class="MsoNormal" style="margin-left:1.5in; text-indent:.5in">http://www.openmicroscopy.org/Schemas/OME/2013-06/ome.xsd"></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in">+ <Experiment Type="FluorescenceLifetime" ID="dFLIM_v2.1">  [[[[ this is collapsed for easy reading ]]]</p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in">+ <Image ID="Image:0">                                                                           [[[[ this is collapsed for easy reading ]]]</p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in">- <StructuredAnnotations></p>
<p class="MsoNormal" style="margin-left:1.0in; text-indent:.5in"><XMLAnnotation ID="Annotation:0" Namespace="openmicroscopy.org/omero/dimension/modulo"></p>
<p class="MsoNormal" style="margin-left:1.0in; text-indent:.5in"><Value></p>
<p class="MsoNormal" style="margin-left:1.5in"><Modulo namespace="http://www.openmicroscopy.org/Schemas/Additions/2011-09"></p>
<p class="MsoNormal" style="margin-left:1.5in; text-indent:.5in"><ModuloAlongT Type="lifetime" Unit="ns" TypeDescription="" Step="0.05" Start="0.0" End="12.75"/></p>
<p class="MsoNormal" style="margin-left:1.0in; text-indent:.5in"></Modulo></p>
<p class="MsoNormal" style="margin-left:1.0in; text-indent:.5in"></Value></p>
<p class="MsoNormal" style="margin-left:1.0in; text-indent:.5in"></XMLAnnotation></p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in"></StructuredAnnotations></p>
<p class="MsoNormal" style="margin-left:.5in; text-indent:.5in"></OME></p>
<p class="MsoNormal" style="text-indent:.5in"></Value></p>
<p class="MsoNormal" style="text-indent:.5in"></XMLAnnotation></p>
<p class="MsoNormal"></StructuredAnnotations></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>