code: def make_dics(
      info,
      forward,
      csd,
      reg=0.05,
      noise_csd=None,
      label=None,
      pick_ori=None,
      rank=None,
      weight_norm=None,
      reduce_rank=False,
      depth=1.0,
      real_filter=True,
      inversion="matrix",
      verbose=None,
  ):
      """Compute a Dynamic Imaging of Coherent Sources (DICS) spatial filter.
  
      This is a beamformer filter that can be used to estimate the source power
      at a specific frequency range :footcite:`GrossEtAl2001`. It does this by
      constructing a spatial filter for each source point.
      The computation of these filters is very similar to those of the LCMV
      beamformer (:func:`make_lcmv`), but instead of operating on a covariance
      matrix, the CSD matrix is used. When applying these filters to a CSD matrix
      (see :func:`apply_dics_csd`), the source power can be estimated for each
      source point.
  
      Parameters
      ----------
      %(info_not_none)s
      forward : instance of Forward
          Forward operator.
      csd : instance of CrossSpectralDensity
          The data cross-spectral density (CSD) matrices. A source estimate is
          performed for each frequency or frequency-bin defined in the CSD
          object.
      reg : float
          The regularization to apply to the cross-spectral density before
          computing the inverse.
      noise_csd : instance of CrossSpectralDensity | None
          Noise cross-spectral density (CSD) matrices. If provided, whitening
          will be done. The noise CSDs need to have been computed for the same
          frequencies as the data CSDs. Providing noise CSDs is mandatory if you
          mix sensor types, e.g. gradiometers with magnetometers or EEG with
          MEG.
  
          .. versionadded:: 0.20
      label : Label | None
          Restricts the solution to a given label.
      %(pick_ori_bf)s
      %(rank_none)s
  
          .. versionadded:: 0.17
      %(weight_norm)s
  
          Defaults to ``None``, in which case no normalization is performed.
      %(reduce_rank)s
      %(depth)s
      real_filter : bool
          If ``True``, take only the real part of the cross-spectral-density
          matrices to compute real filters.
  
          .. versionchanged:: 0.23
              Version 0.23 an earlier used ``real_filter=False`` as the default,
              as of version 0.24 ``True`` is the default.
      %(inversion_bf)s
  
          .. versionchanged:: 0.21
             Default changed to ``'matrix'``.
      %(verbose)s
  
      Returns
      -------
      filters : instance of Beamformer
          Dictionary containing filter weights from DICS beamformer.
          Contains the following keys:
  
              'kind' : str
                  The type of beamformer, in this case 'DICS'.
              'weights' : ndarray, shape (n_frequencies, n_weights)
                  For each frequency, the filter weights of the beamformer.
              'csd' : instance of CrossSpectralDensity
                  The data cross-spectral density matrices used to compute the
                  beamformer.
              'ch_names' : list of str
                  Channels used to compute the beamformer.
              'proj' : ndarray, shape (n_channels, n_channels)
                  Projections used to compute the beamformer.
              'vertices' : list of ndarray
                  Vertices for which the filter weights were computed.
              'n_sources' : int
                  Number of source location for which the filter weight were
                  computed.
              'subject' : str
                  The subject ID.
              'pick-ori' : None | 'max-power' | 'normal' | 'vector'
                  The orientation in which the beamformer filters were computed.
              'inversion' : 'single' | 'matrix'
                  Whether the spatial filters were computed for each dipole
                  separately or jointly for all dipoles at each vertex using a
                  matrix inversion.
              'weight_norm' : None | 'unit-noise-gain'
                  The normalization of the weights.
              'src_type' : str
                  Type of source space.
              'source_nn' : ndarray, shape (n_sources, 3)
                  For each source location, the surface normal.
              'is_free_ori' : bool
                  Whether the filter was computed in a fixed direction
                  (pick_ori='max-power', pick_ori='normal') or not.
              'whitener' : None | ndarray, shape (n_channels, n_channels)
                  Whitening matrix, provided if whitening was applied to the
                  covariance matrix and leadfield during computation of the
                  beamformer weights.
              'max-power-ori' : ndarray, shape (n_sources, 3) | None
                  When pick_ori='max-power', this fields contains the estimated
                  direction of maximum power at each source location.
  
      See Also
      --------
      apply_dics_csd
  
      Notes
      -----
      The original reference is :footcite:`GrossEtAl2001`. See
      :footcite:`vanVlietEtAl2018` for a tutorial style paper on the topic.
  
      The DICS beamformer is very similar to the LCMV (:func:`make_lcmv`)
      beamformer and many of the parameters are shared. However,
      :func:`make_dics` and :func:`make_lcmv` currently have different defaults
      for these parameters, which were settled on separately through extensive
      practical use case testing (but not necessarily exhaustive parameter space
      searching), and it remains to be seen how functionally interchangeable they
      could be.
  
      The default setting reproduce the DICS beamformer as described in
      :footcite:`vanVlietEtAl2018`::
  
          inversion='single', weight_norm=None, depth=1.
  
      To use the :func:`make_lcmv` defaults, use::
  
          inversion='matrix', weight_norm='unit-noise-gain-invariant', depth=None
  
      For more information about ``real_filter``, see the
      supplemental information from :footcite:`HippEtAl2011`.
  
      References
      ----------
      .. footbibliography::
      """  # noqa: E501
      rank = _check_rank(rank)
      _check_option(
          "pick_ori", pick_ori, [None, "vector", "normal", "max-power"]
      )
      _check_option("inversion", inversion, ["single", "matrix"])
      _validate_type(weight_norm, (str, None), "weight_norm")
  
      frequencies = [np.mean(freq_bin) for freq_bin in csd.frequencies]
      n_freqs = len(frequencies)
  
      _, _, allow_mismatch = _check_one_ch_type(
          "dics", info, forward, csd, noise_csd
      )
      # remove bads so that equalize_channels only keeps all good
      info = pick_info(
          info, pick_channels(info["ch_names"], [], info["bads"])
      )
      info, forward, csd = equalize_channels([info, forward, csd])
  
      csd, noise_csd = _prepare_noise_csd(csd, noise_csd, real_filter)
  
      depth = _check_depth(depth, "depth_sparse")
      if inversion == "single":
          depth["combine_xyz"] = False
  
      (
          is_free_ori,
          info,
          proj,
          vertices,
          G,
          whitener,
          nn,
          orient_std,
      ) = _prepare_beamformer_input(
          info,
          forward,
          label,
          pick_ori,
          noise_cov=noise_csd,
          rank=rank,
          pca=False,
          **depth,
      )
  
      # Compute ranks
      csd_int_rank = []
      if not allow_mismatch:
          noise_rank = compute_rank(noise_csd, info=info, rank=rank)
      for i in range(len(frequencies)):
          csd_rank = compute_rank(
              csd.get_data(index=i, as_cov=True), info=info, rank=rank
          )
          if not allow_mismatch:
              for key in csd_rank:
                  if (
                      key not in noise_rank
                      or csd_rank[key] != noise_rank[key]
                  ):
                      raise ValueError(
                          f"{key} data rank ({csd_rank[key]}) did not match the noise "
                          f"rank ({noise_rank.get(key, None)})"
                      )
          csd_int_rank.append(sum(csd_rank.values()))
  
      del noise_csd
      ch_names = list(info["ch_names"])
  
      logger.info("Computing DICS spatial filters...")
      Ws = []
      max_oris = []
      for i, freq in enumerate(frequencies):
          if n_freqs > 1:
              logger.info(
                  "    computing DICS spatial filter at "
                  f"{round(freq, 2)} Hz ({i + 1}/{n_freqs})"
              )
  
          Cm = csd.get_data(index=i)
  
          # XXX: Weird that real_filter happens *before* whitening, which could
          # make things complex again...?
          if real_filter:
              Cm = Cm.real
  
          # compute spatial filter
          n_orient = 3 if is_free_ori else 1
          W, max_power_ori = _compute_beamformer(
              G,
              Cm,
              reg,
              n_orient,
              weight_norm,
              pick_ori,
              reduce_rank,
              rank=csd_int_rank[i],
              inversion=inversion,
              nn=nn,
              orient_std=orient_std,
              whitener=whitener,
          )
          Ws.append(W)
          max_oris.append(max_power_ori)
  
      Ws = np.array(Ws)
      if pick_ori == "max-power":
          max_oris = np.array(max_oris)
      else:
          max_oris = None
  
      src_type = _get_src_type(forward["src"], vertices)
      subject = _subject_from_forward(forward)
      is_free_ori = (
          is_free_ori if pick_ori in [None, "vector"] else False
      )
      n_sources = np.sum([len(v) for v in vertices])
  
      filters = Beamformer(
          kind="DICS",
          weights=Ws,
          csd=csd,
          ch_names=ch_names,
          proj=proj,
          vertices=vertices,
          n_sources=n_sources,
          subject=subject,
          pick_ori=pick_ori,
          inversion=inversion,
          weight_norm=weight_norm,
          src_type=src_type,
          source_nn=forward["source_nn"].copy(),
          is_free_ori=is_free_ori,
          whitener=whitener,
          max_power_ori=max_oris,
      )
  
      return filters
  
file_path: mne-python/mne/beamformer/_dics.py
imports: import numpy
  from .._fiff.pick import pick_channels, pick_info
  from ..channels import equalize_channels
  from ..forward import _subject_from_forward
  from ..minimum_norm.inverse import _check_depth, _check_reference, combine_xyz
  from ..rank import compute_rank
  from ..source_estimate import _get_src_type, _make_stc
  from ..time_frequency import EpochsTFR
  from ..time_frequency.tfr import _check_tfr_complex
  from ..utils import _check_channels_spatial_filter, _check_one_ch_type, _check_option, _check_rank, _validate_type, logger, verbose, warn
  from ._compute_beamformer import Beamformer, _check_src_type, _compute_beamformer, _compute_power, _prepare_beamformer_input, _proj_whiten_data
label_desc: Use image node_id 1 for calling a global function with example usage: make_dics(info, forward, csd, reg, noise_csd, label, pick_ori, rank, weight_norm, reduce_rank, depth, real_filter, inversion, verbose) and returns: filters