code: def perm_prfx(
      domain,
      graphs,
      features,
      nb_parcel,
      ldata,
      initial_mask=None,
      nb_perm=100,
      niter=5,
      dmax=10.0,
      lamb=100.0,
      chunksize=1.0e5,
      verbose=1,
  ):
      """
      caveat: assumes that the functional dimension is 1
      """
      from ..utils.reproducibility_measures import ttest
  
      # permutations for the assessment of the results
      prfx0 = []
      adim = domain.coord.shape[1]
      nb_subj = len(ldata)
      for q in range(nb_perm):
          feature = []
          sldata = []
          for s in range(nb_subj):
              lf = features[s].copy()
              swap = (rand() > 0.5) * 2 - 1
              lf[:, 0:-adim] = swap * lf[:, 0:-adim]
              sldata.append(swap * ldata[s])
              feature.append(lf)
  
          # optimization part
          all_labels, proto_anat = _optim_hparcel(
              feature,
              domain,
              graphs,
              nb_parcel,
              lamb,
              dmax,
              niter,
              initial_mask,
              chunksize=chunksize,
          )
          labels = -np.ones((domain.size, nb_subj)).astype(np.int_)
          for s in range(nb_subj):
              labels[initial_mask[:, s] > -1, s] = all_labels[s]
  
          # compute the group-level labels
          template_labels = voronoi(domain.coord, proto_anat)
  
          # create the parcellation
          pcl = MultiSubjectParcellation(
              domain,
              individual_labels=labels,
              template_labels=template_labels,
          )
          pdata = pcl.make_feature(
              "functional", np.rollaxis(np.array(ldata), 1, 0)
          )
          prfx = ttest(np.squeeze(pdata))
          if verbose:
              print(q, prfx.max(0))
          prfx0.append(prfx.max(0))
  
      return prfx0
  
file_path: nipy/nipy/labs/spatial_models/hierarchical_parcellation.py
imports: from warnings import warn
  import numpy
  from numpy.random import rand
  from nipy.algorithms.clustering.utils import kmeans, voronoi
  from nipy.algorithms.graph.field import Field
  from nipy.algorithms.graph.graph import wgraph_from_coo_matrix
  from .parcellation import MultiSubjectParcellation
label_desc: Use image node_id 10 for calling a global function with example usage: perm_prfx(domain, graphs, features, nb_parcel, ldata, initial_mask, nb_perm, niter, dmax, lamb, chunksize, verbose) and returns: prfx0