| layout | title | zenodo_link | level | questions | objectives | key_points | time_estimation | follow_up_training | contributors | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tutorial_hands_on |
Introduction to image analysis using Galaxy |
Introductory |
|
|
|
1H |
|
|
Introduction
{:.no_toc}
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:
- TOC {:toc}
{: .agenda}
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.
{% icon hands_on %} Hands-on: Data upload
If you are logged in, create a new history for this tutorial
{% include snippets/create_new_history.md %}
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{% include snippets/import_via_link.md %} {% include snippets/import_from_data_library.md %}
Unzip file {% icon tool %} with the following parameters:
- {% icon param-file %} "input_file":
Zippedinput file- "Extract single file":
Single file- "Filepath":
B2--W00026--P00001--Z00000--T00000--dapi.tifRename {% icon galaxy-pencil %} the dataset to
input.tif{% include snippets/rename_dataset.md %} {: .hands_on}
Image Metadata Extraction
Now, we can extract metadata from an image.
{% icon hands_on %} Hands-on: Extract Image Metadata
Image Info {% icon tool %} with the following parameters to extract metadata from the image:
- {% icon param-file %} "Input Image":
input.tiffile (output of the previous step)Click on the {% icon galaxy-eye %} (eye) icon next to the file name, to look at the file content and search for image acquisition information
{% icon question %} Questions
- What is the datatype?
- What are the pixel dimentions?
- How many bits per pixel are used?
{% icon solution %} Solution
- TIFF
- 1344x1024
- 16 {: .solution } {: .question} {: .hands_on}
Image Conversion
Not all tools can handle all image formats. Especially proprietary microscope image formats should be converted to TIFF (supported formats). However, TIFF can not be displayed in the browser. Therefore, we convert input.tif to a PNG for visualization.
{% icon hands_on %} Hands-on: Convert Image
- Convert image {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Input Image":
input.tiffile- "Output data type":
PNG- Rename {% icon galaxy-pencil %} the generated file to
viz_input- Click on the {% icon galaxy-eye %} (eye) icon next to the file name to look at the file content
{: .hands_on}
Your image should look something like this:
{% icon question %} Questions
You can observe that the image content is barely visible. Why?
{% icon solution %} Solution
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. {: .solution } {: .question}
Next we will normalize the histogram to improve the contrast. We do this using a Contrast Limited Adaptive Histogram Equalization (CLAHE) approach.
{% icon hands_on %} Hands-on: Normalize Histogram and Convert Image
- Histogram equalization {% icon tool %} with the following parameters to normalize the histogram of the image:
- {% icon param-file %} "Source file":
input.tiffile- "Histogram Equalization Algorithm":
CLAHE- Rename {% icon galaxy-pencil %} the generated file to
input_normalized- Convert image {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Input Image":
input_normalizedfile (output of Histogram equalization {% icon tool %})- "Output data type":
PNG- Rename {% icon galaxy-pencil %} the generated file to
viz_normalized- Click on the {% icon galaxy-eye %} (eye) icon next to the file name, to look at the file content {: .hands_on}
Your image should now look something like this:
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.
{% icon hands_on %} Hands-on: Filter image
- Filter Image {% icon tool %} with the following parameters to smooth the image:
- "Image type":
Gaussian Blur- "Radius/Sigma":
3- {% icon param-file %} "Source file":
input.tiffile- Rename {% icon galaxy-pencil %} the generated file to
input_smoothed- Histogram equalization {% icon tool %} with the following parameters to normalize the histogram of the image:
- {% icon param-file %} "Source file":
input_smoothedfile (output of Filter image {% icon tool %})- "Histogram Equalization Algorithm":
CLAHE- Rename {% icon galaxy-pencil %} the generated file to
input_smoothed_normalized- Convert image {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Input Image":
input_smoothed_normalizedfile (output of Histogram equalization {% icon tool %})- "Output data type":
PNG- Rename {% icon galaxy-pencil %} the generated file to
viz_smoothed_normalized- Click on the {% icon galaxy-eye %} (eye) icon next to the file name, to look at the file content and compare the result with
viz_normalized. You can observe thatviz_smoothed_normalizedhas significant reduced noise. {: .hands_on}
Your image should now look something like this:
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.
{% icon hands_on %} Hands-on: Segment image
Auto Threshold {% icon tool %} with the following parameters to segment the image:
- {% icon param-file %} "Source file":
input_smoothedfile (output of Filter image {% icon tool %})- "Threshold Algorithm":
Otsu- "Dark Background":
YesRename {% icon galaxy-pencil %} the generated file to
input_segmentedBinary 2 Label {% icon tool %} with the following parameters to segment the image:
- {% icon param-file %} "Binary Image File":
input_segmentedfile (output of Auto Threshold {% icon tool %})Rename {% icon galaxy-pencil %} the generated file to
input_segmented_labeledConvert image {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Input Image":
input_segmented_labeledfile (output of Binary 2 Label {% icon tool %})- "Output data type":
PNGRename {% icon galaxy-pencil %} the converted image to
viz segmented{% icon question %} Questions
- What does Binary 2 Label {% icon tool %} do? (Hint: check the tool help section)
- View the
viz_segmentedimage from the last step, what do you see?
- Can you explain this result?
- Exercise: Try to make the information in this image better visible (Hint: Histogram Equalization {% icon tool %})
{% icon solution %} Solution
The tool assigns each connected component (e.g., segmented cell) in the image an object id and stores it as the intensity value.
The image looks completely black. The object IDs generated by Binary 2 Label {% icon tool %} are relatively low. Since the IDs 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.
To make 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:
Histogram equalization {% icon tool %} with the following parameters to normalize the intensity values:
- {% icon param-file %} "Source file":
input_segmented_labeledfile (output of Binary 2 Label {% icon tool %})- "Histogram Equalization Algorithm":
CLAHEConvert image {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Input Image": output of Histogram Equalization {% icon tool %}
- "Output data type":
PNGThe information contained in the original image has now become visible to the human eye:
{: .solution } {: .question}
Overlay Segmentation Mask {% icon tool %} with the following parameters to convert the image to PNG:
- {% icon param-file %} "Image Source File":
viz_normalizedfile- {% icon param-file %} "Mask Source File":
viz_segmentedfile- "Image Is Greyscale":
Yes- "Thickness":
3- "Stroke Color":
red- "Plot Labels":
yes- "Label Color":
yellowClick on the {% icon galaxy-eye %} (eye) icon next to the file name, to look at the file content and assess the segmentation performance
Count Objects {% icon tool %} with the following parameters to count the segmented objects in the image:
- {% icon param-file %} "Source file":
input_segmented_labeledfile (output of Binary 2 Label {% icon tool %}){% icon question %} Questions
How many objects were segmented?
{% icon solution %} Solution
The Count Objects {% icon tool %} tool counted 425 objects. {: .solution } {: .question} {: .hands_on}
The resulting image should look something like this:
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
{:.no_toc}
In this exercise you imported images into Galaxy, extracted meta information from an image, converted between file formats, learned how to visualize microscopy images, filtered the image, and segmented cells using Galaxy.




