magmap.gui.plot_editor module¶
Editor for 2D plot with overlaid planes.
Integrates with :class:atlas_editor.AtlasEditor for synchronized 3D
view of orthogonal planes.
- class magmap.gui.plot_editor.PlotAxImg(ax_img, vmin=None, vmax=None, img=None)[source]¶
Bases:
objectAxes image storage class.
Tracks settings that may differ between the currently displayed image and input values, such as
Noneto specify auto-intensity and values for brightness and contrast that are not stored in the image itself.- Variables:
ax_img – Displayed Matplotlib image.
vmin – Specified vmin; defaults to None for auto-scaling. See
ax_img.norm.vminfor the output vmin.vmax – Specified vmax; defaults to None for auto-scaling. See
ax_img.norm.vmaxfor the output vmax.brightness – Brightness addend; defaults to 0.0.
contrast – Contrast factor; defaults to 1.0.
alpha – Opacity level; defaults to None.
alpha_blend – Opacity level of the first level in the area of blending between two images; defaults to None.
- class magmap.gui.plot_editor.PlotEditor(overlayer, img3d, img3d_labels=None, cmap_labels=None, plane=None, fn_update_coords=None, fn_refresh_images=None, scaling=None, plane_slider=None, img3d_borders=None, cmap_borders=None, fn_show_label_3d=None, interp_planes=None, fn_update_intensity=None, max_size=None, fn_status_bar=None, img3d_extras=None)[source]¶
Bases:
objectShow a scrollable, editable plot of sequential planes in a 3D image.
- Variables:
intensity (int) – Chosen intensity value of
img3d_labels.intensity_spec (int) – Intensity value specified directly rather than chosen from the labels image.
intensity_shown (int) – Displayed intensity in the
matplotlib.AxesImagecorresponding toimg3d_labels.coord (List[int]) – Coordinates in
z, y, x.scale_bar (bool) – True to add a scale bar; defaults to False.
enable_painting (bool) – True to enable label painting; defaults to True.
max_intens_proj (int) – Number of planes to include in a maximum intensity projection; defaults to 0 for no projection. The planes are taken starting from the given z-value in
coord, limited by the number of planes available. Applied to the first intensity image.
- ALPHA_DEFAULT = 0.5¶
-
alpha:
float¶ Labels opacity from 0-1; defaults to
ALPHA_DEFAULT.
-
alpha_img3d:
Sequence[float]¶ Main image opacity as a sequence of values from 0-1 for each channel. Defaults to a list of the first element in
config.alphas.
- static change_brightness_contrast(plot_ax_img, brightness, contrast)[source]¶
Change image brightness and contrast.
All changes are made relative to the original image, so both brightness and contrast should be given together. For example, if brightness is changed, and later contrast is changed, the contrast change will wipe out the brightness change unless the brightness value is given again.
-
cmap_labels:
Optional[ListedColormap]¶ Labels colormap, generally of
magmap.plot.colormaps.DiscreteColormap. Defaults to None.
- draw_crosslines(show=None)[source]¶
Draw crosshairs depicting the x and y values in orthogonal viewers.
- Parameters:
show (bool) – True to show crosslines, False to make them invisible; defaults to None to use
show_crosslines.
- property edit_mode: bool¶
Atlas labels edit mode status.
- Returns:
True if in edit mode, False otherwise.
-
fn_update_coords:
Callable[[Sequence[int],str],None]¶ Callback when updating coordinates, typically mouse click events in x,y; takes two arguments, the updated coordinates and
planeto indicate the coordinates’ orientation.
- static get_plot_ax_img(plot_ax_imgs, imgi, channels=None, chl=None)[source]¶
Get a plotted image based on image group and channel.
- Parameters:
plot_ax_imgs (
Sequence[Sequence[PlotAxImg]]) – Plotted image objects, organized as[[img0_chl0, img0_chl1, ...], [img1_chl0, ...], ....].imgi (
int) – Index of image group inplot_ax_imgs.channels (
Optional[Sequence[Sequence[int]]], default:None) – List of channel lists corresponding toplot_ax_imgs; defalts to None to usechldirectly.chl (
Optional[int], default:None) – Index of channel within the selected image group; defaults to None to use the first channel.
- Return type:
- Returns:
The selected plotted image, or None if image corresponding to
imgiandchlis not found.
-
label_motion_thresh:
float¶ Threshold for triggering label motion events. Use 0 (default) to respond to all events except those within the same pixel. Higher values filter more movements, especially fast and short motions. Use np.inf to ignore motion and respond to left-click instead.
Threshold for triggering navigation (eg pan/zoom) events. See
label_motion_thresh, except np.inf simply turns off navigation.
- on_key_press(event)[source]¶
Change pen radius with bracket ([/]) buttons.
The “ctrl” modifier will have the increment.
- Parameters:
event – Key press event.
- on_release(event)[source]¶
Respond to mouse button release events.
If labels were edited during the current mouse press, update plane interpolation values. Also reset any specified intensity value.
- Parameters:
event – Key press event.
-
overlayer:
ImageOverlayer¶ Manager for plotting overlaid images.
-
plane:
str¶ One of
magmap.settings.config.PLANEspecifying the orthogonal plane to view.
- set_show_label(val)[source]¶
Set whether to show labels on hover.
- Parameters:
val (bool) – True to show labels, False otherwise.
- show_labels(show=True, **kwargs)[source]¶
Show or remove labels for all regions.
- Parameters:
show (
bool, default:True) – True (default) to show all labels; False to remove them.kwargs – Arguments passed to
magmap.plot_support.ImageOverlayer.annotate_labels().
- show_roi(offset=None, size=None, preview=False)[source]¶
Show an ROI as an empty rectangular patch.
If
offsetandsizecannot be retrieved, no ROI will be shown.- Parameters:
offset (List[int]) – ROI offset in
y, x. Defaults to None to use the saved ROI offset if available.size (List[int]) – ROI size in
y, x. Defaults to None to use the saved ROI size if available.preview (bool) – True if the ROI should be displayed as a preview, which is lighter and transient, removed when another preview ROI is displayed. Defaults to False. If False, ROI parameters for a displayed ROI will be shown.
- translate_coord(coord, up=False, coord_slice=None)[source]¶
Translate coordinate based on downsampling factor of the main image.
Coordinates sent to and received from the Atlas Editor are assumed to be in the original image space. All overlaid images are assumed to be resized to the shape of the main image.
- Parameters:
up (
bool, default:False) – True to upsample; defaults to False, which adjusts coordinates for downsampled images.coord_slice (
Union[slice,Sequence[slice],None], default:None) – Slice of each set of coordinates to transpose. Defaults to None, which gives a slice starting at 1 so that the z-value will not be adjusted on the assumption that downsampling is only performed inx,y.
- Returns:
The translated coordinates.
- Return type:
List[int]
- update_coord(coord=None)[source]¶
Update the displayed image for the given coordinates.
Scroll to the given z-plane if changed and draw crosshairs to indicated the corresponding
x,yvalues.- Parameters:
coord (List[int]) – Coordinates in z,y,x, assumed to be transposed so the z-plane is show in this editor; defaults to None to use
coord.
- update_img_display(imgi, chl=None, minimum=nan, maximum=nan, brightness=None, contrast=None, alpha=None, alpha_blend=None)[source]¶
Update displayed image settings.
- Parameters:
imgi (
int) – Index of image group.chl (
Optional[int], default:None) – Index of channel within the group; defaults to None.minimum (
float, default:nan) – Vmin; can be None for auto setting; defaults tonp.nanto ignore.maximum (
float, default:nan) – Vmax; can be None for auto setting; defaults tonp.nanto ignore.brightness (
Optional[float], default:None) – Brightness addend; defaults to None.contrast (
Optional[float], default:None) – Contrast multiplier; defaults to None.alpha (
Optional[float], default:None) – Opacity value; defaults to None.alpha_blend (
Optional[float], default:None) – Opacity blending value; defaults to None. False turns off alpha blending, resetting the images to their stored alpha values.
- Return type:
- Returns:
The updated axes image plot.
- static update_plot_ax_img_display(plot_ax_img, minimum=nan, maximum=nan, brightness=None, contrast=None, alpha=None, **kwargs)[source]¶
Update plotted image display settings.
- Parameters:
plot_ax_img (
PlotAxImg) – Plotted image.minimum (
float, default:nan) – Vmin; can be None for auto setting; defaults tonp.nanto ignore.maximum (
float, default:nan) – Vmax; can be None for auto setting; defaults tonp.nanto ignore.brightness (
Optional[float], default:None) – Brightness addend; defaults to None.contrast (
Optional[float], default:None) – Contrast multiplier; defaults to None.alpha (
Optional[float], default:None) – Opacity value; defalts to None.**kwargs – Extra arguments, currently ignored.
- Return type:
- Returns:
The updated axes image plot.