예제 #1
0
        data = data.reshape(num_pixels, num_bins)
        if cluster_images:
            data = np.transpose(data)

        # Execute clustering
        centers, _ = kmeans(data,
                            current_num_clusters,
                            iter=current_num_repeat,
                            thresh=current_threshold)
        cluster, _ = vq(data, centers)

        # Fill the clusters
        if current_mask is not None:
            out_cluster = np.zeros(current_mask.shape, dtype='int')
            out_cluster[:] = -1
            out_cluster[current_mask] = cluster
            cluster = out_cluster
        else:
            # Reshape the clusters to the original shape
            if cluster_images:
                pass  # Nothing to be done
            else:
                cluster = cluster.reshape(indata_shape[:-1])

        return cluster, centers


if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_kmeans).main()
예제 #2
0
파일: omsi_rpca.py 프로젝트: wholtz/BASTet
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_rpca class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_rpca,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_rpca class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_rpca).main()
예제 #3
0
파일: omsi_cx.py 프로젝트: wholtz/BASTet
            custom_options = ['Informative Images']
        else:
            custom_options = ['Pixel Leverage Scores', 'Pixel Rank']

        dependent_options = super(omsi_cx,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_cx).main()
"""Test script:

from omsi.dataformat.omsi_file import *
from omsi.analysis.multivariate_stats.omsi_cx import *
inputFile = 'test_cx.h5'
f = omsi_file( inputFile , 'a' )
e = f.get_experiment(0)
a = e.get_analysis(0)
d = a['peak_cube']
ocxi = omsi_cx(nameKey='testCX_Images')
ocxi.execute( msidata=d , rank=10, objectiveDim=omsi_cx.dimension_index['imageDim'] )
ocxp = omsi_cx(nameKey='testCX_Pixel')
ocxp.execute( msidata=d , rank=10, objectiveDim=omsi_cx.dimension_index['pixelDim'] )
e.create_analysis( ocxi , flushIO=True)
e.create_analysis( ocxp , flushIO=True)
예제 #4
0
        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
            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).
        """
        custom_options = ['Tic Norm']
        dependent_options = super(omsi_tic_norm, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_tic_norm).main()








예제 #5
0
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_findpeaks_cwt class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_findpeaks_cwt,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_findpeaks_cwt class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_findpeaks_cwt).main()
예제 #6
0
파일: omsi_nmf.py 프로젝트: biorack/BASTet
                                     current_num_iter)

        # Reshape the ho matrix to be a 3D image cube
        ho_matrix = ho_matrix.transpose()
        if current_mask is not None:
            out_ho = np.zeros(output_shape, dtype=ho_matrix.dtype)
            out_ho[current_mask, :] = ho_matrix
            ho_matrix = out_ho
        else:
            ho_matrix = ho_matrix.reshape(output_shape)

        return wo_matrix, ho_matrix

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_nmf).main()


# def main(argv=None):
#     """Then main function"""
#
#     import sys
#     from sys import argv, exit
#     import matplotlib.pyplot as plt
#     import matplotlib.gridspec as gridspec
#     from math import log
#     from omsi.dataformat.omsi_file import  omsi_file
#
#     if argv is None:
#         argv = sys.argv
#
예제 #7
0
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_mz_upsample class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_mz_upsample,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_mz_upsample class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_mz_upsample).main()
예제 #8
0
"""
Simple helper tool to run an analysis. This is essentially just a short-cut
to the omsi/workflow/analysis_driver/omsi_cl_diver module
"""
from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver

if __name__ == "__main__":

    # Create a command-line driver and call main to run the analysis
    cl_analysis_driver(analysis_class=None, add_analysis_class_arg=True, add_output_arg=True, add_log_level_arg=True).main()
