"""Interactive widget for visualizing slices of a 3D volume.
"""Interactive widget for visualizing slices of a 3D volume.
...
@@ -342,7 +342,7 @@ def slicer(
...
@@ -342,7 +342,7 @@ def slicer(
image_width (int, optional): Width of the figure. Defaults to 3.
image_width (int, optional): Width of the figure. Defaults to 3.
display_positions (bool, optional): If True, displays the position of the slices. Defaults to False.
display_positions (bool, optional): If True, displays the position of the slices. Defaults to False.
interpolation (str, optional): Specifies the interpolation method for the image. Defaults to None.
interpolation (str, optional): Specifies the interpolation method for the image. Defaults to None.
color_bar (bool, optional): Adds a colorbar for the corresponding colormap and data range. Defaults to False.
color_bar (str, optional): Controls the options for color bar. If None, no colorbar is included. If 'volume', the color map range is constant for each slice. If 'slices', the colormap range changes dynamically according to the slice. Defaults to None.
Returns:
Returns:
slicer_obj (widgets.interactive): The interactive widget for visualizing slices of a 3D volume.
slicer_obj (widgets.interactive): The interactive widget for visualizing slices of a 3D volume.
...
@@ -361,14 +361,34 @@ def slicer(
...
@@ -361,14 +361,34 @@ def slicer(
image_height=image_size
image_height=image_size
image_width=image_size
image_width=image_size
color_bar_options=[None,'slices','volume']
ifcolor_barnotincolor_bar_options:
raiseValueError(
f"Unrecognized value '{color_bar}' for parameter color_bar. "
f"Expected one of {color_bar_options}."
)
show_color_bar=color_barisnotNone
ifcolor_bar=='slices':
# Precompute the minimum and maximum along each slice for faster widget sliding.