code: def parcel_analysis(
      con_imgs,
      parcel_img,
      msk_img=None,
      vcon_imgs=None,
      design_matrix=None,
      cvect=None,
      fwhm=8,
      smooth_method="default",
      res_path=None,
  ):
      """
      Helper function for Bayesian parcel-based analysis.
  
      Given a sequence of independent images registered to a common
      space (for instance, a set of contrast images from a first-level
      fMRI analysis), perform a second-level analysis assuming constant
      effects throughout parcels defined from a given label image in
      reference space. Specifically, a model of the following form is
      assumed:
  
      Y = X * beta + variability,
  
      where Y denotes the input image sequence, X is a design matrix,
      and beta are parcel-wise parameter vectors. The algorithm computes
      the Bayesian posterior probability of cvect'*beta, where cvect is
      a given contrast vector, in each parcel using an expectation
      propagation scheme.
  
      Parameters
      ----------
      con_imgs: sequence of nipy-like images
        Images input to the group analysis.
      parcel_img: nipy-like image
        Label image where each label codes for a parcel.
      msk_img: nipy-like image, optional
        Binary mask to restrict analysis. By default, analysis is
        carried out on all parcels with nonzero value.
      vcon_imgs: sequence of nipy-like images, optional
        First-level variance estimates corresponding to `con_imgs`. This
        is useful if the input images are "noisy". By default,
        first-level variances are assumed to be zero.
      design_matrix: array, optional
        If None, a one-sample analysis model is used. Otherwise, an
        array with shape (n, p) where `n` matches the number of input
        scans, and `p` is the number of regressors.
      cvect: array, optional
        Contrast vector of interest. The method makes an inference on
        the contrast defined as the dot product cvect'*beta, where beta
        are the unknown parcel-wise effects. If None, `cvect` is assumed
        to be np.array((1,)). However, the `cvect` argument is mandatory
        if `design_matrix` is provided.
      fwhm: float, optional
        A parameter that represents the localization uncertainty in
        reference space in terms of the full width at half maximum of an
        isotropic Gaussian kernel.
      smooth_method: str, optional
        One of 'default' and 'spm'. Setting `smooth_method=spm` results
        in simply smoothing the input images using a Gaussian kernel,
        while the default method involves more complex smoothing in
        order to propagate spatial uncertainty into the inference
        process.
      res_path: str, optional
        An existing path to write output images. If None, no output is
        written.
  
      Returns
      -------
      pmap_mu_img: nipy image
        Image of posterior contrast means for each parcel.
      pmap_prob_img: nipy image
        Corresponding image of posterior probabilities of positive
        contrast.
      """
      p = ParcelAnalysis(
          con_imgs,
          parcel_img,
          parcel_info=None,
          msk_img=msk_img,
          vcon_imgs=vcon_imgs,
          design_matrix=design_matrix,
          cvect=cvect,
          fwhm=fwhm,
          smooth_method=smooth_method,
          res_path=res_path,
      )
      return p.parcel_maps()
  
imports: import warnings
  from os.path import join
  import numpy
  import scipy.ndimage
  import scipy.stats
  from nibabel import io_orientation
  from ...None import save_image
  from ...core.image.image_spaces import make_xyz_image, xyz_affine
  from ..kernel_smooth import fwhm2sigma
  from ..registration import resample
  from ..statistics.bayesian_mixed_effects import two_level_glm
  from ..statistics.histogram import histogram
label_desc: Use image node_id 8 for calling a global function with example usage: parcel_analysis(con_imgs, parcel_img, msk_img, vcon_imgs, design_matrix, cvect, fwhm, smooth_method, res_path) and returns: p