Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multichannel images #616

Merged
merged 6 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module_order:
- tool_installation
- pixels
- lut
- multichannel_images
- spatial_calibration
- multidimensional_image_basics
- datatypes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# %% [markdown]
# ## Apply manual and automated thresholds

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# initial imports
import napari
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# %% [markdown]
# ## Apply automated thresholds in 3D

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# initial imports
import numpy as np
Expand Down Expand Up @@ -41,3 +45,5 @@
thresholded_li = image > threshold_li(image)

viewer.add_labels(thresholded_li, name='li', num_colors=1, color={1: 'orange'}, scale=scales)

# %%
6 changes: 6 additions & 0 deletions _includes/binarization/binarization_act1_skimage_napari.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# %% [markdown]
# ## Thresholding bright and dim cell

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# Instantiate the napari viewer
import napari
Expand Down Expand Up @@ -44,3 +48,5 @@
# to only select the brighter cell
binary_image_one_cell = image > 100
viewer.add_image(binary_image_one_cell, opacity=0.8)

# %%
8 changes: 7 additions & 1 deletion _includes/binarization/binarization_act2_skimage_napari.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# %% [markdown]
# ## Spots and threshold interval


# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# Instantiate the napari viewer
import napari
Expand Down Expand Up @@ -50,3 +54,5 @@
# to only select the boundary of cells
binary_image_boundary = (image < 5) * (image >= 4)
viewer.add_image(binary_image_boundary, opacity=0.8)

# %%
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# %% [markdown]
# # 3D connected component labeling

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# Import modules
import napari
Expand Down
15 changes: 11 additions & 4 deletions _includes/datatypes/datatypes_act1_skimage_napari.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# %% [markdown]
# ## Explore image data types and value ranges

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# Import modules
import napari
import numpy as np
from OpenIJTIFF import open_ij_tiff

# Open napari
viewer = napari.Viewer()


# %%
# Open the image
# Execute one of the cells
image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_8bit__nuclei_noisy_different_intensity.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_8bit__nuclei_noisy_different_intensity.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_8bit__nuclei_intensity_clipping_issue_a.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_8bit__nuclei_intensity_clipping_issue_b.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_8bit_binary__h2b.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__autophagosomes.tif')
#image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__scanR_datatype_issue.tif')
image, _, _, _ = open_ij_tiff('https://github.com/NEUBIAS/training-resources/raw/master/image_data/xy_16bit__scanR_datatype_issue.tif')

# View the image
viewer.add_image(image)
Expand All @@ -29,3 +32,7 @@

# Check the image's minimum and maximum intensity
print(np.min(image),np.max(image))

# %%

# %%
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Run `PowerPoint` and open a `Blank presentation`
- Remove `Text boxes` or images if present by selecting them and pressing `Delete` key
- Drag and drop all the saved images from the folder into your `Blank presentation`
- Select `Intensity profile plots` and `ROI images`, use right click menu and press `Bring to Front`
- Resize and arrange all the images so that `Intensity profile plots` and `ROI images` belong to their respective images.
- When all images are arranged corrected, press `Ctrl + A` to select all images and group them using right click menu and pressing `Group > Group`
- Use right click menu again on the `Group` image press `Save as Picture`
- Select a file name and folder and save as type `SVG`
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<h4 id="inspect_collagen_data"><a href="#inspect_collagen_data">Inspect collagen image data</a></h4>

In this activity we inspect images of tissue culture cells expressing collagen.

The below drop down menu allows you to perfom all steps in one go, which requires prior knowledge as mentioned in this module's prerequisites.

