ROI Manager

Video Tutorial

ModuleGUI

The GUI QDockWidget that communicates with the back-end managers

class mesmerize.viewer.modules.roi_manager.ModuleGUI(parent, viewer_reference)[source]

The GUI front-end for the ROI Manager module

__init__(parent, viewer_reference)[source]

Instantiate attributes

manager

The back-end manager instance.

eventFilter(QObject, QEvent)[source]

Set some keyboard shortcuts

slot_delete_roi_menu()[source]

Delete the currently selected ROI

start_backend(type_str: str)[source]

Choose backend, one of the Manager classes in the managers module.

start_manual_mode()[source]

Start in manual mode. Creates a new back-end manager instance (Uses ManagerManual)

add_manual_roi(shape: str)[source]

Add a manual ROI. Just calls ManagerManual.add_roi

package_for_project()dict[source]

Gets all the ROI states so that they can be packaged along with the rest of the work environment to be saved as a project Sample

set_all_from_states(states: dict)[source]

Set all the ROIs from a states dict. Instantiates the appropriate back-end Manager

import_from_imagej()[source]

Import ROIs from ImageJ zip file

Managers

The back-end managers that are used by the ROI Manager ModuleGUI

The managers hold instances of ROIs in an instance of ROIList

AbstractBaseManager

Subclass this if you want to make your own Manager Back-end.

