Did I find the right examples for you? yes no

All Samples(7)  |  Call(5)  |  Derive(0)  |  Import(2)

src/n/i/nipy-0.3.0/nipy/labs/spatial_models/parcel_io.py   nipy(Download)
 
from nipy.algorithms.clustering.utils import kmeans
from .discrete_domain import grid_domain_from_image
from .mroi import SubDomains
from ..mask import intersect_masks
                           load(mask_images[0]).get_affine())
 
    domain = grid_domain_from_image(mask)
    cent, labels, J = kmeans(domain.coord, nb_parcel)
    sub_dom = SubDomains(domain, labels)
 
    # build the domain
    domain = grid_domain_from_image(mask, nn=6)
    #nn = 6 for speed up and stability
 
    # step 1: load the data ----------------------------
    # 1.1 the domain
    domain = grid_domain_from_image(mask_image, nn)
 
    if method is not 'kmeans':

src/n/i/nipy-0.3.0/nipy/labs/spatial_models/tests/test_discrete_domain.py   nipy(Download)
import numpy as np
from numpy.testing import assert_almost_equal, assert_equal
from ..discrete_domain import smatrix_from_nd_idx, smatrix_from_3d_array, \
    smatrix_from_nd_array, domain_from_binary_array, domain_from_image, \
    domain_from_mesh, grid_domain_from_binary_array, grid_domain_from_image, \
    mim = Nifti1Image(mask.astype('u8'), affine)
    nim = Nifti1Image(noise, affine)
    ddom = grid_domain_from_image(mim)
    ddom.make_feature_from_image(nim, 'noise')
    assert_almost_equal(ddom.features['noise'], noise[mask])
    affine[3:, 0:3] = 0
    nim = Nifti1Image(toto, affine)
    ddom = grid_domain_from_image(nim)
    ref = np.sum(toto) * np.absolute(np.linalg.det(affine[:3, 0:3]))
    assert_almost_equal(np.sum(ddom.local_volume), ref)