code: def test_median_otsu():
      fname = get_fnames("S0_10")
      data = load_nifti_data(fname)
      data = np.squeeze(data.astype("f8"))
      dummy_mask = data > data.mean()
      data_masked, mask = median_otsu(
          data,
          median_radius=3,
          numpass=2,
          autocrop=False,
          vol_idx=None,
          dilate=None,
      )
      assert_equal(mask.sum() < dummy_mask.sum(), True)
      data2 = np.zeros(data.shape + (2,))
      data2[..., 0] = data
      data2[..., 1] = data
  
      data2_masked, mask2 = median_otsu(
          data2,
          median_radius=3,
          numpass=2,
          autocrop=False,
          vol_idx=[0, 1],
          dilate=None,
      )
      assert_almost_equal(mask.sum(), mask2.sum())
  
      _, mask3 = median_otsu(
          data2,
          median_radius=3,
          numpass=2,
          autocrop=False,
          vol_idx=[0, 1],
          dilate=1,
      )
      assert_equal(mask2.sum() < mask3.sum(), True)
  
      _, mask4 = median_otsu(
          data2,
          median_radius=3,
          numpass=2,
          autocrop=False,
          vol_idx=[0, 1],
          dilate=2,
      )
      assert_equal(mask3.sum() < mask4.sum(), True)
  
      # For 4D volumes, can't call without vol_idx input:
      assert_raises(ValueError, median_otsu, data2)
  
file_path: dipy/dipy/segment/tests/test_mask.py
imports: import warnings
  import numpy
  from scipy.ndimage import generate_binary_structure, binary_dilation
  from scipy.ndimage import median_filter
  from dipy.segment.mask import otsu, bounding_box, crop, applymask, multi_median, median_otsu
  from numpy.testing import assert_equal, assert_almost_equal, assert_raises
  from dipy.data import get_fnames
  from dipy.io.image import load_nifti_data
label_desc: Use image node_id 3 for calling a global function with example usage: test_median_otsu() without return types