def _dpmm(coords, alpha, null_density, dof, prior_precision, prior_h0, subjects, sampling_coords=None, n_iter=1000, burnin=100, co_clust=False): """Apply the dpmm analysis to compute clusters from regions coordinates """ from nipy.algorithms.clustering.imm import MixedIMM dim = coords.shape[1] migmm = MixedIMM(alpha, dim) migmm.set_priors(coords) migmm.set_constant_densities( null_dens=null_density, prior_dens=null_density) migmm._prior_dof = dof migmm._prior_scale = np.diag(prior_precision[0] / dof) migmm._inv_prior_scale_ = [np.diag(dof * 1. / (prior_precision[0]))] migmm.sample(coords, null_class_proba=prior_h0, niter=burnin, init=False, kfold=subjects) # sampling like, pproba, co_clustering = migmm.sample( coords, null_class_proba=prior_h0, niter=n_iter, kfold=subjects, sampling_points=sampling_coords, co_clustering=True) if co_clust: return like, 1 - pproba, co_clustering else: return like, 1 - pproba
def _dpmm(coords, alpha, null_density, dof, prior_precision, prior_h0, subjects, sampling_coords=None, n_iter=1000, burnin=100, co_clust=False): """Apply the dpmm analysis to compute clusters from regions coordinates """ from nipy.algorithms.clustering.imm import MixedIMM dim = coords.shape[1] migmm = MixedIMM(alpha, dim) migmm.set_priors(coords) migmm.set_constant_densities(null_dens=null_density, prior_dens=null_density) migmm._prior_dof = dof migmm._prior_scale = np.diag(prior_precision[0] / dof) migmm._inv_prior_scale_ = [np.diag(dof * 1. / (prior_precision[0]))] migmm.sample(coords, null_class_proba=prior_h0, niter=burnin, init=False, kfold=subjects) # sampling like, pproba, co_clustering = migmm.sample(coords, null_class_proba=prior_h0, niter=n_iter, kfold=subjects, sampling_points=sampling_coords, co_clustering=True) if co_clust: return like, 1 - pproba, co_clustering else: return like, 1 - pproba
def dpmm(gfc, alpha, g0, g1, dof, prior_precision, gf1, sub, burnin, spatial_coords=None, nis=1000, co_clust=False, verbose=False): """Apply the dpmm analysis to compute clusters from regions coordinates """ from nipy.algorithms.clustering.imm import MixedIMM dim = gfc.shape[1] migmm = MixedIMM(alpha, dim) migmm.set_priors(gfc) migmm.set_constant_densities(null_dens=g0, prior_dens=g1) migmm._prior_dof = dof migmm._prior_scale = np.diag(prior_precision[0] / dof) migmm._inv_prior_scale_ = [np.diag(dof * 1. / (prior_precision[0]))] migmm.sample(gfc, null_class_proba=1 - gf1, niter=burnin, init=False, kfold=sub) if verbose: print 'number of components: ', migmm.k # sampling if co_clust: like, pproba, co_clust = migmm.sample( gfc, null_class_proba=1 - gf1, niter=nis, sampling_points=spatial_coords, kfold=sub, co_clustering=co_clust) if verbose: print 'number of components: ', migmm.k return like, 1 - pproba, co_clust else: like, pproba = migmm.sample( gfc, null_class_proba=1 - gf1, niter=nis, sampling_points=spatial_coords, kfold=sub, co_clustering=co_clust) if verbose: print 'number of components: ', migmm.k return like, 1 - pproba
def dpmm(gfc, alpha, g0, g1, dof, prior_precision, gf1, sub, burnin, spatial_coords=None, nis=1000, co_clust=False, verbose=False): """Apply the dpmm analysis to compute clusters from regions coordinates """ from nipy.algorithms.clustering.imm import MixedIMM dim = gfc.shape[1] migmm = MixedIMM(alpha, dim) migmm.set_priors(gfc) migmm.set_constant_densities(null_dens=g0, prior_dens=g1) migmm._prior_dof = dof migmm._prior_scale = np.diag(prior_precision[0] / dof) migmm._inv_prior_scale_ = [np.diag(dof * 1. / (prior_precision[0]))] migmm.sample(gfc, null_class_proba=1 - gf1, niter=burnin, init=False, kfold=sub) if verbose: print 'number of components: ', migmm.k # sampling if co_clust: like, pproba, co_clust = migmm.sample(gfc, null_class_proba=1 - gf1, niter=nis, sampling_points=spatial_coords, kfold=sub, co_clustering=co_clust) if verbose: print 'number of components: ', migmm.k return like, 1 - pproba, co_clust else: like, pproba = migmm.sample(gfc, null_class_proba=1 - gf1, niter=nis, sampling_points=spatial_coords, kfold=sub, co_clustering=co_clust) if verbose: print 'number of components: ', migmm.k return like, 1 - pproba