templates Package¶
omsi.templates |
This package provides a collection of code templates to ease the development of additional components, e.g., analysis modules. |
omsi.templates.analysis_template |
Template intended to help with the development of new analysis modules. |
templates
Package¶
This package provides a collection of code templates to ease the development of additional components, e.g., analysis modules. As such, this package is NOT intended for direct usage but is rather just a library of code templates.
analysis_template
Module¶
Template intended to help with the development of new analysis modules.
-
class
omsi.templates.analysis_template.
analysis_template
(name_key='undefined')¶ Bases:
omsi.analysis.base.analysis_base
Template intended to help with the development of new analysis classes.
Search for EDIT_ME to find locations that need to be changed.
EDIT_ME Search for analysis_template and replace it with your classname throughout
EDIT_ME Replace this doc-string with your class documentation
Initalize the basic data members
-
execute_analysis
()¶ EDIT_ME Implement this function to implement the execution of the actual analysis.
This function may not require any input parameters. All input parameters are recoded in the parameters and dependencies lists and should be retrieved from there, e.g, using basic slicing self[ paramName ]
EDIT_ME Remove this comment and replace it with your own documentation. Describe what your analysis does and how a user can use it. Note, a user will call the function execute(...) which takes care of storing parameters, collecting execution data etc., so that you only need to implement your analysis, the rest is taken care of by analysis_base.
Keyword Arguments:
Parameters: mydata – ...
Returns: This function may return any developer-defined data. Note, all output that should be recorded must be put into the data list.
-
groups
= None¶ EDIT_ME
Add a list of names of input parameters for your analysis using the self.add_add_parameter.
For parameters that define n-dimension arrays you should specify the dtypes[‘ndarray’] as dtype. This will allow discovery of dependencies and proper function with the analysis drivers. Other available dtypes include standard built-ins, e.g, int, float etc. See self.get_default_dtypes() for details.
It is also recommended to organize parameters into groups using the default set of groups, e.g., groups[‘input’], groups[‘settings’], groups[‘stop’].
-
classmethod
v_qmz
(analysis_object, qslice_viewer_option=0, qspectrum_viewer_option=0)¶ Get the mz axes for the analysis
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- qslice_viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them for the qslice URL pattern.
- qspectrum_viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them for the qspectrum URL pattern.
Returns: The following four arrays are returned by the analysis:
- mz_spectra : Array with the static mz values for the spectra.
- label_spectra : Lable for the spectral mz axis
- mz_slice : Array of the static mz values for the slices or None if identical to the mz_spectra.
- label_slice : Lable for the slice mz axis or None if identical to label_spectra.
-
classmethod
v_qslice
(analysis_object, z, viewer_option=0)¶ Get 3D analysis dataset for which z-slices should be extracted for presentation in the OMSI viewer
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- z – Selection string indicting which z values should be selected.
- viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them.
Returns: numpy array with the data to be displayed in the image slice viewer. Slicing will be performed typically like [:,:,zmin:zmax].
-
classmethod
v_qslice_viewer_options
(analysis_object)¶ Get a list of strings describing the different default viewer options for the analysis for qslice. The default implementation tries to take care of handling the spectra retrieval for all the depencies but can naturally not decide how the qspectrum should be handled by a derived class. However, this implementation is often called at the end of custom implementations to also allow access to data from other dependencies.
Parameters: analysis_object – The omsi_file_analysis object for which slicing should be performed. For most cases this is not needed here as the support for slice operations is usually a static decision based on the class type, however, in some cases additional checks may be needed (e.g., ensure that the required data is available). Returns: List of strings indicating the different available viewer options. The list should be empty if the analysis does not support qslice requests (i.e., v_qslice(...) is not available).
-
classmethod
v_qspectrum
(analysis_object, x, y, viewer_option=0)¶ Get from which 3D analysis spectra in x/y should be extracted for presentation in the OMSI viewer
- Developer Note: h5py currently supports only a single index list. If the user provides an index-list for both
- x and y, then we need to construct the proper merged list and load the data manually, or if the data is small enough, one can load the full data into a numpy array which supports mulitple lists in the selection.
Parameters: - analysis_object – The omsi_file_analysis object for which slicing should be performed
- x – x selection string
- y – y selection string
- viewer_option – If multiple default viewer behaviors are available for a given analysis then this option is used to switch between them.
Returns: The following two elemnts are expected to be returned by this function :
- 1D, 2D or 3D numpy array of the requested spectra. NOTE: The mass (m/z) axis must be the last axis. For index selection x=1,y=1 a 1D array is usually expected. For indexList selections x=[0]&y=[1] usually a 2D array is expected. For ragne selections x=0:1&y=1:2 we one usually expects a 3D array.
- None in case that the spectra axis returned by v_qmz are valid for the returned spectrum. Otherwise, return a 1D numpy array with the m/z values for the spectrum (i.e., if custom m/z values are needed for interpretation of the returned spectrum).This may be needed, e.g., in cases where a per-spectrum peak analysis is performed and the peaks for each spectrum appear at different m/z values.
-
classmethod
v_qspectrum_viewer_options
(analysis_object)¶ Get a list of strings describing the different default viewer options for the analysis for qspectrum. The default implementation tries to take care of handling the spectra retrieval for all the dependencies but can naturally not decide how the qspectrum should be handled by a derived class. However, this implementation is often called at the end of custom implementations to also allow access to data from other dependencies.
param analysis_object: The omsi_file_analysis object for which slicing should be performed. For most cases this is not needed here as the support for slice operations is usually a static decission based on the class type, however, in some cases additional checks may be needed (e.g., ensure that the required data is available). returns: List of strings indicating the different available viewer options. The list should be empty if the analysis does not support qspectrum requests (i.e., v_qspectrum(...) is not available).
-