code: def test_parcel_feature():
      """Simply test parcellation feature interface"""
      # prepare some data
      shape = (5, 5, 5)
      nb_parcel = 10
      data = np.random.randn(np.prod(shape), 1)
      domain = grid_domain_from_binary_array(np.ones(shape))
      g = field_from_coo_matrix_and_data(domain.topology, data)
      u, J0 = g.ward(nb_parcel)
  
      # instantiate a parcellation
      msp = MultiSubjectParcellation(domain, u, u)
      msp.make_feature("data", data)
      assert msp.get_feature("data").shape == (nb_parcel, 1)
  
      # test with a copy
      msp2 = msp.copy()
      assert (
          msp2.get_feature("data") == msp2.get_feature("data")
      ).all()
  
      # test a multi_dimensional feature
      dim = 4
      msp.make_feature("new", np.random.randn(np.prod(shape), 1, dim))
      assert msp.get_feature("new").shape == (nb_parcel, 1, dim)
  
file_path: nipy/nipy/labs/spatial_models/tests/test_parcel.py
imports: import numpy
  from nipy.algorithms.graph.field import field_from_coo_matrix_and_data
  from ...utils.simul_multisubject_fmri_dataset import surrogate_2d_dataset
  from ..discrete_domain import grid_domain_from_binary_array
  from ..hierarchical_parcellation import hparcel
  from ..parcellation import MultiSubjectParcellation
label_desc: Use image node_id 3 for calling a global function with example usage: test_parcel_feature() without return types