code: def _check_centroid_position(pos, ch_names, pos_centroid):
      """Check the centroid distance.
  
      The cartesian average should be distanced from pos_centroid by the
      difference between the radii.
      """
      radii = list()
      cartesian_positions = np.zeros((len(ch_names), 3))
      for i, ch in enumerate(ch_names):
          radii.append(_cart_to_sph(pos["ch_pos"][ch])[0, 0])
          cartesian_positions[i, :] = pos["ch_pos"][ch]
      avg_radius = np.average(radii)
      avg_cartesian_position = np.average(cartesian_positions, axis=0)
      avg_cartesian_position_radius = _cart_to_sph(
          avg_cartesian_position
      )[0, 0]
      radius_diff = np.abs(avg_radius - avg_cartesian_position_radius)
      # distance
      distance = np.linalg.norm(pos_centroid - avg_cartesian_position)
      assert np.isclose(radius_diff, distance, atol=1e-6)
  
file_path: mne-python/mne/preprocessing/tests/test_interpolate.py
imports: import itertools
  from pathlib import Path
  import numpy
  import pytest
  from mne import Epochs, create_info, io, pick_types, read_events
  from mne.channels import make_standard_montage
  from mne.preprocessing import equalize_bads, interpolate_bridged_electrodes
  from mne.preprocessing.interpolate import _find_centroid_sphere
  from mne.transforms import _cart_to_sph
label_desc: Use image node_id 5 for calling a global function with example usage: _check_centroid_position(pos, ch_names, pos_centroid) without return types