code: def applymask(vol, mask):
      """Mask vol with mask.
  
      Parameters
      ----------
      vol : ndarray
          Array with $V$ dimensions
      mask : ndarray
          Binary mask.  Has $M$ dimensions where $M <= V$. When $M < V$, we
          append $V - M$ dimensions with axis length 1 to `mask` so that `mask`
          will broadcast against `vol`.  In the typical case `vol` can be 4D,
          `mask` can be 3D, and we append a 1 to the mask shape which (via numpy
          broadcasting) has the effect of applying the 3D mask to each 3D slice in
          `vol` (``vol[..., 0]`` to ``vol[..., -1``).
  
      Returns
      -------
      masked_vol : ndarray
          `vol` multiplied by `mask` where `mask` may have been extended to match
          extra dimensions in `vol`
      """
      mask = mask.reshape(mask.shape + (vol.ndim - mask.ndim) * (1,))
      return vol * mask
  
file_path: dipy/dipy/segment/mask.py
imports: from warnings import warn
  import numpy
  from dipy.reconst.dti import fractional_anisotropy, color_fa
  from scipy.ndimage import median_filter
  from scipy.ndimage import binary_dilation, generate_binary_structure
label_desc: Use image node_id 2 for calling a global function with example usage: applymask(vol, mask) and returns: unknown