Introduction to Image Analysis using Galaxy

Overview
Creative Commons License: CC-BY Questions:
  • How do I use Galaxy with imaging data?

  • How do I convert images using Galaxy?

  • How do I display images in Galaxy?

  • How do I filter images in Galaxy?

  • How do I segment simple images in Galaxy?

Objectives:
  • How to handle images in Galaxy.

  • How to perform basic image processing in Galaxy.

Requirements:
Time estimation: 1 hour
Level: Introductory Introductory
Supporting Materials:
Published: Aug 13, 2019
Last modification: Nov 6, 2024
License: Tutorial Content is licensed under Creative Commons Attribution 4.0 International License. The GTN Framework is licensed under MIT
purl PURL: https://gxy.io/GTN:T00181
rating Rating: 5.0 (0 recent ratings, 4 all time)
version Revision: 13

Image analysis is the extraction of meaningful information from images by means of digital image processing techniques. Imaging is an important component in a wide range of scientific fields of study, such as astronomy, medicine, physics, biology, geography, chemistry, robotics, and industrial manufacturing.

This tutorial shows how to use Galaxy to perform basic image analysis tasks such as format conversion, image enhancement, segmentation, and feature extraction.

Agenda

In this tutorial, we will deal with:

  1. Getting Data
  2. Image Metadata Extraction
  3. Visual Inspection of TIFF Images
  4. Image Filtering
  5. Segmentation
  6. Conclusion

Getting Data

The dataset required for this tutorial is available from Zenodo and contains a screen of DAPI stained HeLa nuclei (more information). We will use a sample image from this dataset for training basic image processing skills in Galaxy.

Our objective is to automatically count the number of cells contained in this image. In order to achieve this, we will enhance the quality of the image, automatically detect the nuclei and segment the nuclei and count them.

Hands-on: Data upload
  1. If you are logged in, create a new history for this tutorial

    To create a new history simply click the new-history icon at the top of the history panel:

    UI for creating new history

  2. Import the following dataset from Zenodo or from the data library (ask your instructor).
    • Important: Choose the type of data as zip.
    https://zenodo.org/record/3362976/files/B2.zip
    
    • Copy the link location
    • Click galaxy-upload Upload Data at the top of the tool panel

    • Select galaxy-wf-edit Paste/Fetch Data
    • Paste the link(s) into the text field

    • Press Start

    • Close the window

    As an alternative to uploading the data from a URL or your computer, the files may also have been made available from a shared data library:

    1. Go into Data (top panel) then Data libraries
    2. Navigate to the correct folder as indicated by your instructor.
      • On most Galaxies tutorial data will be provided in a folder named GTN - Material –> Topic Name -> Tutorial Name.
    3. Select the desired files
    4. Click on Add to History galaxy-dropdown near the top and select as Datasets from the dropdown menu
    5. In the pop-up window, choose

      • “Select history”: the history you want to import the data to (or create a new one)
    6. Click on Import

  3. Unzip ( Galaxy version 6.0+galaxy0) with the following parameters:
    • param-file “input_file”: B2.zip
    • “Extract single file”: Single file
    • “Filepath”: B2--W00026--P00001--Z00000--T00000--dapi.tif
  4. Rename galaxy-pencil the dataset to input.tif

    • Click on the galaxy-pencil pencil icon for the dataset to edit its attributes
    • In the central panel, change the Name field
    • Click the Save button

Image Metadata Extraction

Now, we can extract metadata from an image.

Hands-on: Extract Image Metadata
  1. Show image info ( Galaxy version 5.7.1+galaxy1) with the following parameters to extract metadata from the image:
    • param-file “Input Image”: input.tif file (output of the previous step)
  2. Click on the galaxy-eye (eye) icon next to the file name, to look at the file content and search for image acquisition information

    Question
    1. What is the datatype?
    2. What are the pixel dimentions?
    3. How many bits per pixel are used?
    1. TIFF
    2. 1344x1024
    3. 16

Visual Inspection of TIFF Images

Not all tools can handle all image formats. Especially proprietary microscope image formats should be converted to TIFF (supported formats). However, TIFF cannot be displayed in most web browsers directly. Therefore, for visual inspection of TIFF images, we use a TIFF visualization plugin in Galaxy.

Hands-on: Visual Inspection of TIFF Images
  1. Click on the title of your file to see the row of small icons for saving, linking, etc.: Screenshot of Galaxy icons. Seven small blue icons are shown on a green background. From left to right they are: floppy disk, link, information, redo, bar chart, flow chart and a question mark.
  2. Click on the visualise icon galaxy-visualise and then select the Tiff Viewer visualization plugin.

Your image should look something like this:

raw input image.

Question

You can observe that the image content is barely visible. Why?

The original image is 16-bit and the intensity values are spread over a larger range than the display can render. Therefore, for improved visibility the intensity histogram of the image can be normalized first.

Next we will normalize the histogram to improve the contrast. We do this using a Contrast Limited Adaptive Histogram Equalization (CLAHE) approach.

