Image data formats
Prerequisites
Before starting this lesson, you should be familiar with:
Learning Objectives
After completing this lesson, learners should be able to:
Open various image files formats
Understand the difference between image data and metadata
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
Figure
Activities
Open TIF image data
- Open a TIFF (Tag Image File) file and inspect its pixel and metatdata content
- Observe that there are different variants of TIFF files
- Observe that reading the metadata correctly does not always work in the same way for the different variants
Data
Show activity for:
ImageJ GUI
- Inspect the ImageJ-TIFF image
- Open by drag and drop into the FIJI window:
- Inspect the image
- Inspect the metadata via [Image > Show info…]
- Close the image and open it again via Bio-Formats Importer:
- [Plugins > Bio-Formats > Bio-Formats Importer]
- Select your image
- Display metadata
- Click [OK]
- Both options should yield the same pixel calibration
- Inspect the Molecular Devices TIFF image
- Repeat the above steps and observe that the pixel calibration is only read by the Bio-Formats importer
Key points
- There are different TIFF variants
- There are different TIFF openers in Fiji
- Typically, the Bio-Formats plugin does the best job in terms of reading all metadata
python BioIO
Open CZI image data
- Open a CZI (Carl Zeiss Image) file and inspect its pixel and metatdata content
- Observe the data is presented as one file on disk, but contains two image datasets with the same dimensions
Data
Show activity for:
ImageJ GUI
- Open the file mentioned in the activity using:
- [Plugins > Bio-Formats > Bio-Format Importer]
- Display metadata
- Display OME-XML Metadata
- Press [OK]
- Select both “Series”
- Look at the images
- Inspect the metadata
- Note that opening the CZI file via drag and drop also triggers the Bio-Formats plugin; this is not always the case(!); this is only true if ImageJ itself does not want to open the image itself (see the above activity about TIFF files where this can become confusing).
python BioIO
Open Leica LIF image data
- Open a LIF (Leica Image File) file and inspect its pixel and metatdata content
- Observe the data is presented as one file on disk, but the file contains two image data sets with different dimensions
Data
Show activity for:
ImageJ GUI
- Open the file mentioned in the activity using:
- [Plugins > Bio-Formats > Bio-Formats Importer]
- Open all series (you can check this to open all series automatically)
- Colormode: Composite
- Display metadata
- Display OME-XML Metadata
- Press [OK]
- Select both series
- Look at the images
- Inspect the different metadata for these two images.
python BioIO
Open volume EM TIFF series
- Open a series of 2D TIFF files representing an EM volume
- Observe the data is distributed onto several files on disk
- Observe that crucial metadata, namely the z slice position, is part of the file name
- Observe that the pixel calibration metadata is wrong
- Try to find the metadata at the EMPIAR website
- Discuss that for a 2D file series, it is not obvious where to store the z spacing, because the individual files are only 2D and thus may not have a metadata tag for the z-dimension
- Discuss that using pattern files might be useful for such data that is distributed across multiple files
Data
- EM-TIFF-Series.ZIP
- The data is from https://www.ebi.ac.uk/empiar/EMPIAR-10982/
- If the above link does not work, please download from here
Show activity for:
ImageJ GUI
- Open the file mentioned in the activity using:
- [Plugins > Bio-Formats > Bio-Format Importer]
- Select one of the EM TIFF slice files
- Group files with similar names
- This will load all the slices (see below)
- Display metadata
- Display OME-XML Metadata
- Press [OK]
- A dialog will appear that lets you configure how to load the multiple files “with similar names”
- Study the dialog, but you should not need to change anything
- Press [OK] to open the TIFF series
- Use [Image > Properties] to observe that the pixel size metadata is missing/wrong
- Visit https://www.ebi.ac.uk/empiar/EMPIAR-10982/ to find and then enter the pixel calibration data
python BioIO
Open Olympus VSI image data
- Open an Olypmus VSI dataset and inspect its pixel and metatdata content
- Observe that one 3-D image is stored as multiple files and folders
Data
Show activity for:
ImageJ GUI
- Drag and drop the .VSI file on Fiji
- What happens?
- For us, it seemingly opened the image data wrongly, showing some weird RGB data
- Now open the VSI file using [Plugins > Bio-Formats > Bio-Formats Importer]
- Display metadata
- Display OME-XML Metadata
- Press [OK]
- In the upcoming dialog select the first image “series”, which represents the actual image data
- Press [OK]
- The image data and metadata will open and can be inspected
Copy the VSI file to a different location and try again opening it. This should NOT work anymore, because the link to actual data, which is in the ETS file, is now broken
python BioIO
Explore various image file formats
- Open different image file formats and inspect their pixel data and also their metadata
- Appreciate that image file formats
- include more or less metadata
- may contain multiple images
- may consist of multiple files, e.g. splitting metadata and pixel data across two files
Example image data
- Nuclei - TIFF with minimal metadata
- Collagen - Molecular Devices TIFF with extensive metadata
- LIF containing two images with extensive metadata
- CZI containing several images
- ICS/IDS
- XML/HDF5
Show activity for:
ImageJ GUI
- 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.
- 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
python BioIO
Resave images in various file formats
Resaving images in different file formats very often leads to a loss of metadata or distortion of the pixel values. It is critical to be aware of this!
Checks to be done after each resaving
- Open the resaved image in all relevant applications and check whether the pixels values and/or metadata are different from the original image
- This is critical for the scientific integrity of the resaving
- Open the image in a web-browser and observe how the image is rendered
- This can be useful to share previews with collaborators
Resave 8 bit single channel image as TIFF
- Open xy_8bit__nuclei_PLK1_control.tif
- Change the contrast limits
- Save as TIFF
- Do the above checks
Resave 8 bit single channel image as JPEG
- Open xy_8bit__nuclei_PLK1_control.tif
- Change contrast such that the cells appear saturated
- Save as JPEG
- Do the above checks
Resave 16 bit two channel movie as JPEG
- Open xyzct_16bit__mitosis.tif
- Select a timepoint in the middle of the movie
- Save as JPEG
- Do the above checks
Resave 8 bit single channel movie as GIF
- Open xyt_8bit__mitocheck_incenp.tif
- Change contrast such that cells appear saturated
- Save as GIF
- Do the above checks
Show activity for:
ImageJ GUI
- 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
Assessment
True or false
- One could use Excel’s XLSX file format for saving image data.
Solution
- 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
- What are the pros and cons of converting an image into another format?
- What are the pros and cons of splitting metadata and image pixel data into separate files?
- Do you know any good file formats for image metadata?
Solution
- (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.
- (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.
- 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: