code: def test_bsa_methods():
      # generate the data
      n_subj = 5
      shape = (40, 40)
      pos = np.array([[12, 14], [20, 20], [30, 35]])
      # make a dataset with a nothing feature
      null_ampli = np.array([0, 0, 0])
      null_betas = surrogate_2d_dataset(
          n_subj=n_subj,
          shape=shape,
          pos=pos,
          ampli=null_ampli,
          width=5.0,
          seed=1,
      )
      # null_betas = np.reshape(null_dataset, (n_subj, shape[0], shape[1]))
      # make a dataset with a something feature
      pos_ampli = np.array([5, 7, 6])
      pos_betas = surrogate_2d_dataset(
          n_subj=n_subj,
          shape=shape,
          pos=pos,
          ampli=pos_ampli,
          width=5.0,
          seed=2,
      )
      # pos_betas = np.reshape(pos_dataset, (n_subj, shape[0], shape[1]))
      # set various parameters
      theta = float(st.t.isf(0.01, 100))
      sigma = 5.0 / 1.5
      half_subjs = n_subj / 2
      thq = 0.9
      smin = 5
  
      # tuple of tuples with each tuple being
      # (name_of_method, ths_value, data_set, test_function)
      algs_tests = (
          ("density", half_subjs, null_betas, lambda AF, BF: AF.k == 0),
          (
              "co-occurrence",
              half_subjs,
              null_betas,
              lambda AF, BF: AF.k == 0,
          ),
          ("density", 1, pos_betas, lambda AF, BF: AF.k > 1),
      )
  
      for name, ths, betas, test_func in algs_tests:
          # run the algo
          AF, BF = make_bsa_2d(
              betas, theta, sigma, ths, thq, smin, algorithm=name
          )
          assert test_func(AF, BF)
  
      assert AF.map_label().shape == (np.prod(shape),)
      assert AF.kernel_density().shape == (np.prod(shape),)
      assert (AF.roi_prevalence() > ths).all()
  
file_path: nipy/nipy/labs/spatial_models/tests/test_bsa.py
imports: import numpy
  import scipy.stats
  from nipy.testing import assert_array_equal
  from ...utils.simul_multisubject_fmri_dataset import surrogate_2d_dataset
  from ..bayesian_structural_analysis import _stat_to_proba, compute_landmarks
  from ..discrete_domain import domain_from_binary_array
label_desc: Use image node_id 2 for calling a global function with example usage: test_bsa_methods() without return types