Hands-on: Normalize Histogram
  1. Perform histogram equalization ( Galaxy version 0.18.1+galaxy0) with the following parameters to normalize the histogram of the image:
    • param-file “Input image”: input.tif file
    • “Histogram equalization algorithm”: CLAHE
  2. Rename galaxy-pencil the generated file to input_normalized.
  3. Click on the visualise icon galaxy-visualise of the file to visually inspect the image using the Tiff Viewer visualization plugin.

Your image should now look something like this:

viz_normalized output image.

We can now clearly make out the presence of the stained nuclei. Next we will automatically detect these features and segment the image.

Image Filtering

Specific features of interest (e.g., edges, noise) can be enhanced or suppressed by using an image filter.

Hands-on: Filter image
  1. Filter 2-D image ( Galaxy version 1.12.0+galaxy1) with the following parameters to smooth the image:
    • “Filter type”: Gaussian
    • “Sigma”: 3
    • param-file “Source file”: input.tif file
  2. Rename galaxy-pencil the generated file to input_smoothed.
  3. Perform histogram equalization ( Galaxy version 0.18.1+galaxy0) with the following parameters to normalize the histogram of the image:
    • param-file “Input image”: input_smoothed file (output of Filter 2-D image ( Galaxy version 1.12.0+galaxy1))
    • “Histogram equalization algorithm”: CLAHE
  4. Rename galaxy-pencil the generated file to input_smoothed_normalized.
  5. Click on the visualise icon galaxy-visualise of the file to visually inspect the image and compare the result with input_normalized. You can observe that input_smoothed_normalized has significantly reduced noise.

Your image should now look something like this:

viz_smoothed_normalized output image.

Segmentation

Objects of interest like nuclei can be segmented by using a smoothed image and thresholding. Moreover, the results can be overlayed with the original image.

Hands-on: Segment image
  1. Threshold image ( Galaxy version 0.18.1+galaxy3) with the following parameters to segment the image:
    • param-file “Input image”: input_smoothed file (output of Filter 2-D image ( Galaxy version 1.12.0+galaxy1))
    • “Thresholding method”: Globally adaptive / Otsu
  2. Rename galaxy-pencil the generated file to input_segmented.
  3. Convert binary image to label map ( Galaxy version 0.5+galaxy0) with the following parameters to segment the image:
    • param-file “Binary image”: input_segmented file (output of Threshold image ( Galaxy version 0.18.1+galaxy3))
  4. Rename galaxy-pencil the generated file to input_segmented_labeled

    Question
    1. What does Convert binary image to label map ( Galaxy version 0.5+galaxy0) do? (Hint: check the tool help section)
    2. View the input_segmented_labeled image from the last step, what do you see? Can you explain this result?
    3. Exercise: Try to make the information in this image better visible (Hint: use Perform histogram equalization ( Galaxy version 0.18.1+galaxy0))
    1. The tool assigns each connected component (e.g., segmented cell) in the image a unique object ID called label and stores it as the intensity value.
    2. The image looks completely black. The object labels generated by Convert binary image to label map ( Galaxy version 0.5+galaxy0) are relatively low. Since the labels are stored as intensity values, these are too low to be visible in this case. Nevertheless, there is more information in this image than meets the eye.
    3. To make the labeled objects visible, the values have to be stretched to a larger range of visible intensity values. We can do that by equalizing the histogram again. To this end, use Perform histogram equalization ( Galaxy version 0.18.1+galaxy0) with the following parameters to normalize the intensity values:
      • param-file “Input image”: input_segmented_labeled file (output of Convert binary image to label map ( Galaxy version 0.5+galaxy0))
      • “Histogram equalization algorithm”: CLAHE

      The information contained in the original image has now become visible to the human eye: normalized viz_segmented file.

  5. Overlay images ( Galaxy version 0.0.4+galaxy4) with the following parameters to convert the image to PNG:
    • “Type of the overlay”: Segmentation contours over image
    • param-file “Intensity image”: input_normalized file
    • param-file “Label map”: input_segmented_labeled file (output of Convert binary image to label map ( Galaxy version 0.5+galaxy0))
    • “Contour thickness”: 2
    • “Contour color”: red
    • “Show labels”: yes
    • “Label color”: yellow
  6. Click on the galaxy-eye (eye) icon next to the file name, to look at the file content and assess the segmentation performance.
  7. Count objects in label map ( Galaxy version 0.0.5-2) with the following parameters to count the segmented objects in the image:
    • param-file “Source file”: input_segmented_labeled file (output of Convert binary image to label map ( Galaxy version 0.5+galaxy0))
    Question

    How many objects were segmented?

    The Count objects in label map ( Galaxy version 0.0.5-2) tool counted 425 objects.

The resulting image should look something like this:

segmentation mask output image.

We see the segmentation mask overlayed; each detected object (nucleus) is labeled with its ID value.

We see that with the help of just a few simple steps, we were able to detect the locations of the stained nuclei, and count them.

Conclusion

In this exercise you imported images into Galaxy, extracted meta information from an image, learned how to visualize microscopy images, filtered the image, and segmented cells using Galaxy.