예제 #9
0
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the analysis_template class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(analysis_template,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the analysis_template class name with your class name
    """
    cl_analysis_driver(analysis_class=analysis_template).main()
예제 #10
0
            print time_str
            sys.stdout.flush()

            # Initialize the hit_table if necessary
            if hit_table is None:
                # If our compound database does not contain any related compounds then just finish
                if current_hits.shape[0] == 0:
                    # Initialize the results as empty and finish as there is nothing to do
                    hit_table = np.zeros(shape=(pixel_index.shape[0], 0),
                                         dtype=MIDAS.scoring_C.HIT_TABLE_DTYPE)  # FIXME the number of hits may be different for different spectra if we have varying precursor m/z
                    continue
                # If our compound database contains at least one relevant compound then check all spectra
                else:
                    # Create the data structure to store all results
                    hit_table = np.zeros(shape=(pixel_index.shape[0], current_hits.shape[0]),
                                         dtype=current_hits.dtype)  # FIXME the number of hits may be different for different spectra if we have varying precursor m/z
            # Save the hits for the current pixel
            hit_table[current_index] = current_hits

        if hit_table is None:
            hit_table = np.zeros(shape=(pixel_index.shape[0], 0),
                                 dtype=MIDAS.scoring_C.HIT_TABLE_DTYPE)

        # Return the hit_table and the index of the pixel each hit_table applies to
        return hit_table, pixel_index

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_score_midas).main()

예제 #11
0
                                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.

        :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 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).
        """
        custom_options = ['Rebinned Images']
        dependent_options = super(omsi_mz_rebin, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_mz_rebin).main()


예제 #12
0
        data = data.reshape(num_pixels, num_bins)
        if cluster_images:
            data = np.transpose(data)

        # Execute clustering
        centers, _ = kmeans(data,
                            current_num_clusters,
                            iter=current_num_repeat,
                            thresh=current_threshold)
        cluster, _ = vq(data, centers)

        # Fill the clusters
        if current_mask is not None:
            out_cluster = np.zeros(current_mask.shape, dtype='int')
            out_cluster[:] = -1
            out_cluster[current_mask] = cluster
            cluster = out_cluster
        else:
            # Reshape the clusters to the original shape
            if cluster_images:
                pass  # Nothing to be done
            else:
                cluster = cluster.reshape(indata_shape[:-1])

        return cluster, centers


if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_kmeans).main()
예제 #13
0
            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).
        """

        """
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []

        """
        EDIT_ME

        Change the omsi_mask_by_cluster class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_mask_by_cluster, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_mask_by_cluster).main()
예제 #14
0
            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).
        """

        """
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []

        """
        EDIT_ME

        Change the omsi_filter_by_mask class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_filter_by_mask, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_filter_by_mask).main()
예제 #15
0
        # We here convert the single scalars to 1D numpy arrays to ensure consistency. The data write function can
        # handle also a large range of python built_in types by converting them to numpy for storage in HDF5 but
        # to ensure a consistent behavior we convert the values directly here

        # Clean up the biggest chunks of memory we allocated when we potentially loaded the data from file
        del data
        del processed_msidata
        del flat_data

        # Save the analysis data to the __data_list so that the data can be
        # saved automatically by the omsi HDF5 file API
        return peak_cube, mz_peaks

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_findpeaks_global).main()


# def main(argv=None):
#     """Then main function"""
#
#     import sys
#     from omsi.dataformat.omsi_file.main_file import omsi_file
#     import matplotlib.pyplot as plt
#     import matplotlib.gridspec as gridspec
#     import numpy as np
#
#     if argv is None:
#         argv = sys.argv
#
#     # Check for correct usage
예제 #16
0
                        pactolus_results=hit_matrix[current_index],
                        table_file=file_lookup_table,
                        original_db=metabolite_database))
                    for score_index in non_zero_scores:
                        pixel_index.append(fpl_peak_arrayindex[spectrum_index, 0:2])
                        score.append(current_hit_table['score'][score_index])
                        id_data.append(current_hit_table['id'][score_index])
                        name.append(current_hit_table['name'][score_index])
                        mass.append(current_hit_table['mass'][score_index])
                        n_peaks.append(current_hit_table['n_peaks'][score_index])
                        n_match.append(current_hit_table['n_match'][score_index])
        else:
            pixel_index = fpl_peak_arrayindex[spectrum_indexes, 0:2]
            score = np.asarray(hit_matrix)

        # Return the hit_table and the index of the pixel each hit_table applies to
        print "rank : " + str(mpi_helper.get_rank()) + " : scores " + str(score)
        sys.stdout.flush()
        return np.asarray(pixel_index), \
               np.asarray(score), \
               np.asarray(id_data), \
               np.asarray(name), \
               np.asarray(mass), \
               np.asarray(n_peaks), \
               np.asarray(n_match)

