Exemplo n.º 1
0
Arquivo: gui.py Projeto: aestrivex/cvu
    def _load_adjmat_check(self):
        acw=self.adjmat_chooser_window
        if not acw.finished: return

        import preprocessing as pp
        adj_struct = pp.process_adj(acw.ctl,self)
        if adj_struct is None: return #preprocessing returned an error 
    
        adj,soft_max_edges,adj_filename = adj_struct
        acw.ctl.ds_ref._load_adj(adj, soft_max_edges, acw.ctl.require_ls,
            acw.ctl.suppress_extra_rois)
        self.controller.update_display_metadata(acw.ctl.ds_ref.name,
            adj_filename=adj_filename)
Exemplo n.º 2
0
    def _load_adjmat_check(self):
        acw = self.adjmat_chooser_window
        if not acw.finished: return

        import preprocessing as pp
        adj_struct = pp.process_adj(acw.ctl, self)
        if adj_struct is None: return  #preprocessing returned an error

        adj, soft_max_edges, adj_filename = adj_struct
        acw.ctl.ds_ref._load_adj(adj, soft_max_edges, acw.ctl.require_ls,
                                 acw.ctl.suppress_extra_rois)
        self.controller.update_display_metadata(acw.ctl.ds_ref.name,
                                                adj_filename=adj_filename)
Exemplo n.º 3
0
def load_adj(matrix, dataset, ordering=None, ignore_deletes=False, max_edges=0, 
        field_name=None, required_rois=[], suppress_extra_rois=False):
    """
    Loads a matrix. This function is a scripting helper. In other words,
    instead of clicking on the GUI or simulating button presses, this
    function is provided for scripting purposes to just simulate the
    process of loading a matrix into a dataset.

    Parameters
    ----------

    matrix : str | instance(np.ndarray)
        Filename of an adjacency matrix in a supported format (numpy, matlab,
        or plaintext). Can also be a numpy matrix.
    dataset : instance(cvu.dataset.Dataset)
        The dataset into which to place this adjacency matrix
    ordering : None | str | list(str)
        Filename of an ordering file describing the matrix order. Default
        value is None. If None, matrix is assumed to be in parcellation order.
        Can just be a list of label names.
    ignore_deletes : bool
        If True, 'delete' entries in the ordering file are ignored.
        Default value is False.
    max_edges : int
        Default 0. Leave as default or see wiki documentation.
    field_name : None | str
        Needed to tell the field name of a matlab matrix. Required for
        matlab matrices, otherwise ignored
    required_rois : list(str)
        A list of ROIs whose labels must be shown in the circle plot.
        The default value is the empty list, signifying no restrictions.
    suppress_extra_rois : bool
        If true, only the ROIs in required_rois are shown on the circle
        plot.
    """


#    '''
#Loads a matrix. This function is meant to be a scripting helper. In
#other words, instead of clicking on the GUI buttons (or simulating button 
#presses) one could provide the requisite files for this operation inside a 
#script by just calling this function).
#
#Arguments:
#    matrix,         Filename of an adjacency matrix in a supported format 
#                    (numpy, matlab, plaintext). Can also just be a numpy
#                    matrix.
#    dataset,        A reference to the dataset that should contain this
#    ordering,       Filename of an ordering file. Defaults to None. If None,
#                    the matrix is assumed to be in parcellation order. Can also
#                    simply be a list of ROIs.
#    ignore_deletes  If true, 'delete' entries in the ordering file are
#                    ignored. Defaults to false.
#    max_edges       A number. Defaults to 0. If in doubt see wiki documentation.
#    field_name      Only needed for matlab .mat files. Specifies the field name
#                    of the matrix. 
#    required_rois   A list of ROIs that must be included in the circle plot.
#                    Defaults to the empty list.
#    suppress_extra_rois     If true, only the ROIs in required_rois are shown
#                    on the circle plot.
#
#Returns:
#    None
#    '''

    gui = globals()['self']     #explicitly allow dynamic scope
    err_handler = ErrorHandler(quiet=True)

    from preprocessing import process_adj
    from options_struct import AdjmatChooserParameters
    from dataset import Dataset

    if not isinstance(dataset, Dataset):
        print "must supply a valid dataset!"
        return

    adjmat_params = AdjmatChooserParameters(adjmat = matrix,
        adjmat_order = ordering, ignore_deletes = ignore_deletes,
        max_edges=max_edges, field_name=field_name, require_ls=required_rois,
        suppress_extra_rois=suppress_extra_rois, ds_ref = dataset)

    adj_struct = process_adj(adjmat_params, err_handler)
    if adj_struct is None:      #preprocessing errored out
        return
    adj, soft_max_edges, _ = adj_struct 
    dataset._load_adj(adj, soft_max_edges, required_rois, suppress_extra_rois)
    gui.controller.update_display_metadata(dataset.name,
        adj_filename=matrix if isinstance(matrix,str) else 'custom')