If you are a beginner, we recommend first learning the individual steps
- [Image pixel value inspection](https://neubias.github.io/training-resources/pixels/index.html#inspect_collagen)
- [Image display adjustment](https://neubias.github.io/training-resources/lut/index.html#configure_luts)
- [Image spatial calibration](https://neubias.github.io/training-resources/spatial_calibration/index.html#scale_bar)
- [Image data types](https://neubias.github.io/training-resources/datatypes/index.html#datatype_metadata)
- [Image microscopy metadata](https://neubias.github.io/training-resources/image_file_formats/index.html#open)
- Check out the collagen image and find important metadata, such as exposure time and illumination intensity


##### Image data

- [0h_collagen_secretion](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__0h_collagen.ome.tif)
- [96h_collagen_secretion](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__96h_collagen.ome.tif)
- This activity opens images where tissue culture cells are secreting collagen for different amounts of time.
The aim is to display the images such that one can appreciate that after 96 h there is more collagen
secreted than after 0 h. The aim is to make this display as quantitative as possible without doing an actual
image analysis.
- Requirements:
- BioVoxxel Fiji Update site for saving images as SVG vector graphics
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- Open collagen images [0h_collagen_secretion](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__0h_collagen.ome.tif) and [96h_collagen_secretion](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__96h_collagen.ome.tif)
- Adjust the display range of both images using `Image > Adjust > Brightness/Contrast...`
- Try to select an intensity range for control image and then use the same `min` and `max` values for the treatment image
- This can be done using the `Set` button of the `B&C` window. This will open another window `Set Display Range`. As an example, set `Minimum displayed value` and `Maximum displayed value` to `0` and `3500` respectively and select `[x] Propagate to all other open images` and press `OK`
- If metadata is missing, add it manually to both images
- Open `Image > Properties...`
- Set `Pixel width` and `Pixel height` to `0.324` `micron`
- Add calibration bar to both images using `Analyze > Tools > Calibration Bar...`
- `Location` - `Upper Left`
- `Fill color` - `White`
- `Label color` - `Black`
- `Font size` - `12`
- `Zoom factor` - `4`
- `[x] Overlay`
- Open dapi images [0h_dapi](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__0h_dapi.ome.tif) and [96h_dapi](https://github.com/NEUBIAS/training-resources/raw/master/image_data/image_inspection_and_presentation/xy_16bit__96h_dapi.ome.tif)
- Adjust the display range of both images using `Image > Adjust > Brightness/Contrast...`
- Use `Set` button of `B&C` and set `Minimum displayed value` and `Maximum displayed value` to `0` and `4000` respectively and select `[x] Propagate to all other open images` and press `OK`
- Merge channels belonging to the same image (e.g. "*_0h_collagen.ome.tif" belongs to "*_0h_dapi.ome.tif") using `Image > Color > Merge Channels...`. and in the settings:
- Set collagen channel as `C2(green)`
- Set dapi channel as `C3(blue)`
- `[x] Create composite`
- `[x] Keep source images`
- Add scale bar to each image using `Analyze > Tools > Scale Bar...` and increase `Thickness in pixels` and `Font size` to suit your needs
- `Thickness in pixels` - `20`
- `Width in um` - `100`
- `Font size` - `50`
- `Location` - `Lower left`
- `[x] Overlay`
- Close `dapi` single channel image windows
- Select `Rectangle` tool from Fiji GUI, and select an ROI on `0h_collagen` image (grayscale)
- Add it as overlay on the image using `Image > Overlay > Add Selection...`
- Duplicate the selection to create an ROI image using `Image > Duplicate...`
- `[] Ignore selection`
- _Note:_ The overlay box stays on the original image even if you click elsewhere
- Add scale bar to ROI image using `Analyze > Tools > Scale Bar...` and reduce `Thickness in pixels` and `Font size` to suit your needs
- Select a `Line` tool from Fiji GUI, and draw a line in the middle of ROI image
- Add it as an overlay on the image using `Image > Overlay > Add Selection...`
- Plot intensity profile along this line using `Analyze > Plot Profile`
- Set the y-axis range using `Set>> Set Range...`
- Set `YFrom` to `0` and `YTo` to `whatever number` and press `OK`
- Select `Rectangle` tool from Fiji GUI, and select an ROI on `96h_collagen` image (grayscale) and repeat the procedure above
- _Note:_ You can use the same ROI as above by selecting the ROI rectangular box on `0h_collagen` image and then selecting `96h_collagen` image and doing `Edit > Selection > Restore Selection`
- To save all the images in the high quality, go to `Plugins > BioVoxxel Figure Toolbox > Export all images as SVG`
- `Traget folder` - folder of your choice to save all `SVG` images
- `Export channels` - `Color`
- `Lock critical ROIs [x]`
6 changes: 6 additions & 0 deletions _includes/multichannel_images/activity1_imagejgui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Use the slider bar under the image to select the channel to be processed/analyzed
- The number of bar positions are equal to the number of channels
- _Note:_ The color of the subtitle changes when you switch to a different channel
- Open the `Channels` tool using `Image > Color > Channels Tool` or by pressing `shift-z` to select/deselect channels to display
- Use the `B & C` tool using `Image > Adjust > Brightness/Contrast` or press `shift-c` to adjust the brightness and contrast of the current channel. _Note:_ The slider bar decides your active channel for changing brightness and contrast settings
- Try changing the channel color by selecting a LUT from the `Image > Lookup Tables` menu
10 changes: 10 additions & 0 deletions _includes/multichannel_images/activity2_imagejgui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- Open a [sample multichannel image](https://github.com/NEUBIAS/training-resources/raw/master/image_data/xyc_16bit__hela-cells.tif)
- Check the image data type using `Image > Type`. It is 16-bit. Convert it into RGB by selecting `Image > Type > RGB Color`
- Use `File > Save As > Tiff` to save as a 48-bit TIFF
- Now, reopen [sample multichannel image](https://github.com/NEUBIAS/training-resources/raw/master/image_data/xyc_16bit__hela-cells.tif)
- Split the channels using `Image > Color > Split Channels`
- Select any two channels, adjust the brightness and contrast and change their look up table according to your own choice
- Now merge the channels using `Image > Color > Merge Channels...` and select the channels in `C1` and `C2` fields and leave other channels set to `*None*`
- _Note:_ Keep these settings: [x] - Create composite, [] Keep source images, [] Ignore source LUTs
- Convert this image to RGB using `Image > Type > RGB Color`
- Use `File > Save As > Tiff` to save as a TIFF
14 changes: 14 additions & 0 deletions _includes/projections/projections_act1_skimage_napari.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#
#

# %%
import sys
sys.path.append("C:\\Users\\akhan\\python_course")

# %%
# Import python packages.
from OpenIJTIFF import open_ij_tiff
Expand All @@ -26,6 +30,7 @@
image.shape



# %%
# Maximum projection along z-axis. i.e. axis = 0
max_z_image = np.max(image, axis=0)
Expand Down Expand Up @@ -91,3 +96,12 @@
rescaled_max_x_image = rescale(max_x_image, [dz/dy,1])
viewer.add_image(rescaled_max_x_image)


# %%
rescaled_max_x_image.shape


# %%
rescaled_max_y_image.shape

# %%
7 changes: 3 additions & 4 deletions _modules/image_inspection_and_presentation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Quantitative image inspection and presentation
title: Quantitative image inspection and presentation
layout: module
tags: ["workflow"]
prerequisites:
Expand All @@ -19,7 +19,7 @@ figure: /figures/image_inspection_and_presentation.png
figure_legend: "Fluorescence microscopy data showing collagen secretion of tissue culture cells. Left: 0 hours secretion of collagen; right: 96 hours secretion of collagen."

multiactivities:
- ["image_inspection_and_presentation/inspect_collagen_data.md", [["ImageJ Macro", "image_inspection_and_presentation/inspect_collagen_data.ijm"]]]
- ["image_inspection_and_presentation/inspect_collagen_data.md", [["ImageJ Macro", "image_inspection_and_presentation/inspect_collagen_data.ijm"], ["ImageJ GUI", "image_inspection_and_presentation/inspect_collagen_datagui.md"]]]
- ["image_inspection_and_presentation/create_collagen_figure.md", [["Powerpoint", "image_inspection_and_presentation/create_collagen_figure_powerpoint.md"]]]

assessment: >
Expand All @@ -28,7 +28,7 @@ assessment: >

1. TODO ___ .
1. TODO ___ .

> ## Solution
> 1. TODO
> 1. TODO
Expand All @@ -39,4 +39,3 @@ learn_next:
external_links:
- "[Forum discussion on collagen figure creation](https://forum.image.sc/t/image-data-figure-creation-best-practices-example-for-collagen-secretion/84584)"
---

67 changes: 67 additions & 0 deletions _modules/multichannel_images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Multichannel images
layout: module
prerequisites:
- "[Digital image basics](../pixels)"
- "[Data types](../datatypes)"
- "[Lookup tables](../lut)"
objectives:
- Understand/visualize different image channels.
motivation: >
Typically, multichannel imaging involves using a fluorescence microscope equipped with multiple filter sets or detectors, each specific to a particular fluorophore's emission wavelength. In fluorescence microscopy, fluorescence signal of different dyes (at different wavelengths) can be registered simultaneously to one set of image spatial coordinates. Each signal then represents one channel and this information can be used to study/analyze various cellular and molecular processes e.g. colocalization.

concept_map: >
graph TD
F("Multichannel image")
F --> C1("Channel 1")
F --> C2("Channel 2")
F --> CA(". . . .")
F --> CN("Channel n")


figure: /figures/multichannel_2d_image.png

figure_legend: Multichannel image. Example for three 2D (xy) channels. Left - Each individual image is a channel shown in blue, red and green lookup tables.
Right - All channels overlaid to display a composite image.
Note that the array shape of (x,y,c) is just an example of channel order. The order may vary depending upon the data structure used to read image

activity_preface: |
- Open a [sample multichannel image](https://github.com/NEUBIAS/training-resources/raw/master/image_data/xyc_16bit__hela-cells.tif)
- This is a 16-bits/channel composite color image of HeLa cells with red lysosomes, green mitochondria and blue nucleus. Image courtesy of Tony Collins, creator of the ImageJ for Microscopy collection of plugins at <http://www.macbiophotonics.ca/imagej/>
- Explore how different channels can be viewed and selected
- Learn to adjust look up tables and brightness/contrast settings
- Learn to select channels and make an RGB image

activities:
- ["ImageJ GUI - Inspect/view channels", "multichannel_images/activity1_imagejgui.md", "markdown"]
#- ["binarization/binarization_act1.md", [["ImageJ GUI", "binarization/binarization_act1_imagejgui.md"], ["ImageJ Macro", "binarization/binarization_act1_imagejmacro.ijm"], ["ImageJ Jython", "binarization/binarization_act1_jython.py"], ["skimage napari", "binarization/binarization_act1_skimage_napari.py", "python"]]]
- ["ImageJ GUI - Save channels as Tiff/RGB image", "multichannel_images/activity2_imagejgui.md", "markdown"]

assessment: >

### True of false?

1. An RGB image is a 3-dimensional image
1. In a multichannel image, each channel is a grayscale image that represents different data


> ## Solution
> 1. True
> 1. True
{: .solution}

### Discuss with your neighbor

1. How can multichannel images be used to improve machine learning models for image/object classification?
1. What is a potential challenge when analyzing multichannel images?

> ## Solution
> 1. By providing additional context and information that can be leveraged by the model
> 1. Correcting for crosstalk or bleed-through between channels
{: .solution}

learn_next:

external_links:

---
Loading
Loading