<div dir="ltr"><div class="markdown-here-wrapper" id="markdown-here-wrapper-382096" style><p style="margin:1.2em 0px!important">Thank you Melissa !</p>
<p style="margin:1.2em 0px!important">I already send a mail to Christophe with a patch. This solution is fine for me and I understand it’s complicated to handle all case. However a genral rule should be to remove TiffData tags is they don’t exist anymore in the tiff… this case seems pretty simple and general to me. </p>
<p style="margin:1.2em 0px!important">Thanks for the support !</p>
<p style="margin:1.2em 0px!important">In case Christophe don’t integrate it in tifffile.py and if any python devs see this mail I post the patch : </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,255);background-repeat:initial initial">
--- a/tifffile.py
+++ b/tifffile.py
@@ -853,9 +853,12 @@ class TiffFile(object):
shape = list(int(atr['Size'+ax]) for ax in axes)
size = numpy.prod(shape[:-2])
ifds = [None] * size
- for data in pixels:
+ excepted_size = numpy.cumproduct(shape[:-2])[-1]^M
+ for i, data in enumerate(pixels):^M
if not data.tag.endswith('TiffData'):
continue
+ if i >= excepted_size:^M
+ continue^M
atr = data.attrib
ifd = int(atr.get('IFD', 0))
num = int(atr.get('NumPlanes', 1 if 'IFD' in atr else 0))</code></pre>
<p style="margin:1.2em 0px!important">Best,</p>
<p style="margin:1.2em 0px!important">—<br>Hadrien Mary</p>
<p style="margin:1.2em 0px!important">Ph.D student in Biology<br>Tournier-Gachet Team<br>CNRS - LBCMCP - UMR 5088</p>
<p style="margin:1.2em 0px!important">Université de Toulouse - Bât. 4R3B1<br>118, route de Narbonne - 31062 Toulouse </p>
<p style="margin:1.2em 0px!important">On Thu, Dec 12, 2013 at 8:54 PM, Melissa Linkert <<a href="mailto:melissa@glencoesoftware.com" target="_blank">melissa@glencoesoftware.com</a>> wrote:</p>
<p style="margin:1.2em 0px!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi Hadrien,<br>
<div><br>
> I use duplicate and I specifiy custom timepoints range in ImageJ / Fiji to<br>
> “temporally” crop OME Tiff file.<br>
><br>
> SizeT in Pixels tag is correctly updated but obsolete TiffData (such as<br>
> Plane) tags are not removed from OME description. It’s not a big deal since<br>
> LOCI can still re open the file without issue.<br>
><br>
> However it seems weird to me keep informations about missing data… So I<br>
> wonder to know if you could remove them.<br>
<br>
</div>The issue is that it is quite difficult in general to know which<br>
metadata needs to be kept, and which should be discarded. I have filed<br>
a ticket on our issue tracking system to attempt to improve this:<br>
<br>
<a href="http://trac.openmicroscopy.org.uk/ome/ticket/11831" target="_blank">http://trac.openmicroscopy.org.uk/ome/ticket/11831</a><br>
<br>
but I wouldn't expect that to completely cover all cases of images being<br>
modified before exporting. You have been CC'd on the ticket and so will<br>
be notified of any updates; if you prefer not to receive notifications<br>
please let me know.<br>
<div><br>
> Moreover I process OME Tiff file with the excellent tifffile.py from<br>
> Christoph Gohlke ( <<a href="http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html" target="_blank">http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html</a>><br>
> <a href="http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html" target="_blank">http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html</a>). And it appears that<br>
> the module failed to open OME Tiff (see error at the end of the mail for<br>
> python devs). It failed because while iterating over TiffData, module raise<br>
> an error when no data is found in the Tiff…<br>
><br>
> If you think these data should be kept across OME description I will talk<br>
> to Christoph Gohlke to see how we can overcome this issue.<br>
<br>
</div>I would advise contacting Christoph Gohlke to fix this; even once the<br>
above ticket is fixed, the reality is many software packages write<br>
OME-TIFF files, and not all of them will always do so in a way that is 100%<br>
compliant with the specification.<br>
<br>
Regards,<br>
-Melissa<br>
<div><div><br>
<br>
On Wed, Dec 11, 2013 at 08:24:46PM +0100, Hadrien Mary wrote:<br>
> Hi,<br>
><br>
> I use duplicate and I specifiy custom timepoints range in ImageJ / Fiji to<br>
> “temporally” crop OME Tiff file.<br>
><br>
> SizeT in Pixels tag is correctly updated but obsolete TiffData (such as<br>
> Plane) tags are not removed from OME description. It’s not a big deal since<br>
> LOCI can still re open the file without issue.<br>
><br>
> However it seems weird to me keep informations about missing data… So I<br>
> wonder to know if you could remove them.<br>
><br>
> Moreover I process OME Tiff file with the excellent tifffile.py from<br>
> Christoph Gohlke ( <<a href="http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html" target="_blank">http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html</a>><br>
> <a href="http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html" target="_blank">http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html</a>). And it appears that<br>
> the module failed to open OME Tiff (see error at the end of the mail for<br>
> python devs). It failed because while iterating over TiffData, module raise<br>
> an error when no data is found in the Tiff…<br>
><br>
> If you think these data should be kept across OME description I will talk<br>
> to Christoph Gohlke to see how we can overcome this issue.<br>
><br>
> ---------------------------------------------------------------------------<br>
> ValueError Traceback (most recent call last)<br>
> <ipython-input-13-896eff0433ce> in <module>()<br>
> 1 f = os.path.join(data_path, "temporal_crop.ome.tif")<br>
> 2 tf = TiffFile(f)<br>
> ----> 3 tf.series<br>
><br>
> /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in<br>
> __get__(self, instance, owner)<br>
> 549 if instance is None:<br>
> 550 return self<br>
> --> 551 value = self.func(instance)<br>
> 552 if value is NotImplemented:<br>
> 553 return getattr(super(owner, instance), self.func.__name__)<br>
><br>
> /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in<br>
> series(self)<br>
> 664 series = []<br>
> 665 if self.is_ome:<br>
> --> 666 series = self._omeseries()<br>
> 667 elif self.is_fluoview:<br>
> 668 dims = {b'X': 'X', b'Y': 'Y', b'Z': 'Z', b'T': 'T',<br>
><br>
> /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in<br>
> _omeseries(self)<br>
> 862 num = int(atr.get('PlaneCount', num))<br>
> 863 idx = [int(atr.get('First'+ax, 0)) for ax<br>
> in axes[:-2]]<br>
> --> 864 idx = numpy.ravel_multi_index(idx, shape[:-2])<br>
> 865 for uuid in data:<br>
> 866 if uuid.tag.endswith('UUID'):<br>
><br>
> ValueError: invalid entry in coordinates array<br>
><br>
> Best,<br>
><br>
> —<br>
> Hadrien Mary<br>
<br>
</div></div>> _______________________________________________<br>
> ome-devel mailing list<br>
> <a href="mailto:ome-devel@lists.openmicroscopy.org.uk" target="_blank">ome-devel@lists.openmicroscopy.org.uk</a><br>
> <a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel" target="_blank">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel</a><br>
<br>
</blockquote><p></p></div><p style="margin:1.2em 0px!important"></p>
</div></div>