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

Various updates to python activities on multiscale and spatial calibration #656

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Remove Markdown from skimage activities
in Multidimensional images, and
and Spatial Calibration.
  • Loading branch information
k-dominik committed May 28, 2024
commit 072a00f0ee6b4b7c5408a134439f5ee7cbc974f2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# ## Explore a 3D image
# %%
# Explore a 3D image

# %%
# Load the image
@@ -11,9 +11,9 @@
napari_viewer = Viewer()
napari_viewer.add_image(image)

# %% [markdown]
# **Napari GUI** Explore different sliders and values in the bottom left part \
# **Napari GUI** Show in 3D. Note that the scalings are not yet correct.
# [markdown]
# Napari GUI: Explore different sliders and values in the bottom left part.
# Napari GUI: Show in 3D. Note that the scalings are not yet correct.

# %%
# Print image axes metadata
@@ -23,8 +23,8 @@
print("Units: ", units)

# %%
# Add image with scaling.
napari_viewer.add_image(image, name = "Scaled image", scale = scales)
# Add image with scaling.
napari_viewer.add_image(image, name = "Scaled image", scale = scales)

# %% [markdown]
# **Napari GUI** View scaled image in 3D. Note that the scaling is now correct.
# %%
# Napari GUI: View scaled image in 3D. Note that the scaling is now correct.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# %% [markdown]
# %%
# ## Explore a 3D multi-channel image

# %%
# Load the image
# Load the image
from OpenIJTIFF import open_ij_tiff
image, axes, scales, units = open_ij_tiff("https://github.com/NEUBIAS/training-resources/raw/master/image_data/xyzc_8bit_beads_p_open.tif")

@@ -19,9 +19,9 @@
napari_viewer = Viewer()
napari_viewer.add_image(image, scale = scales)

# %% [markdown]
# **Napari GUI** Explore different sliders and values in the bottom left part \
# **Napari GUI** Delete the image
# %%
# Napari GUI: Explore different sliders and values in the bottom left part.
# Napari GUI: Delete the image.

# %%
# Create images as separate channels
@@ -41,5 +41,5 @@
napari_viewer.add_image(image_ch0, name = 'Ch0_ns', colormap = 'magenta')
napari_viewer.add_image(image_ch1, name = 'Ch1_ns', colormap = 'green', blending='additive')

# %% [markdown]
# **Napari GUI** Explore different blending modes and LUTs
# %%
# Napari GUI: Explore different blending modes and LUTs.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# ## Inspect a 3D time-lapse image
# %%
# Inspect a 3D time-lapse image

# %%
# Load the image
@@ -19,6 +19,6 @@
napari_viewer = Viewer()
napari_viewer.add_image(image, scale = scales)

# %% [markdown]
# **Napari GUI** Explore different axes sliders and values in the bottom left part \
# **Napari GUI** Show in 3D.
# %%
# Napari GUI: Explore different axes sliders and values in the bottom left part.
# Napari GUI: Show in 3D.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# %% [markdown]
# ## Explore a 5D image (3D image + channels + time)
# %%
# Explore a 5D image (3D image + channels + time)

# %%
# Load the image
@@ -19,10 +19,11 @@
napari_viewer = Viewer()
napari_viewer.add_image(image, scale = scales)

# %% [markdown]
# **Napari GUI** Explore different sliders and values in the bottom left part \
# **Napari GUI** Show in 3D. Note that the order of axes is not yet correct.\ Napari expects that the last 3 dimension are ZYX\
# **Napari GUI** Delete image
# %%
# Napari GUI: Explore different sliders and values in the bottom left part.
# Napari GUI: Show in 3D. Note that the order of axes is not yet correct.
# Napari expects that the last 3 dimension are ZYX.
# Napari GUI: Delete image.

# %%
# Remove channel from scale
@@ -36,16 +37,16 @@
napari_viewer.add_image(image[:,:,0,:,:], scale = scales_tzyx, name = 'Ch0', colormap = 'magenta')
napari_viewer.add_image(image[:,:,1,:,:], scale = scales_tzyx, name = 'Ch1', colormap = 'green', blending='additive')

# %% [markdown]
# **Napari GUI** Explore different sliders and values in the bottom left part \
# **Napari GUI** delete image and try direct loading
# %%
# Napari GUI: Explore different sliders and values in the bottom left part.
# Napari GUI: delete image and try direct loading.

# %%
# View image as separate channels in one step
napari_viewer.add_image(image, channel_axis = 2, scale = scales_tzyx, name = ['Ch0', 'Ch1'])

# %% [markdown]
# **Napari GUI** delete image
# %%
# Napari GUI: delete image.

# %%
# Loading with numpy transpose
@@ -54,5 +55,5 @@
scales_transpose = [scales[2],scales[0],scales[1],scales[3],scales[4]]
napari_viewer.add_image(image_transpose, scale = scales_transpose)

# %% [markdown]
# **Napari GUI** Right mouse click on image and `split stack`. This will generate visible two channels
# %%
# Napari GUI: Right mouse click on image and `split stack`. This will generate visible two channels.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# %% [markdown]
# ## Spatial image calibration
# #### Requirements
# - [skimage and napari](https://neubias.github.io/training-resources/tool_installation/index.html#skimage_napari)
# %%
# Spatial image calibration

# %%
# Import python packages.
@@ -27,15 +25,15 @@
napari_viewer = Viewer()
napari_viewer.add_image(image, scale=voxel_size)

# %% [markdown]
# **Napari GUI**: Change the axes order using the corresponding button. \
# **Napari GUI**: Use the 3D viewer button to render the image in 3D.
# %%
# Napari GUI: Change the axes order using the corresponding button.
# Napari GUI: Use the 3D viewer button to render the image in 3D.

# %% [markdown]
# ### Compute distances between points
# %%
# Compute distances between points
#
# **Napari GUI** use the `New points layer button` to create a new points layer \
# **Napari GUI** use `Add points` to add two points somewhere on the meta-phase plate \
# Napari GUI: use the `New points layer button` to create a new points layer.
# Napari GUI: use `Add points` to add two points somewhere on the meta-phase plate.

# %%
# extract point coordinates
@@ -51,7 +49,7 @@
print("Voxel size: ", voxel_size)

# %%
points_cal = points * scale
points_cal = points * scale
print("Points :\n", points)
print("Calibrated points :\n", points_cal)

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# %% [markdown]
# ## Spatial image calibration
# #### Requirements
# - [skimage and napari](https://neubias.github.io/training-resources/tool_installation/index.html#skimage_napari)
# %%
# Spatial image calibration

# %%
# Import python packages.
@@ -39,7 +37,7 @@
# %%
# Note that the 3D image does not have calibrated metadata.
# Let's add spatial calibration using the x&y voxel_size from the 2D image
# and also add a z scaling
# and also add a z scaling
voxel_size_image_3D = [0.52, voxel_size_image_2D[1], voxel_size_image_2D[0]]
units_image_3D = ["um","um","um"]

@@ -56,8 +54,8 @@
napari_viewer.add_image(image_2D, scale=voxel_size_image_2D, name='image_2D')
napari_viewer.add_image(image_3D, scale=voxel_size_image_3D, name='image_3D')

# %% [markdown]
# Napari GUI: Change the axes order using the corresponding button. \
# %%
# Napari GUI: Change the axes order using the corresponding button.
# Napari GUI: Use the 3D viewer button to render the image in 3D.

# %%