erlab.interactive.imagetool.viewer_linking

Linking and history decorators for ImageTool viewer widgets.

Functions

link_slicer([func, indices, steps, color])

Sync decorated methods across multiple ImageSlicerArea instances.

record_history([method])

Log history before calling the decorated method.

suppress_history([method])

Ignore history changes made within the decorated method.

Classes

SlicerLinkProxy(*slicers[, link_colors])

Internal class for handling linked ImageSlicerArea s.

erlab.interactive.imagetool.viewer_linking.suppress_history(method=None)[source]

Ignore history changes made within the decorated method.

erlab.interactive.imagetool.viewer_linking.record_history(method=None)[source]

Log history before calling the decorated method.

Sync decorated methods across multiple ImageSlicerArea instances.

Parameters:
  • func (Callable | None, default: None) – The method to sync across multiple instances of ImageSlicerArea.

  • indices (bool, default: False) – If True, the input argument named value given to func are interpreted as indices, and will be converted to appropriate values for other instances of ImageSlicerArea. The behavior of this conversion is determined by steps. If True, An input argument named axis of type integer must be present in the decorated method to determine the axis along which the index is to be changed.

  • steps (bool, default: False) – If False, considers value as an absolute index. If True, considers value as a relative value such as the number of steps or bins. See the implementation of SlicerLinkProxy for more information.

  • color (bool, default: False) – Boolean whether the decorated method is related to visualization, such as colormap control.

class erlab.interactive.imagetool.viewer_linking.SlicerLinkProxy(*slicers, link_colors=True)[source]

Bases: object

Internal class for handling linked ImageSlicerArea s.

Parameters:
  • *slicers (ImageSlicerArea) – The slicers to link.

  • link_colors (bool, default: True) – Whether to sync color related changes, by default True.

property children: WeakSet
property num_children: int
add(slicer_area)[source]
remove(slicer_area)[source]
sync(source, funcname, arguments, indices, steps, color, transaction_id, keep_pending)[source]

Propagate changes across multiple ImageSlicerAreas.

This method is invoked every time a method decorated with link_slicer() in a linked ImageSlicerArea is called.

Parameters:
  • source (ImageSlicerArea) – Instance of ImageSlicerArea corresponding to the called method.

  • funcname (str) – Name of the called method.

  • arguments (dict[str, Any]) – Arguments included in the function call.

  • indices (bool) – Arguments given to the decorator. See link_slicer()

  • steps (bool) – Arguments given to the decorator. See link_slicer()

  • color (bool) – Arguments given to the decorator. See link_slicer()

convert_args(source, target, args, indices, steps, transaction_id, keep_pending)[source]
static convert_index(source, target, axis, index, steps)[source]