Image file formats

Prerequisites

Before starting this lesson, you should be familiar with:

Learning Objectives

After completing this lesson, learners should be able to:
  • Open and save various image files formats

  • Understand the difference between image voxel data and metadata

  • Understand that converting between image file formats likely leads to loss of information

Motivation

There are numerous ways how to save image data on disk. Virtually every microscope vendor has their own file format. It is thus very important to understand how to open those files and inspect their content. Moreover, some software will open only specific image file formats and thus it is sometime necessary to re-save the data. During such image file format conversions information can be lost; it is important to be aware of this and avoid such information loss as much as possible.

Concept map

graph TD F("TIFF, JPEG, XML/HDF5, CZI, LIF, ...") F --> PD("Pixel data") PD --> Values PD --> Dimensions F --> MD("Metadata") MD --> IC("Image calibration") MD --> MS("Microscope settings") MD --> DS("Display settings") MD --> NA("...")

Figure


Image pixel data and metadata



Activities

Image inspection

Example image data for inspection

Image saving


Show activity for:

ImageJ GUI

Image inspection

  • Open the files mentioned in the activity:
    • [Plugins > Bio-Formats > Bio-Format Importer].
      • Display metadata
      • Display OME-XML Metadata
        • Should be the same information as above but in XML (sometimes it is more correct than the above)
  • For ICS/IDS and XML/HDF5:
    • The ICS and XML file are the entry points that should be opened (the respective other file will be read automatically).
    • Also inspect the ICS and XML files in a simple text editor.

Image saving

  • Saving 8 bit single channel image as TIFF:
    • Open xy_8bit__nuclei_PLK1_control.tif
    • [Image > Adjust > Brightness/Contrast] such that cells appear saturated
    • [File > Save As > TIFF…]
      • Open with Fiji
        • LUT metadata has changed, but pixel values and calibration metadata are preserved
      • Open with a web browser
        • It may not open at all
  • Saving 8 bit single channel image as JPEG:
    • Open xy_8bit__nuclei_PLK1_control.tif
    • [Image > Adjust > Brightness/Contrast] such that cells appear saturated
    • [File > Save As > JPEG…]
      • Open with Fiji
        • Pixel values have changed
        • Calibration metadata is gone
      • Open with a web browser
        • It should look the same as when you saved it
  • Saving 16 bit two channel movie as JPEG: xyzct_16bit__mitosis.tif
    • Select a timepoint in the middle of the movie
    • [File > Save As > JPEG…]
      • Open JPEG with Fiji
      • Image dimensions, data type, pixel values, and metadata have changed
  • Saving 8 bit single channel movie as GIF: xyt_8bit__mitocheck_incenp.tif
    • [Image > Adjust > Brightness/Contrast] such that cells appear saturated
    • [File > Save As > GIF…]
      • Open with Fiji
        • Pixel values have changed
      • Open with a web browser
        • Movie plays and looks as when you saved it

Exercises

Show exercise/solution for:

ImageJ GUI

Image inspection

  • Open xyz__multiple_images.czi
    • How many images are contained?
    • What are the dimensions of the images?
    • What are the voxel sizes of the images?

Solution

  • There are two images
  • [ Image > Show Info ] reveals that both have SizeC = 1, SizeT = 1, SizeX = 251, SizeY = 251, SizeZ = 2
  • [ Image > Properties ] shows that dx = dy = 0.195 micrometer and dz = 0.3 micrometer

Image saving

  • Open xyzct_16bit__mitosis.tif
  • Enable the view of all channels by selecting Composite in [Image > Color > Channels Tools …]
  • Save as PNG
  • Open the saved image: What has changed as compared to the original image?

Solution

  • The original image looks like the image in the viewer when loaded in ImageJ or the OS viewer
  • Pixel calibration and intensities have been lost.

Assessment

True or false

  1. One could use Excel’s XLSX file format for saving image data.

Solution

  1. One could use Excel’s XLSX file format for saving image data. True, the matrix of each sheet could represent one image plane and one could use the first sheet to store metadata and the mapping of each sheet (image plane) to the zct coordinates, e.g. sheet 12 c 2 z 3 t 1.

Discuss

  1. What are the pros and cons of converting an image into another format?
  2. What are the pros and cons of splitting metadata and image pixel data into separate files?
  3. Do you know any good file formats for image metadata?

Solution

  1. (A) Sometimes it is necessary to convert to another format to be able to open the image in a specific software. (B) Converting an image to another format typically loose information, e.g. because the file format that you are saving to cannot represent all the metadata of the original image file. Thus, it is in general recommened to keep to original image file. (C) Converting to a file format with good compression may save you considerable disk space.
  2. (A) Metadata typically is much smaller than the pixel data. Thus, it can be a good idea to keep metadata in a separate file that can be readily inspected (inspecting the potentially TB sized pixel data files can be tricky). (B) The best file formats for metadata and pixel data can be very different due to the nature of the data, thus splitting can make sense. (C) Having separate files always bares the risk that you loose one of them, e.g. you may forget to copy both to a new folder.
  3. TXT, XML, and JSON are good formats for image metadata, because they are human readable standard formats that can be openend with any text editor.

Follow-up material

Recommended follow-up modules:

Learn more: