[ome-devel] Temporal crop OME Tiff file with ImageJ / Fiji
Hadrien Mary
hadrien.mary at gmail.com
Thu Dec 12 20:06:22 GMT 2013
Thank you Melissa !
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.
Thanks for the support !
In case Christophe don’t integrate it in tifffile.py and if any python devs
see this mail I post the patch :
--- 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))
Best,
—
Hadrien Mary
Ph.D student in Biology
Tournier-Gachet Team
CNRS - LBCMCP - UMR 5088
Université de Toulouse - Bât. 4R3B1
118, route de Narbonne - 31062 Toulouse
On Thu, Dec 12, 2013 at 8:54 PM, Melissa Linkert <
melissa at glencoesoftware.com> wrote:
Hi Hadrien,
>
> > I use duplicate and I specifiy custom timepoints range in ImageJ / Fiji
> to
> > “temporally” crop OME Tiff file.
> >
> > SizeT in Pixels tag is correctly updated but obsolete TiffData (such as
> > Plane) tags are not removed from OME description. It’s not a big deal
> since
> > LOCI can still re open the file without issue.
> >
> > However it seems weird to me keep informations about missing data… So I
> > wonder to know if you could remove them.
>
> The issue is that it is quite difficult in general to know which
> metadata needs to be kept, and which should be discarded. I have filed
> a ticket on our issue tracking system to attempt to improve this:
>
> http://trac.openmicroscopy.org.uk/ome/ticket/11831
>
> but I wouldn't expect that to completely cover all cases of images being
> modified before exporting. You have been CC'd on the ticket and so will
> be notified of any updates; if you prefer not to receive notifications
> please let me know.
>
> > Moreover I process OME Tiff file with the excellent tifffile.py from
> > Christoph Gohlke ( <http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html
> >
> > http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html). And it appears
> that
> > the module failed to open OME Tiff (see error at the end of the mail for
> > python devs). It failed because while iterating over TiffData, module
> raise
> > an error when no data is found in the Tiff…
> >
> > If you think these data should be kept across OME description I will talk
> > to Christoph Gohlke to see how we can overcome this issue.
>
> I would advise contacting Christoph Gohlke to fix this; even once the
> above ticket is fixed, the reality is many software packages write
> OME-TIFF files, and not all of them will always do so in a way that is 100%
> compliant with the specification.
>
> Regards,
> -Melissa
>
>
> On Wed, Dec 11, 2013 at 08:24:46PM +0100, Hadrien Mary wrote:
> > Hi,
> >
> > I use duplicate and I specifiy custom timepoints range in ImageJ / Fiji
> to
> > “temporally” crop OME Tiff file.
> >
> > SizeT in Pixels tag is correctly updated but obsolete TiffData (such as
> > Plane) tags are not removed from OME description. It’s not a big deal
> since
> > LOCI can still re open the file without issue.
> >
> > However it seems weird to me keep informations about missing data… So I
> > wonder to know if you could remove them.
> >
> > Moreover I process OME Tiff file with the excellent tifffile.py from
> > Christoph Gohlke ( <http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html
> >
> > http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html). And it appears
> that
> > the module failed to open OME Tiff (see error at the end of the mail for
> > python devs). It failed because while iterating over TiffData, module
> raise
> > an error when no data is found in the Tiff…
> >
> > If you think these data should be kept across OME description I will talk
> > to Christoph Gohlke to see how we can overcome this issue.
> >
> >
> ---------------------------------------------------------------------------
> > ValueError Traceback (most recent call
> last)
> > <ipython-input-13-896eff0433ce> in <module>()
> > 1 f = os.path.join(data_path, "temporal_crop.ome.tif")
> > 2 tf = TiffFile(f)
> > ----> 3 tf.series
> >
> > /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in
> > __get__(self, instance, owner)
> > 549 if instance is None:
> > 550 return self
> > --> 551 value = self.func(instance)
> > 552 if value is NotImplemented:
> > 553 return getattr(super(owner, instance),
> self.func.__name__)
> >
> > /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in
> > series(self)
> > 664 series = []
> > 665 if self.is_ome:
> > --> 666 series = self._omeseries()
> > 667 elif self.is_fluoview:
> > 668 dims = {b'X': 'X', b'Y': 'Y', b'Z': 'Z', b'T': 'T',
> >
> > /home/hadim/.phd/dev/spindle_tracker/spindle_tracker/io/tifffile.py in
> > _omeseries(self)
> > 862 num = int(atr.get('PlaneCount', num))
> > 863 idx = [int(atr.get('First'+ax, 0)) for ax
> > in axes[:-2]]
> > --> 864 idx = numpy.ravel_multi_index(idx,
> shape[:-2])
> > 865 for uuid in data:
> > 866 if uuid.tag.endswith('UUID'):
> >
> > ValueError: invalid entry in coordinates array
> >
> > Best,
> >
> > —
> > Hadrien Mary
>
> > _______________________________________________
> > ome-devel mailing list
> > ome-devel at lists.openmicroscopy.org.uk
> > http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20131212/5f191ef7/attachment.html>
More information about the ome-devel
mailing list