This objects stores the data that the Viewer interacts with.
- class mesmerize.viewer.core.ViewerWorkEnv(imgdata: Optional[mesmerize.viewer.core.data_types.ImgData] = None, sample_id='', UUID=None, meta=None, stim_maps=None, roi_manager=None, roi_states=None, comments='', origin_file='', custom_cols=None, history_trace: Optional[list] = None, additional_data: Optional[dict] = None, misc: Optional[dict] = None, **kwargs)¶
UUID, if opened from a project Sample refers to the ImgUUID
- __init__(imgdata: Optional[mesmerize.viewer.core.data_types.ImgData] = None, sample_id='', UUID=None, meta=None, stim_maps=None, roi_manager=None, roi_states=None, comments='', origin_file='', custom_cols=None, history_trace: Optional[list] = None, additional_data: Optional[dict] = None, misc: Optional[dict] = None, **kwargs)¶
A class that encapsulates the main work environment objects (img sequence, ROIs, and ROI associated curves) of the viewer. Allows for a work environment to be easily spawned from different types of sources and allows for a work environment to be easily saved in different ways regardless of the type of original data source.
list of weak references to the object (if defined)
- static _organize_meta(meta: dict, origin: str) → dict¶
Organize input meta data dict into a uniform structure :param meta: meta data dict, origin from a json file for example :param origin: name of the origin source of the meta data, such a program or microscope etc. :return: dict organized with keys that are used throughout Mesmerize.
Cleanup of the work environment
- classmethod from_mesfile(mesfile_object: mesmerize.viewer.core.mesfile.MES, img_reference: str)¶
Return instance of work environment with MesmerizeCore.ImgData class object using seq returned from MES.load_img from MesmerizeCore.FileInput module and any stimulus map that the user may have specified.
mesfile_object – MES object, created from .mes file
img_reference – image reference to load, see
- classmethod from_pickle(pickle_file_path: str, tiff_path: Optional[str] = None)¶
Get pickled image data from a pickle file & image sequence from a npz or tiff. Used after motion correction & to view a sample from a project DataFrame. Create ImgData class object (See MesmerizeCore.DataTypes) and return instance of the work environment.
pickle_file_path: full path to the pickle containing image metadata, stim maps, and roi_states
tiff_path: str of the full path to a tiff file containing the image sequence
- classmethod from_tiff(path: str, method: str, meta_path: Optional[str] = None, axes_order: Optional[str] = None, meta_format: Optional[str] = None)¶
Return instance of work environment with ImgData.seq set from the tiff file.
path – path to the tiff file
method – one of ‘imread’, ‘asarray’, or ‘asarray-multi’. Refers to usage of either tifffile.imread or tifffile.asarray. ‘asarray-multi’ will load multi-page tiff files.
meta_path – path to a file containing meta data
meta_format – meta data format, must correspond to the name of a function in viewer.core.organize_meta
axes_order – Axes order as a 3 or 4 letter string for 2D or 3D data respectively. Axes order is assumed to be “txy” or “tzxy” if not specified.
Return True if the work environment is empty
- static load_mesfile(path: str) → mesmerize.viewer.core.mesfile.MES¶
Just passes the path of a .mes file to the constructor of class MES in MesmerizeCore.FileInput. Loads .mes file & constructs MES obj from which individual images & their respective metadata can be loaded to construct viewer work environments using the classmethod viewerWorkEnv.from_mesfile.
path – full path to a single .mes file.
reference to the back-end ROI Manager that is currently in use
SampleID, if opened from a project Sample
- to_pandas(proj_path: str, modify_options: Optional[dict] = None) → list¶
Used for saving the work environment as a project Sample.
proj_path – Root path of the current project
list of dicts that each correspond to a single curve that can be appended as rows to the project dataframe
- to_pickle(dir_path: str, filename: Optional[str] = None, save_img_seq=True, UUID=None) → str¶
Package the current work Env ImgData class object (See MesmerizeCore.DataTypes) and any paramteres such as for motion correction and package them into a pickle & image seq array. Used for batch motion correction and for saving current sample to the project. Image sequence is saved as a tiff and other information about the image is saved in a pickle.
- class mesmerize.viewer.core.data_types.ImgData(seq: Optional[numpy.ndarray] = None, meta: Optional[dict] = None)¶
Object that stores the image sequence and meta data from the imaging source
The Viewer is usually not interacted with directly from modules outside of the viewer (such as viewer modules. They instead use the ViewerUtils class which includes helper functions and a reference to the viewer.
- class mesmerize.viewer.core.ViewerUtils(viewer_reference: <module 'mesmerize.pyqtgraphCore.imageview.ImageView' from '/home/docs/checkouts/readthedocs.org/user_builds/mesmerize/envs/master/lib/python3.7/site-packages/mesmerize-0.6.0-py3.7.egg/mesmerize/pyqtgraphCore/imageview/ImageView.py'>)¶
Some utility functions for interfacing viewer.core.ViewerWorkEnv with the pyqtgraphCore.ImageView widget
- __init__(viewer_reference: <module 'mesmerize.pyqtgraphCore.imageview.ImageView' from '/home/docs/checkouts/readthedocs.org/user_builds/mesmerize/envs/master/lib/python3.7/site-packages/mesmerize-0.6.0-py3.7.egg/mesmerize/pyqtgraphCore/imageview/ImageView.py'>)¶
Cleanup of the ViewerWorkEnv and ImageView widget
Ask the user if they want to discard their work environment. If Yes, calls _clear_workEnv()
Set the status bar message in the viewer window.
msg – text to display in the status bar
Update the ImageView widget with the ViewerWorkEnv
reference to the pyqtgraph ImageView widget instance (viewer)
- class mesmerize.viewer.core.mesfile.MES(filename: str)¶
Handles of opening .mes files and organizing the images and meta data. The load_img() method returns a 3D array (dims are [time, cols, rows]) of the image sequence and its associated meta data.
Usage: Create a MES instance by passing the path of your mes file, example:
mesfile = MES(‘/path/to/mesfile/experiment_Feb_31.mes’)
Call the get_image_references() method to get a list of references for images that can be loaded.
To load an image that is available in the instance, just pass one of the references from get_image_references() to the load_img method:
img_array, meta_dict = mesfile.load_img(‘IF0001_0001’)
list of weak references to the object (if defined)
- load_img(img_reference: str) -> (<class 'numpy.ndarray'>, <class 'dict'>)¶
img_reference – The image reference, usually something like IFxxxx_xxxx or Ifxxxx_xxxx
(image sequence array, meta data dict)