class mesmerize.viewer.modules.roi_manager_modules.managers.AbstractBaseManager(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Base ROI Manager

__init__(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Set the common attributes

Parameters
  • parent – The ModuleGUI QDockWidget instance

  • ui – The ui of the ModuleGUI QDockWidget instance,

  • viewer_interface – A ViewerUtils instance for accessing the Viewer the parent QDockWidget belongs to

roi_list

The ROIList instance that stores the list of ROIs

abstract add_roi(*args, **kwargs)[source]

Method for adding an ROI, must be implemented in subclass

is_empty()bool[source]

Return true if the ROI list is empty, else return False

get_all_states()dict[source]

Get the ROI states for all ROIs in self.roi_list so that they can be restored. The appropriate manager is instantiated based on the ‘roi_type’ key of the returned dict

get_plot_item() → mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem[source]

Get the viewer plot item that is associated to these ROIs

clear()[source]

Cleanup of all ROIs in the list

__del__()[source]

Cleanup of all ROIs in the list and deletes the manager instance. Used when switching modes.

__weakref__

list of weak references to the object (if defined)

ManagerManual

class mesmerize.viewer.modules.roi_manager_modules.managers.ManagerManual(parent, ui, viewer_interface)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.managers.AbstractBaseManager

The Manager for the Manual mode

__init__(parent, ui, viewer_interface)[source]

Set the common attributes

Parameters
  • parent – The ModuleGUI QDockWidget instance

  • ui – The ui of the ModuleGUI QDockWidget instance,

  • viewer_interface – A ViewerUtils instance for accessing the Viewer the parent QDockWidget belongs to

create_roi_list()[source]

Create a new empty ROI list instance for storing Manual ROIs

add_roi(shape: str)mesmerize.viewer.modules.roi_manager_modules.roi_types.ManualROI[source]

Add an ROI to the list

Parameters

shape – either “PolyLineROI” or “EllipseROI”

restore_from_states(states: dict)[source]

Restore ROIs from states

get_all_states()dict[source]

Get the ROI states so that they can be restored later

import_from_imagej(path: str)[source]

Uses read-roi package created by Hadrien Mary. https://pypi.org/project/read-roi/

Parameters

path – Full path to the ImageJ ROIs zip file

ManagerScatterROI

class mesmerize.viewer.modules.roi_manager_modules.managers.ManagerScatterROI(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.managers.AbstractBaseManager

Manager for unmoveable ROIs drawn using scatterplots

__init__(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Set the common attributes

Parameters
  • parent – The ModuleGUI QDockWidget instance

  • ui – The ui of the ModuleGUI QDockWidget instance,

  • viewer_interface – A ViewerUtils instance for accessing the Viewer the parent QDockWidget belongs to

add_roi(curve: numpy.ndarray, xs: numpy.ndarray, ys: numpy.ndarray, metadata: dict = None, dfof_data: numpy.ndarray = None, spike_data: numpy.ndarray = None)mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI[source]

Add a single ROI

xs and ys arguments are 1D numpy arrays.

Parameters
  • curve – curve data, 1-D array, y values/intensity values

  • xs – x-values for the scatter plot to spatially illustrate the ROI

  • ys – corresponding y-values for the scatter plot to spatially illustrate the ROI

  • metadata – Any metadata for this ROI

Returns

ScatterROI object

restore_from_states(states: dict)[source]

Restore from states, such as when these ROIs are saved with a Project Sample

create_roi_list()[source]

Create empty ROI List

set_spot_size(size: int)[source]

Set the spot size for the scatter plot which illustrates the ROI

ManagerVolROI

class mesmerize.viewer.modules.roi_manager_modules.managers.ManagerVolROI(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.managers.ManagerScatterROI

Manager for 3D ROIs

__init__(parent, ui, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Set the common attributes

Parameters
  • parent – The ModuleGUI QDockWidget instance

  • ui – The ui of the ModuleGUI QDockWidget instance,

  • viewer_interface – A ViewerUtils instance for accessing the Viewer the parent QDockWidget belongs to

set_zlevel(z: int)[source]

Set the current z-level to be visible in the viewer

create_roi_list()[source]

Create new empty ROI list

ManagerVolCNMF

class mesmerize.viewer.modules.roi_manager_modules.managers.ManagerVolCNMF(parent, ui, viewer_interface)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.managers.ManagerVolROI

Manager for 3D CNMF based ROIs

__init__(parent, ui, viewer_interface)[source]

Set the common attributes

Parameters
  • parent – The ModuleGUI QDockWidget instance

  • ui – The ui of the ModuleGUI QDockWidget instance,

  • viewer_interface – A ViewerUtils instance for accessing the Viewer the parent QDockWidget belongs to

create_roi_list()[source]

Create new empty ROI list

add_all_components(cnmf_data_dict: dict, input_params_dict: dict)[source]

Add all components from a CNMF(E) output. Arguments correspond to CNMF(E) outputs

Parameters
  • cnmf_data_dict – CNMF results data directly from the HDF5 file

  • input_params_dict – dict of input params, from the batch manager

  • calc_raw_min_max – Calculate raw min & max for each ROI

Returns

add_roi()[source]

Not implemented, uses add_all_components to import all ROIs instead

restore_from_states(states: dict)[source]

Restore from states, such as when these ROIs are saved with a Project Sample

get_all_states()dict[source]

Get all states so that they can be restored

update_idx_components(ix: int)[source]

Update idx_components if the user manually delete an ROI

set_spot_size(size: int)[source]

Set the spot size for the scatter plot which illustrates the ROI

ManagerCNMFROI

class mesmerize.viewer.modules.roi_manager_modules.managers.ManagerCNMFROI(parent, ui, viewer_interface)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.managers.AbstractBaseManager

Manager for ROIs imported from CNMF or CNMFE outputs

__init__(parent, ui, viewer_interface)[source]

Instantiate necessary attributes

create_roi_list()[source]

Create empty CNMFROI list

add_all_components(cnmf_data_dict, input_params_dict, calc_raw_min_max=False)[source]

Add all components from a CNMF(E) output. Arguments correspond to CNMF(E) outputs

Parameters
  • cnmf_data_dict – CNMF results data directly from the HDF5 file

  • input_params_dict – dict of input params, from the batch manager

  • calc_raw_min_max – Calculate raw min & max for each ROI

Returns

add_roi()[source]

Not implemented, uses add_all_components to import all ROIs instead

restore_from_states(states: dict)[source]

Restore from states, such as when these ROIs are saved with a Project Sample

get_all_states()dict[source]

Get all states so that they can be restored

update_idx_components(ix: int)[source]

Update idx_components if the user manually delete an ROI

ROI List

Used for holding instance of ROIs

class mesmerize.viewer.modules.roi_manager_modules.roi_list.ROIList(ui, roi_types: type, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

A list for holding ROIs of one type

__init__(ui, roi_types: type, viewer_interface: mesmerize.viewer.core.common.ViewerUtils)[source]

Instantiate

Parameters
  • ui – The ui from the parent ModuleGUI, used to interact with the ROI list widget etc.

  • roi_types – The type of ROI that this list will hold

  • viewer_interface – ViewerUtils instance for interacting with the parent Viewer

list_widget

ROI list widget

list_widget_tags

Tags list widget

vi

ViewrUtils instance

current_index

Current index (int)

previous_index

Previous index (int)

append(roi: Union[mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI, mesmerize.viewer.modules.roi_manager_modules.roi_types.ManualROI])[source]

Add an ROI instance to the list

clear_()[source]

Cleanup of the list

__delitem__(key)[source]

Delete an ROI from the list and cleanup from the viewer, reindex the colors etc.

disconnect_all()[source]

Disconnect signals from the parent GUI

_reindex_list_widget()[source]

Reindex ROI list

reindex_colormap()[source]

Reindex the colors so they sequentially follow the HSV colormap

__getitem__(item) → Union[mesmerize.viewer.modules.roi_manager_modules.roi_types.ManualROI, mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI][source]

Get an item (ROI) from the list

set_current_index(ix: int)[source]

Set the current index

highlight_roi(roi: Union[mesmerize.viewer.modules.roi_manager_modules.roi_types.ManualROI, mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI])[source]

Highlight an ROI in white, both the spatial visualization and the curve

highlight_curve(ix: int)[source]

Highlight the curve corresponding to the ROI at the passed index

set_previous_index()[source]

Set the previous_index attribute

slot_show_all_checkbox_clicked(b: bool)[source]

Show all ROIs in the viewer overlay visualization and curves

_show_graphics_object(ix: int)[source]

Show the ROI at the passed index in the viewer overlay visualization

_hide_graphics_object(ix: int)[source]

Hide the ROI at the passed index in the viewer overlay visualization

_show_all_graphics_objects()[source]

Show all ROIs in the viewer overlay visualization

_hide_all_graphics_objects()[source]

Hide all ROIs in the viewer overlay visualization

plot_manual_roi_regions()[source]

Plot the ROI curves from the regions of all ManualROI instances in the list

set_pg_roi_plot(ix: int)[source]

Plot the ROI curve from the region of the ManualROI instance at the passed index

set_list_widget_tags()[source]

Set the tags list for the ROI at the current index

update_roi_defs_from_configuration()[source]

Update ROI_DEFs in the Tags list from the project configuration

__weakref__

list of weak references to the object (if defined)

ROI Types

A list of these are held by an instance of ROIList

AbstractBaseROI

class mesmerize.viewer.modules.roi_manager_modules.roi_types._AbstractBaseROI(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict])[source]

Abstract base class defining an ROI that works with the ROIList and ROI Managers. Inherit from this or BaseROI to make a new ROI class

abstract __init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict])[source]

Minimum required attributes

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

abstract get_roi_graphics_object() → PyQt5.QtWidgets.QGraphicsObject[source]

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

abstract set_roi_graphics_object(*args, **kwargs)[source]

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

abstract reset_color()[source]

Reset the color of this ROI back to the original color

abstract set_original_color(color)[source]

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

abstract get_color() → numpy.ndarray[source]

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

abstract set_color(color, *args, **kwargs)[source]

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

abstract set_text(text: str)[source]

Not implemented

abstract set_tag(roi_def: str, tag: str)[source]

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

abstract get_tag(roi_def)str[source]

Get the tag that is set to the passed ‘roi_def’

Return type

str

abstract get_all_tags()dict[source]

Get all the tags for all the ROI_DEFs

Return type

dict

abstract add_to_viewer()[source]

Add this ROI to the viewer.

abstract remove_from_viewer()[source]

Remove this ROI from the viewer

abstract to_state()[source]

Get the current state for this ROI so that it can be restored later

abstract classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict)[source]

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

__weakref__

list of weak references to the object (if defined)

BaseROI

Subclass from this if you want to make your own ROI Type.

class mesmerize.viewer.modules.roi_manager_modules.roi_types.BaseROI(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, metadata: dict = None)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.roi_types._AbstractBaseROI

A base class that is used by ManualROI and CNMFEROI Inherit from this to make a new ROI class

__init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, metadata: dict = None)[source]

Instantiate common attributes

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

get_roi_graphics_object() → PyQt5.QtWidgets.QGraphicsObject[source]

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

set_roi_graphics_object(*args, **kwargs)[source]

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

reset_color()[source]

Reset the color of this ROI back to the original color

set_original_color(color)[source]

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

get_color()[source]

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

set_color(color: Union[numpy.ndarray, str], *args, **kwargs)[source]

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

set_text(text: str)[source]

Not implemented

set_tag(roi_def: str, tag: str)[source]

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

get_tag(roi_def)str[source]

Get the tag that is set to the passed ‘roi_def’

Return type

str

get_all_tags()dict[source]

Get all the tags for all the ROI_DEFs

Return type

dict

add_to_viewer()[source]

Add this ROI to the viewer.

remove_from_viewer()[source]

Remove this ROI from the viewer

to_state()[source]

Must be implemented in subclass

classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict)[source]

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

ManualROI

class mesmerize.viewer.modules.roi_manager_modules.roi_types.ManualROI(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, roi_graphics_object: mesmerize.pyqtgraphCore.graphicsItems.ROI.ROI, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.roi_types.BaseROI

A class manually drawn ROIs

__init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, roi_graphics_object: mesmerize.pyqtgraphCore.graphicsItems.ROI.ROI, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None)[source]
property curve_data

tuple of (xs, ys)

Type

return

get_roi_graphics_object() → mesmerize.pyqtgraphCore.graphicsItems.ROI.ROI[source]

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

set_roi_graphics_object(graphics_object: mesmerize.pyqtgraphCore.graphicsItems.ROI.ROI)[source]

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

to_state()[source]

Must be implemented in subclass

classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict)[source]

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

reset_color()

Reset the color of this ROI back to the original color

set_original_color(color)

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

get_color()

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

set_color(color: Union[numpy.ndarray, str], *args, **kwargs)

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

set_text(text: str)

Not implemented

set_tag(roi_def: str, tag: str)

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

get_tag(roi_def)str

Get the tag that is set to the passed ‘roi_def’

Return type

str

get_all_tags()dict

Get all the tags for all the ROI_DEFs

Return type

dict

add_to_viewer()

Add this ROI to the viewer.

remove_from_viewer()

Remove this ROI from the viewer

ScatterROI

class mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, curve_data: numpy.ndarray = None, xs: numpy.ndarray = None, ys: numpy.ndarray = None, metadata: dict = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, **kwargs)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.roi_types.BaseROI

A class for unmoveable ROIs drawn using scatter points

__init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: Optional[dict] = None, curve_data: numpy.ndarray = None, xs: numpy.ndarray = None, ys: numpy.ndarray = None, metadata: dict = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, **kwargs)[source]
Parameters
  • curve_plot_item

  • view_box

  • state

  • curve_data – 1D numpy array of y values

  • kwargs

set_curve_data(y_vals: numpy.ndarray)[source]

Set the curve data

to_state()dict[source]

Must be implemented in subclass

set_roi_graphics_object(xs: numpy.ndarray, ys: numpy.ndarray)[source]

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

get_roi_graphics_object() → mesmerize.pyqtgraphCore.graphicsItems.ScatterPlotItem.ScatterPlotItem[source]

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict, **kwargs)[source]

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

reset_color()

Reset the color of this ROI back to the original color

set_original_color(color)

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

get_color()

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

set_color(color: Union[numpy.ndarray, str], *args, **kwargs)

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

set_text(text: str)

Not implemented

set_tag(roi_def: str, tag: str)

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

get_tag(roi_def)str

Get the tag that is set to the passed ‘roi_def’

Return type

str

get_all_tags()dict

Get all the tags for all the ROI_DEFs

Return type

dict

add_to_viewer()

Add this ROI to the viewer.

remove_from_viewer()

Remove this ROI from the viewer

VolCNMF

class mesmerize.viewer.modules.roi_manager_modules.roi_types.VolCNMF(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, cnmf_idx: int = None, curve_data: numpy.ndarray = None, contour: dict = None, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, metadata: dict = None, zlevel: int = 0)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI

3D ROI for CNMF data

__init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, cnmf_idx: int = None, curve_data: numpy.ndarray = None, contour: dict = None, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, metadata: dict = None, zlevel: int = 0)[source]
Parameters
  • curve_plot_item

  • view_box

  • state

  • curve_data – 1D numpy array of y values

  • kwargs

