code: def test_isfc_options():
      # Set parameters for toy time series data
      n_subjects = 20
      n_TRs = 60
      n_voxels = 30
  
      logger.info("Testing ISFC options")
  
      data = simulated_timeseries(
          n_subjects, n_TRs, n_voxels=n_voxels, data_type="array"
      )
      isfcs, iscs = isfc(data, pairwise=False, summary_statistic=None)
      assert isfcs.shape == (n_subjects, n_voxels * (n_voxels - 1) / 2)
      assert iscs.shape == (n_subjects, n_voxels)
  
      # Without vectorized upper triangle
      isfcs = isfc(
          data,
          pairwise=False,
          summary_statistic=None,
          vectorize_isfcs=False,
      )
      assert isfcs.shape == (n_subjects, n_voxels, n_voxels)
  
      # Just two subjects
      isfcs, iscs = isfc(
          data[..., :2], pairwise=False, summary_statistic=None
      )
      assert isfcs.shape == (n_voxels * (n_voxels - 1) / 2,)
      assert iscs.shape == (n_voxels,)
  
      isfcs = isfc(
          data[..., :2],
          pairwise=False,
          summary_statistic=None,
          vectorize_isfcs=False,
      )
      assert isfcs.shape == (n_voxels, n_voxels)
  
      # ISFC with pairwise approach
      isfcs, iscs = isfc(data, pairwise=True, summary_statistic=None)
      assert isfcs.shape == (
          n_subjects * (n_subjects - 1) / 2,
          n_voxels * (n_voxels - 1) / 2,
      )
      assert iscs.shape == (n_subjects * (n_subjects - 1) / 2, n_voxels)
  
      isfcs = isfc(
          data,
          pairwise=True,
          summary_statistic=None,
          vectorize_isfcs=False,
      )
      assert isfcs.shape == (
          n_subjects * (n_subjects - 1) / 2,
          n_voxels,
          n_voxels,
      )
  
      # ISFC with summary statistics
      isfcs, iscs = isfc(data, pairwise=True, summary_statistic="mean")
      isfcs, iscs = isfc(
          data, pairwise=True, summary_statistic="median"
      )
  
      # Check output p-values
      data = correlated_timeseries(20, 60, noise=0.5, random_state=42)
      isfcs = isfc(data, pairwise=False, vectorize_isfcs=False)
      assert np.all(isfcs[:, 0, 1] > 0.5) and np.all(
          isfcs[:, 1, 0] > 0.5
      )
      assert np.all(isfcs[:, :2, 2] < 0.5) and np.all(
          isfcs[:, 2, :2] < 0.5
      )
  
      isfcs = isfc(data, pairwise=True, vectorize_isfcs=False)
      assert np.all(isfcs[:, 0, 1] > 0.5) and np.all(
          isfcs[:, 1, 0] > 0.5
      )
      assert np.all(isfcs[:, :2, 2] < 0.5) and np.all(
          isfcs[:, 2, :2] < 0.5
      )
  
      # Check that ISC and ISFC diagonal are identical
      iscs = isc(data, pairwise=False)
      isfcs = isfc(data, pairwise=False, vectorize_isfcs=False)
      for s in np.arange(len(iscs)):
          assert np.allclose(
              isfcs[s, ...].diagonal(), iscs[s, :], rtol=1e-03
          )
      isfcs, iscs_v = isfc(data, pairwise=False)
      assert np.allclose(iscs, iscs_v, rtol=1e-03)
  
      # Check that ISC and ISFC diagonal are identical (pairwise)
      iscs = isc(data, pairwise=True)
      isfcs = isfc(data, pairwise=True, vectorize_isfcs=False)
      for s in np.arange(len(iscs)):
          assert np.allclose(
              isfcs[s, ...].diagonal(), iscs[s, :], rtol=1e-03
          )
      isfcs, iscs_v = isfc(data, pairwise=True)
      assert np.allclose(iscs, iscs_v, rtol=1e-03)
  
      # Generate 'targets' data and use for ISFC
      data = simulated_timeseries(
          n_subjects, n_TRs, n_voxels=n_voxels, data_type="array"
      )
      n_targets = 15
      targets_data = simulated_timeseries(
          n_subjects, n_TRs, n_voxels=n_targets, data_type="array"
      )
      isfcs = isfc(
          data,
          targets=targets_data,
          pairwise=False,
          vectorize_isfcs=False,
      )
      assert isfcs.shape == (n_subjects, n_voxels, n_targets)
  
      # Ensure 'square' output enforced
      isfcs = isfc(
          data,
          targets=targets_data,
          pairwise=False,
          vectorize_isfcs=True,
      )
      assert isfcs.shape == (n_subjects, n_voxels, n_targets)
  
      # Check list input for targets
      targets_data = simulated_timeseries(
          n_subjects, n_TRs, n_voxels=n_targets, data_type="list"
      )
      isfcs = isfc(
          data,
          targets=targets_data,
          pairwise=False,
          vectorize_isfcs=False,
      )
      assert isfcs.shape == (n_subjects, n_voxels, n_targets)
  
      # Check that mismatching subjects / TRs breaks targets
      targets_data = simulated_timeseries(
          n_subjects, n_TRs, n_voxels=n_targets, data_type="array"
      )
  
      with pytest.raises(ValueError):
          isfcs = isfc(
              data,
              targets=targets_data[..., :-1],
              pairwise=False,
              vectorize_isfcs=False,
          )
      assert isfcs.shape == (n_subjects, n_voxels, n_targets)
  
      with pytest.raises(ValueError):
          isfcs = isfc(
              data,
              targets=targets_data[:-1, ...],
              pairwise=False,
              vectorize_isfcs=False,
          )
  
      # Check targets for only 2 subjects
      isfcs = isfc(
          data[..., :2],
          targets=targets_data[..., :2],
          pairwise=False,
          summary_statistic=None,
      )
      assert isfcs.shape == (2, n_voxels, n_targets)
  
      isfcs = isfc(
          data[..., :2],
          targets=targets_data[..., :2],
          pairwise=True,
          summary_statistic=None,
      )
      assert isfcs.shape == (2, n_voxels, n_targets)
  
      # Check that supplying targets enforces leave-one-out
      isfcs_pw = isfc(
          data,
          targets=targets_data,
          pairwise=True,
          vectorize_isfcs=False,
          tolerate_nans=False,
      )
      assert isfcs_pw.shape == (n_subjects, n_voxels, n_targets)
  
      logger.info("Finished testing ISFC options")
  
file_path: brainiak/tests/isc/test_isc.py
imports: import numpy
  import logging
  import pytest
  from brainiak.isc import isc, isfc, bootstrap_isc, permutation_isc, squareform_isfc, timeshift_isc, phaseshift_isc
  from scipy.spatial.distance import squareform
label_desc: Use image node_id 11 for calling a global function with example usage: test_isfc_options() without return types