magmap.gui.atlas_editor module

Atlas editing GUI in the MagellanMapper package.

class magmap.gui.atlas_editor.AtlasEditor(img5d, labels_img, channel, offset, fn_close_listener, borders_img=None, fn_show_label_3d=None, title=None, fn_refresh_atlas_eds=None, fig=None, fn_status_bar=None)[source]

Bases: ImageSyncMixin

Graphical interface to view an atlas in multiple orthogonal dimensions and edit atlas labels.

plot_eds are dictionaries of keys specified by one of magmap.config.PLANE plane orientations to Plot Editors.

Variables:
  • labels_img – Numpy image array in z,y,x format.

  • channel – Channel of the image to display.

  • offset – Index of plane at which to start viewing in x,y,z (user) order.

  • fn_close_listener – Handle figure close events.

  • borders_img – Numpy image array in z,y,x,[c] format to show label borders, such as that generated during label smoothing. Defaults to None. If this image has a different number of labels than that of labels_img, a new colormap will be generated.

  • fn_show_label_3d – Function to call to show a label in a 3D viewer. Defaults to None.

  • title (str) – Window title; defaults to None.

  • fn_refresh_atlas_eds (func) – Callback for refreshing other Atlas Editors to synchronize them; defaults to None. Typically takes one argument, this AtlasEditor object to refreshing it. Defaults to None.

  • alpha_slider – Matplotlib alpha slider control.

  • alpha_reset_btn – Maplotlib button for resetting alpha transparency.

  • alpha_last – Float specifying the previous alpha value.

  • interp_planes – Current InterpolatePlanes object.

  • interp_btn – Matplotlib button to initiate plane interpolation.

  • save_btn – Matplotlib button to save the atlas.

  • fn_status_bar (func) – Function to call during status bar updates in pixel_display.PixelDisplay; defaults to None.

  • fn_update_coords (func) – Handler for coordinate updates, which takes coordinates in z-plane orientation; defaults to None.

alpha_reset(event)[source]

Reset the alpha transparency in all plot editors.

Parameters:

event – Button event, currently ignored.

alpha_update(event)[source]

Update the alpha transparency in all plot editors.

Parameters:

event – Slider event.

color_picker_changed(text)[source]

Respond to color picker TextBox changes by updating the specified intensity value in all plot editors.

Parameters:

text (str) – String of text box value. Converted to an int if non-empty.

get_save_path()[source]
Get figure save path based on filename, ROI, and overview plane

shown.

Returns:

Figure save path.

Return type:

str

interpolate(event)[source]

Interpolate planes using interp_planes.

Parameters:

event – Button event, currently ignored.

on_key_press(event)[source]

Respond to key press events.

planes: Sequence[str]

Sequence of planes to show in the Plot Editors. Planes are given as axis-border strings (eg “xy”). Defaults to magmap.settings.config.PLANE. Plots are ordered clockwise from the left of the Atlas Editor and can be None to remove the plot.

refresh_images(plot_ed=None, update_atlas_eds=False)[source]

Refresh images in a plot editor, such as after editing one editor and updating the displayed image in the other editors.

Parameters:
  • plot_ed (magmap.plot_editor.PlotEditor) – Editor that does not need updating, typically the editor that originally changed. Defaults to None.

  • update_atlas_eds (bool) – True to update other ``AtlasEditor``s; defaults to False.

save_atlas(event=None)[source]

Save atlas labels using the registered image suffix given by config.reg_suffixes[config.RegSuffixes.ANNOTATION].

Parameters:

event (default: None) – Button event, currently not used; defaults to None.

scroll_overview(event)[source]

Scroll images and crosshairs in all plot editors

Parameters:

event – Scroll event.

show_atlas()[source]

Set up the atlas display with multiple orthogonal views.

toggle_edit_mode(event)[source]

Toggle editing mode, determining the current state from the first magmap.plot_editor.PlotEditor and switching to the opposite value for all plot editors.

Parameters:

event – Button event, currently not used.

update_color_picker(val)[source]

Update the color picker TextBox with the given value.

Parameters:

val (str) – Color value. If None, only color_picker_changed() will be triggered.

update_coords(coord, plane_src='xy')[source]

Update all plot editors with given coordinates.

Parameters:
  • coord – Coordinate at which to center images, in z,y,x order.

  • plane_src (default: 'xy') – One of magmap.config.PLANE (defaults to first element) to specify the orientation from which the coordinates were given.

view_subimg(offset, shape)[source]

Zoom all Plot Editors to the given sub-image.

Parameters:
  • offset – Sub-image coordinates in z,y,x order.

  • shape – Sub-image shape in z,y,x order.

class magmap.gui.atlas_editor.InterpolatePlanes(btn)[source]

Bases: object

Track manually edited planes between which to interpolate changes for a given label.

This interpolation replaces unedited planes based on the trends of the edited ones to avoid the need to manually edit every single plane.

Variables:
  • btn (matplotlib.widgets.Button) – Button to initiate plane interpolation.

  • plane (str) – Plane in which editing has occurred.

  • bounds (List[int]) – Unsorted start and end planes.

  • label_id (int) – Label ID of the edited region.

property bounds

Get the bounds property.

interpolate(labels_img)[source]

Interpolate between bounds in the given plane direction in the bounding box surrounding label_id.

Parameters:

labels_img – Labels image as a Numpy array of x,y,z dimensions.

update_btn()[source]

Update text and color of button to interpolate planes.

update_plane(plane, i, label_id)[source]

Update the current plane.

Parameters:
  • plane – Plane direction, which will overwrite any current direction.

  • i – Index of the plane to add, which will overwrite the oldest bounds element.

  • label_id – ID of label, which will overwrite any current ID.