code: def response_from_mask_msmt(
      gtab, data, mask_wm, mask_gm, mask_csf, tol=20
  ):
      """Computation of multi-shell multi-tissue (msmt) response
          functions from given tissues masks.
  
      Parameters
      ----------
      gtab : GradientTable
      data : ndarray
          diffusion data
      mask_wm : ndarray
          mask from where to compute the WM response function.
      mask_gm : ndarray
          mask from where to compute the GM response function.
      mask_csf : ndarray
          mask from where to compute the CSF response function.
      tol : int
          tolerance gap for b-values clustering. (Default = 20)
  
      Returns
      -------
      response_wm : ndarray, (len(unique_bvals_tolerance(gtab.bvals))-1, 4)
          (`evals`, `S0`) for WM for each unique bvalues (except b0).
      response_gm : ndarray, (len(unique_bvals_tolerance(gtab.bvals))-1, 4)
          (`evals`, `S0`) for GM for each unique bvalues (except b0).
      response_csf : ndarray, (len(unique_bvals_tolerance(gtab.bvals))-1, 4)
          (`evals`, `S0`) for CSF for each unique bvalues (except b0).
  
      Notes
      -----
      In msmt-CSD there is an important pre-processing step: the estimation of
      every tissue's response function. In order to do this, we look for voxels
      corresponding to WM, GM and CSF. This information can be obtained by using
      mcsd.mask_for_response_msmt() through masks of selected voxels. The present
      function uses such masks to compute the msmt response functions.
  
      For the responses, we base our approach on the function
      csdeconv.response_from_mask_ssst(), with the added layers of multishell and
      multi-tissue (see the ssst function for more information about the
      computation of the ssst response function). This means that for each tissue
      we use the previously found masks and loop on them. For each mask, we loop
      on the b-values (clustered using the tolerance gap) to get many responses
      and then average them to get one response per tissue.
      """
  
      bvals = gtab.bvals
      bvecs = gtab.bvecs
      btens = gtab.btens
  
      list_bvals = unique_bvals_tolerance(bvals, tol)
  
      b0_indices = get_bval_indices(bvals, list_bvals[0], tol)
      b0_map = np.mean(data[..., b0_indices], axis=-1)[..., np.newaxis]
  
      masks = [mask_wm, mask_gm, mask_csf]
      tissue_responses = []
      for mask in masks:
          responses = []
          for bval in list_bvals[1:]:
              indices = get_bval_indices(bvals, bval, tol)
  
              bvecs_sub = np.concatenate(
                  [[bvecs[b0_indices[0]]], bvecs[indices]]
              )
              bvals_sub = np.concatenate([[0], bvals[indices]])
              if btens is not None:
                  btens_b0 = btens[b0_indices[0]].reshape((1, 3, 3))
                  btens_sub = np.concatenate([btens_b0, btens[indices]])
              else:
                  btens_sub = None
  
              data_conc = np.concatenate(
                  [b0_map, data[..., indices]], axis=3
              )
  
              gtab = gradient_table(
                  bvals_sub, bvecs_sub, btens=btens_sub
              )
              response, _ = response_from_mask_ssst(
                  gtab, data_conc, mask
              )
  
              responses.append(
                  list(np.concatenate([response[0], [response[1]]]))
              )
  
          tissue_responses.append(list(responses))
  
      wm_response = np.asarray(tissue_responses[0])
      gm_response = np.asarray(tissue_responses[1])
      csf_response = np.asarray(tissue_responses[2])
      return wm_response, gm_response, csf_response
  
imports: from packaging.version import Version
  import numbers
  import warnings
  import numpy
  from dipy.core import geometry
  from dipy.core.gradients import GradientTable, gradient_table, unique_bvals_tolerance, get_bval_indices
  from dipy.data import default_sphere
  from dipy.reconst import shm
  from dipy.reconst.csdeconv import response_from_mask_ssst
  from dipy.reconst.dti import TensorModel, fractional_anisotropy, mean_diffusivity
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.reconst.utils import _roi_in_volume, _mask_from_roi
  from dipy.sims.voxel import single_tensor
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 7 for calling a global function with example usage: response_from_mask_msmt(gtab, data, mask_wm, mask_gm, mask_csf, tol) and returns: wm_response,  gm_response,  csf_response