Example #1
0
	def calculate_modules(self,thres):
		import bct
		thres_adj=self.adj.copy()
		thres_adj[thres_adj < thres] = 0
		self.verbose_msg('Threshold for modularity calculation: %s'%str(thres))
		modvec,_=bct.modularity_und(thres_adj)
		self.modules = bct.ci2ls(modvec)
		self.nr_modules = len(self.modules)
Example #2
0
 def calculate_modules(self, thres):
     import graph, bct
     thres_adj = self.adj.copy()
     thres_adj[thres_adj < thres] = 0
     self.verbose_msg('Threshold for modularity calculation: %s' %
                      str(thres))
     modvec = graph.calculate_modules(thres_adj)
     self.modules = bct.ci2ls(modvec)
     self.nr_modules = len(self.modules)
Example #3
0
    def load_modules_or_scalars(self, params):
        if not params.mat:
            self.error_dialog('You must specify a valid matrix file')
            return
        if params.whichkind == 'scalars' and not params.measure_name:
            self.error_dialog('Cannot leave scalar name blank.  cvu uses '
                              'this value as a dictionary index')
            return

        import preprocessing
        try:
            ci = preprocessing.loadmat(params.mat,
                                       field=params.field_name,
                                       is_adjmat=False)
        except (CVUError, IOError) as e:
            self.error_dialog(str(e))
            return

        if params.mat_order:
            try:
                init_ord, bads = preprocessing.read_ordering_file(
                    params.mat_order)
            except (IndexError, UnicodeDecodeError) as e:
                self.error_dialog(str(e))
                return

            #delete the bads
            if not params.ignore_deletes:
                ci = np.delete(ci, bads)

            #perform the swapping
            try:
                ci_ord = preprocessing.adj_sort(init_ord, self.labnam)
            except CVUError as e:
                self.error_dialog(str(e))
                return
            except KeyError as e:
                self.error_dialog('Field not found: %s' % str(e))
                return
            ci = ci[ci_ord]

        try:
            ci = np.reshape(ci, (self.nr_labels, ))
        except ValueError as e:
            self.error_dialog('The %s file is of size %i after deletions, but '
                              'the dataset has %i regions' %
                              (params.whichkind, len(ci), self.nr_labels))
            return

        if params.whichkind == 'modules':
            import bct
            self.modules = bct.ci2ls(ci)
            self.nr_modules = len(self.modules)
        elif params.whichkind == 'scalars':
            self.save_scalar(params.measure_name, ci)
            params._increment_scalar_count()
Example #4
0
    def load_modules_or_scalars(self,params):
        if not params.mat:
            self.error_dialog('You must specify a valid matrix file'); return
        if params.whichkind=='scalars' and not params.measure_name:
            self.error_dialog('Cannot leave scalar name blank.  cvu uses '
                'this value as a dictionary index'); return

        import preprocessing
        try:
            ci=preprocessing.loadmat(params.mat, field=params.field_name, 
                is_adjmat=False)
        except (CVUError,IOError) as e: self.error_dialog(str(e)); return

        if params.mat_order:
            try:
                init_ord, bads = preprocessing.read_ordering_file(
                    params.mat_order)	
            except (IndexError,UnicodeDecodeError) as e:
                self.error_dialog(str(e)); return

            #delete the bads
            if not params.ignore_deletes:
                ci=np.delete(ci,bads)

            #perform the swapping
            try:
                ci_ord = preprocessing.adj_sort(init_ord, self.labnam)	
            except CVUError as e: self.error_dialog(str(e)); return
            except KeyError as e:
                self.error_dialog('Field not found: %s'%str(e)); return
            ci=ci[ci_ord]

        try:
            ci=np.reshape(ci,(self.nr_labels,))
        except ValueError as e:
            self.error_dialog('The %s file is of size %i after deletions, but '
                'the dataset has %i regions' %
                (params.whichkind, len(ci), self.nr_labels)); return

        if params.whichkind=='modules':	
            import bct
            self.modules=bct.ci2ls(ci)
            self.nr_modules=len(self.modules)
        elif params.whichkind=='scalars':
            self.save_scalar(params.measure_name,ci)
            params._increment_scalar_count()