Lily
Lily

Reputation: 15

Fiji get a 16bit tiff stack with unknown tags after importing sequences

In Fiji, I import sequences to get a tiff stack image over 5GB. I cannot see the detailed information in the property, such as Width, Height, Bit depth. The original depth is 16bit. When I use "imfinfo" in Matlab, it always shows 1 but not the length of the stack. Can anyone help me solve this problem? I would like to appreciate your kindness.

Below is the feedback from Matlab when I use imfinfo.

info_red=imfinfo('C:\Users\MyDoc\Desktop\Background Subtraction\FluoRed.tif')

info_red= 

                 Filename: 'C:\Users\MyDoc\Desktop\Background   Subtraction\FluoRed.tif'
              FileModDate: '02-Sep-2014 07:09:51'
                 FileSize: 5.3701e+09
                   Format: 'tif'
            FormatVersion: []
                    Width: 1388
                   Height: 1040
                 BitDepth: 16
                ColorType: 'grayscale'
          FormatSignature: [73 73 42 0]
                ByteOrder: 'little-endian'
           NewSubFileType: 0
            BitsPerSample: 16
              Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
             StripOffsets: 230904
          SamplesPerPixel: 1
             RowsPerStrip: 1040
          StripByteCounts: 2887040
              XResolution: []
              YResolution: []
           ResolutionUnit: 'Inch'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: 65535
           MinSampleValue: 0
             Thresholding: 1
                   Offset: 8
         ImageDescription: 'ImageJ=1.49b
images=1860
frames=1860
finterval=3
tunit=min
loop=false
min=30...'
              UnknownTags: [2x1 struct]

Upvotes: 0

Views: 815

Answers (1)

Benoit_11
Benoit_11

Reputation: 13945

when importing tiff stacks with Matlab, you can use the tiff class to get information about your stack, as well as actually opening them.

For example, if you use this:

t = Tiff('FluoRed.tif','r')

you will get a description of your stack which looks somewhat similar to what you get with imfinfo, that is you get a structure in which you can access its fields using standard dot notation. Here is an example with a stack named 'OriginalStack.tif' on my computer:

t = 

                  TIFF File: '/Documents/MATLAB/OriginalStack.tif'
                       Mode: 'r'
    Current Image Directory: 1
           Number Of Strips: 1
                SubFileType: Tiff.SubFileType.Default
                Photometric: Tiff.Photometric.RGB
                ImageLength: 364
                 ImageWidth: 460
               RowsPerStrip: 364
              BitsPerSample: 8
                Compression: Tiff.Compression.None
               SampleFormat: Tiff.SampleFormat.UInt
            SamplesPerPixel: 3
        PlanarConfiguration: Tiff.PlanarConfiguration.Chunky
           ImageDescription: ImageJ=1.48v
images=20
slices=20
loop=false

                Orientation: Tiff.Orientation.TopLeft

For instance, you can get the image width like so:

Width = t.getTag('ImageWidth')

As you can see, there is a field in the structure called 'ImageDescription', which tells you that there are 20 images in your stack (well my stack actually :). You could manage to get this information with structure indexing, but it's cumbersome since using

t.getTag('ImageDescription')

returns a character array and you would need to play around with regular expressions, for instance, to get the actual number of images.

EDIT: here is how you could do to retrieve the number of slices in your stack:

1) Assign a variable name to the 'ImageDescription' tag from the tiff class object:

ImageDes = t.getTag('ImageDecription');

2) Then use regular expressions to look for numbers present in the character array:

NumberSlices = regexp(ImageDes,'\d*','match')

In my case (20 slices), I get the following:

NumberSlices = 

    '1'    '48'    '20'    '20'

The first 2 numbers are in ImageJ 1.48 so we don't want them, however you can fetch any of the last two numbers and you're good to go:

NumberSlices = str2double(NumberSlices{3})

If not, the simplest solution in my opinion is to use the output from imfinfo like so:

NumberImages = length(info_red);

which in your case should give 1860. Sorry if it was very long as an answer; anyhow I think you will find useful the information about the Tiff class if you are to work with stacks in Matlab :)

Hope that helps!

Upvotes: 1

Related Questions