Get the number of frames from a multiple tiff header

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Get the number of frames from a multiple tiff header

mailfert
This post was updated on .
Dear ImageJ users,
I'm a little bit disappointed.
I would like to get the number of frames of my multiple tiff files in the header.
I know how to read the image size and other useful parameters but I don't know how to get the number of frames of my stack of images without opening all frames.
As I work with lots of 2Go files, it takes times for me to open the files just to know the number of frames.

Could you help me please?
Thanks in advance.
Sébastien
Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

Michael Schmid
Hi Sébastien,

you could open the file as a virtual stack. If ImageJ can determine the number of frames ('slices') without reading the whole file, it won't read all of the file, only the first slice.

Michael
________________________________________________________________
On Apr 1, 2015, at 08:12, mailfert wrote:

> Dear ImageJ users,
>
> I'm a little bit disapointed.
> I would like to read from my plugin the number of frames of my multiple tiff
> files.
> I know how to read the image size and other useful parameters but I don't
> know how to know the number of frames of my stack of images without opening
> all frames.
> As I work with lots of 2Go files, it takes times for me to open the files
> just to know the number of frames.
> Could you help me please?
> Thanks in advance.
> Sébastien

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by mailfert
On Apr 1, 2015, at 2:12 AM, mailfert <[hidden email]> wrote:

>
> Dear ImageJ users,
>
> I'm a little bit disapointed.
> I would like to read from my plugin the number of frames of my multiple tiff
> files.
> I know how to read the image size and other useful parameters but I don't
> know how to know the number of frames of my stack of images without opening
> all frames.
> As I work with lots of 2Go files, it takes times for me to open the files
> just to know the number of frames.
> Could you help me please?

Open the file as a virtual stack, which will only load the first frame. Here is a JavaScript example:

   img = IJ.openVirtual("");
   stack = img.getStack();
   frames = stack.getSize();
   print("frames="+frames);

-wayne

> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-number-of-frames-from-a-multiple-tiff-header-tp5012283.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

mailfert
In reply to this post by Michael Schmid
Thanks your very much for your answers.

For a tiff file containing 4086 slices (frames) which corresponds to a 2Go file, it takes:

2 minutes and 30 seconds on a computer: Intel Xeon E5-1620 @3.6GHz + RAM 8Go
and
22 secondes on a second computer: Intel Xeon E5-2630 @2.3GHz + RAM 16Go
16 secondes on a second computer: Intel Core I7-4770 @3.4GHz + RAM 16Go

I don't understand why we should read all the headers just to know the number of slices.
This should be in the ideal world instantaneous as it is to know the image size.

Why theheader is not designed to contain the number of slices directly?!!!

Thanks in advance for your precious comments.

Best regards.
Sébastien



Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

Herbie-4
Bonjour Sébastien,

of course the number of slices is contained in the TIFF-header, but you
have to find it...

The thing is that the TIFF-definition is extremely flexible and in order
to get a desired tag value you need to understand the header format.
Just do a search.

A look at the source code of the ImageJ-PlugIn "tiff_tags.jar" of
Joachim Wesner may help. See:
<http://rsb.info.nih.gov/ij/plugins/tiff-tags.html>

HTH

Herbie

::::::::::::::::::::::::::::::::::::::
Am 02.04.15 um 14:14 schrieb mailfert:

> Thanks your very much for your answers.
>
> For a tiff file containing 4086 slices (frames) which corresponds to a 2Go
> file, it takes:
>
> *2 minutes and 30 seconds *on a computer: Intel Xeon E5-1620 @3.6GHz + RAM
> 8Go
> and
> *22 secondes *on a second computer: Intel Xeon E5-2630 @2.3GHz + RAM 16Go
> *16 secondes *on a second computer: Intel Core I7-4770 @3.4GHz + RAM 16Go
>
> I don't understand why we should read all the headers just to know the
> number of slices.
> This should be in the ideal world instantaneous as it is to know the image
> size.
>
> Why theheader is not designed to contain the number of slices directly?!!!
>
> Thanks in advance for your precious comments.
>
> Best regards.
> Sébastien
>
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-number-of-frames-from-a-multiple-tiff-header-tp5012283p5012322.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

Michael Schmid
In reply to this post by mailfert
Hi Sébastien,

the speed of reading large files depends mainly on
(1) whether the file was recently read and is still in the cache of the computer of the hard disk
(2) the speed of the disk and its interface to the computer.

To see whether there is a tag giving the number of frames in the header, you can switch debug mode on in ImageJ (in Edit>Options>Misc). The list will start e.g. like the following:
  myFileName.tif: opening
    254, "NewSubfileType", value=0
    256, "ImageWidth", value=186
    257, "ImageLength", value=226
If the file was written by ImageJ, you will also see something like the following:
FileInfo: name=myFileName.tif, dir=, width=186, height=226, nImages=27, offset=768, type=byte, byteOrder=big, format=2, url=, whiteIsZero=f, lutSize=0, comp=1, ranges=null, samples=1

If you have to open files repeatedly, you may consider reading them once in ImageJ and saving them again (keep the originals; they may contain some information, e.g. metadata, EXIF, etc. not written by ImageJ). ImageJ stores the number of frames in a private field; so opening ImageJ files as virtual stack should be faster.

Michael
________________________________________________________________
On Apr 2, 2015, at 14:14, mailfert wrote:

> Thanks your very much for your answers.
>
> For a tiff file containing 4086 slices (frames) which corresponds to a 2Go
> file, it takes:
>
> *2 minutes and 30 seconds *on a computer: Intel Xeon E5-1620 @3.6GHz + RAM
> 8Go
> and
> *22 secondes *on a second computer: Intel Xeon E5-2630 @2.3GHz + RAM 16Go
> *16 secondes *on a second computer: Intel Core I7-4770 @3.4GHz + RAM 16Go
>
> I don't understand why we should read all the headers just to know the
> number of slices.
> This should be in the ideal world instantaneous as it is to know the image
> size.
>
> Why theheader is not designed to contain the number of slices directly?!!!
>
> Thanks in advance for your precious comments.
>
> Best regards.
> Sébastien
>
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-number-of-frames-from-a-multiple-tiff-header-tp5012283p5012322.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get the number of frames from a multiple tiff header

lartaud marc
In reply to this post by mailfert
Bonjour Sébastien,
Have you try this macro from bio-formats ?
https://github.com/openmicroscopy/bioformats/blob/v5.1.0/components/bio-formats-plugins/utils/macros/basicMetadata.txt
you have to install loci tool.jar
http://downloads.openmicroscopy.org/bio-formats/5.1.0/

Best regards
Marc Lartaud


Le 02/04/2015 14:14, mailfert a écrit :

> Thanks your very much for your answers.
>
> For a tiff file containing 4086 slices (frames) which corresponds to a 2Go
> file, it takes:
>
> *2 minutes and 30 seconds *on a computer: Intel Xeon E5-1620 @3.6GHz + RAM
> 8Go
> and
> *22 secondes *on a second computer: Intel Xeon E5-2630 @2.3GHz + RAM 16Go
> *16 secondes *on a second computer: Intel Core I7-4770 @3.4GHz + RAM 16Go
>
> I don't understand why we should read all the headers just to know the
> number of slices.
> This should be in the ideal world instantaneous as it is to know the image
> size.
>
> Why theheader is not designed to contain the number of slices directly?!!!
>
> Thanks in advance for your precious comments.
>
> Best regards.
> Sébastien
>
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-number-of-frames-from-a-multiple-tiff-header-tp5012283p5012322.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html