msi_filtering Package

msi_filtering Package

Module with third-party modules, functions, classes used by some of the analysis modules in the containing package.

class omsi.analysis.msi_filtering.omsi_tic_norm(name_key='undefined')

Bases: omsi.analysis.base.analysis_base

TIC Normalization analysis.

Initalize the basic data members

execute_analysis()

Normalize the data based on the total intensity of a spectrum or the intensities of a select set of ions.

Calculations are performed using a memory map approach to avoid loading all data into memory. TIC normalization can as such be performed even on large files (assuming sufficient disk space).

Keyword Arguments:

Parameters:
  • msidata (h5py.dataset or numpu array (3D)) – The input MSI dataset
  • mzdata – The mz axsis do the dataset
  • maxCount

    ...

  • mzTol

    ...

  • infIons – List of informative ions
record_execute_analysis_outputs(analysis_output)

We are not returning any outputs here, but we are going to record them manually. :param analysis_output: The output of the execute_analysis(...) function.

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 multiple 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 elements are expected to be returned by this function :

  1. 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/
  2. 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 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.

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).

omsi_tic_norm Module

Module with the TIC normalization analysis.

class omsi.analysis.msi_filtering.omsi_tic_norm.omsi_tic_norm(name_key='undefined')

Bases: omsi.analysis.base.analysis_base

TIC Normalization analysis.

Initalize the basic data members

execute_analysis()

Normalize the data based on the total intensity of a spectrum or the intensities of a select set of ions.

Calculations are performed using a memory map approach to avoid loading all data into memory. TIC normalization can as such be performed even on large files (assuming sufficient disk space).

Keyword Arguments:

Parameters:
  • msidata (h5py.dataset or numpu array (3D)) – The input MSI dataset
  • mzdata – The mz axsis do the dataset
  • maxCount

    ...

  • mzTol

    ...

  • infIons – List of informative ions
record_execute_analysis_outputs(analysis_output)

We are not returning any outputs here, but we are going to record them manually. :param analysis_output: The output of the execute_analysis(...) function.

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 multiple 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 elements are expected to be returned by this function :

  1. 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/
  2. 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 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.

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).

msi_filtering.third_party Package

msi_filtering.third_party Package

Package containing shared third-party code modules included here to reduce the need for external dependencies when only small parts of external code are used.

msi_filtering.experimental Package

msi_filtering.experimental Package

Module with experimental analysis code, i.e., code that is not (yet) used in production but is under development. Often this is code that is used in a specific research.

omsi_filter_by_mask Module

Module for performing masking for MSI data.

class omsi.analysis.msi_filtering.experimental.omsi_filter_by_mask.omsi_filter_by_mask(name_key='undefined')

Bases: omsi.analysis.base.analysis_base

Class defining a basic mask creation a 2D MSI data file or slice of the data

Initalize the basic data members

execute_analysis()
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 :

  1. 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.
  2. 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).

omsi_mask_by_cluster Module

Module for performing making a mask from cluster matrix for MSI data.

class omsi.analysis.msi_filtering.experimental.omsi_mask_by_cluster.omsi_mask_by_cluster(name_key='undefined')

Bases: omsi.analysis.base.analysis_base

Class defining a basic mask creation a 2D MSI data file or slice of the data

Initalize the basic data members

execute_analysis()
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 :

  1. 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.
  2. 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).