if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_score_pactolus).main()

예제 #17
0
        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []

        """
        EDIT_ME

        Change the omsi_xy_resize class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_xy_resize, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_xy_resize class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_xy_resize).main()


예제 #18
0
                        pixel_index.append(fpl_peak_arrayindex[spectrum_index,
                                                               0:2])
                        score.append(current_hit_table['score'][score_index])
                        id_data.append(current_hit_table['id'][score_index])
                        name.append(current_hit_table['name'][score_index])
                        mass.append(current_hit_table['mass'][score_index])
                        n_peaks.append(
                            current_hit_table['n_peaks'][score_index])
                        n_match.append(
                            current_hit_table['n_match'][score_index])
        else:
            pixel_index = fpl_peak_arrayindex[spectrum_indexes, 0:2]
            score = np.asarray(hit_matrix)

        # Return the hit_table and the index of the pixel each hit_table applies to
        print "rank : " + str(
            mpi_helper.get_rank()) + " : scores " + str(score)
        sys.stdout.flush()
        return np.asarray(pixel_index), \
               np.asarray(score), \
               np.asarray(id_data), \
               np.asarray(name), \
               np.asarray(mass), \
               np.asarray(n_peaks), \
               np.asarray(n_match)


if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_score_pactolus).main()
예제 #19
0
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_xy_smooth class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_xy_smooth,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_xy_smooth class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_xy_smooth).main()
예제 #20
0
        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []

        """
        EDIT_ME

        Change the omsi_mz_upsample class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_mz_upsample, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_mz_upsample class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_mz_upsample).main()


예제 #21
0
    @classmethod
    def v_qslice_viewer_options(cls, 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.

        :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 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).
        """
        custom_options = ['Rebinned Images']
        dependent_options = super(omsi_mz_rebin,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_mz_rebin).main()
예제 #22
0
"""
Simple helper tool to run an analysis. This is essentially just a short-cut
to the omsi/workflow/analysis_driver/omsi_cl_diver module
"""
from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver

if __name__ == "__main__":

    # Create a command-line driver and call main to run the analysis
    cl_analysis_driver(analysis_class=None,
                       add_analysis_class_arg=True,
                       add_output_arg=True,
                       add_log_level_arg=True).main()
예제 #23
0
파일: omsi_rpca.py 프로젝트: biorack/BASTet
        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []

        """
        EDIT_ME

        Change the omsi_rpca class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_rpca, cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


############################################################
#  3) Making your analysis self-sufficient   (Recommended) #
############################################################
if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    """
    EDIT_ME

    Simply replace the omsi_rpca class name with your class name
    """
    cl_analysis_driver(analysis_class=omsi_rpca).main()


예제 #24
0
            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).
        """
        """
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_filter_by_mask class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_filter_by_mask,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_filter_by_mask).main()
예제 #25
0
            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).
        """
        """
        EDIT_ME

        Define a list of custom viewer_options are supported. E.g:

        custom_options = ['Peak cube']
        """
        custom_options = []
        """
        EDIT_ME

        Change the omsi_mask_by_cluster class-name to your class.  If you did
        a replace all, then this should be done already.
        """
        dependent_options = super(omsi_mask_by_cluster,
                                  cls).v_qslice_viewer_options(analysis_object)
        slice_viewer_options = custom_options + dependent_options
        return slice_viewer_options


if __name__ == "__main__":
    from omsi.workflow.driver.cl_analysis_driver import cl_analysis_driver
    cl_analysis_driver(analysis_class=omsi_mask_by_cluster).main()