to_state()dict[source]

Must be implemented in subclass

set_roi_graphics_object()[source]

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

set_zlevel(z: int)[source]

Set the z-level of the ROI to correspond with the z-level of the image.

Different from setZValue!!

get_roi_graphics_object() → mesmerize.pyqtgraphCore.graphicsItems.ScatterPlotItem.ScatterPlotItem

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

reset_color()

Reset the color of this ROI back to the original color

set_original_color(color)

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

get_color()

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

set_color(color: Union[numpy.ndarray, str], *args, **kwargs)

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

set_text(text: str)

Not implemented

set_tag(roi_def: str, tag: str)

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

get_tag(roi_def)str

Get the tag that is set to the passed ‘roi_def’

Return type

str

get_all_tags()dict

Get all the tags for all the ROI_DEFs

Return type

dict

add_to_viewer()

Add this ROI to the viewer.

remove_from_viewer()

Remove this ROI from the viewer

classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict, **kwargs)

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

set_curve_data(y_vals: numpy.ndarray)

Set the curve data

CNMFROI

class mesmerize.viewer.modules.roi_manager_modules.roi_types.CNMFROI(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, cnmf_idx: int = None, curve_data: numpy.ndarray = None, contour: dict = None, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, metadata: dict = None, **kwargs)[source]

Bases: mesmerize.viewer.modules.roi_manager_modules.roi_types.ScatterROI

A class for ROIs imported from CNMF(E) output data

__init__(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, cnmf_idx: int = None, curve_data: numpy.ndarray = None, contour: dict = None, state: Optional[dict] = None, spike_data: numpy.ndarray = None, dfof_data: numpy.ndarray = None, metadata: dict = None, **kwargs)[source]

Instantiate attributes.

Type

curve_data: np.ndarray

Parameters
  • curve_data – 1D numpy array of y values

  • cnmf_idx – original index of the ROI from cnmf idx_components

get_roi_graphics_object() → mesmerize.pyqtgraphCore.graphicsItems.ScatterPlotItem.ScatterPlotItem

Get the QGraphicsObject used for visualization of the spatial localization of the ROI

set_roi_graphics_object(xs: numpy.ndarray, ys: numpy.ndarray)

Set the QGraphicsObject used for visualization of the spatial localization of the ROI

reset_color()

Reset the color of this ROI back to the original color

set_original_color(color)

Set the original color for this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

get_color()

Get the current color of this ROI

Returns

1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

Return type

np.ndarray

set_color(color: Union[numpy.ndarray, str], *args, **kwargs)

Set the current color of this ROI

Parameters

color – 1D numpy array of 4 floating point numbers (range 0 - 255) in RBGA format, [R, G, B, A]

set_text(text: str)

Not implemented

set_tag(roi_def: str, tag: str)

Set a tag for the passed roi_def

Parameters
  • roi_def – The ROI_DEF that should be tagged

  • tag – The tag to label for the passed ROI_DEF/ROI Type

get_tag(roi_def)str

Get the tag that is set to the passed ‘roi_def’

Return type

str

get_all_tags()dict

Get all the tags for all the ROI_DEFs

Return type

dict

add_to_viewer()

Add this ROI to the viewer.

remove_from_viewer()

Remove this ROI from the viewer

classmethod from_state(curve_plot_item: mesmerize.pyqtgraphCore.graphicsItems.PlotDataItem.PlotDataItem, view_box: mesmerize.pyqtgraphCore.graphicsItems.ViewBox.ViewBox.ViewBox, state: dict, **kwargs)

Restore this ROI from a state

Parameters
  • curve_plot_item – The plot item that is used for display the curves in the viewer

  • view_box – ViewBox containing the image sequence, used for overlaying the ROIs on top of the image

  • state – ROI state, used for restoring the ROIs. Pass None is not restoring an ROI from a state dict

set_curve_data(y_vals: numpy.ndarray)

Set the curve data

to_state()dict[source]

Must be implemented in subclass