code: def test_series_from_mask(in_tmp_path):
      """Test the smoothing of the timeseries extraction"""
      # A delta in 3D
      data = np.zeros((40, 40, 40, 2))
      data[20, 20, 20] = 1
      mask = np.ones((40, 40, 40), dtype=np.bool_)
      for affine in (
          np.eye(4),
          np.diag((1, 1, -1, 1)),
          np.diag((0.5, 1, 0.5, 1)),
      ):
          img = nib.Nifti1Image(data, affine)
          nib.save(img, "testing.nii")
          series, header = series_from_mask(
              "testing.nii", mask, smooth=9
          )
          series = np.reshape(series[:, 0], (40, 40, 40))
          vmax = series.max()
          # We are expecting a full-width at half maximum of
          # 9mm/voxel_size:
          above_half_max = series > 0.5 * vmax
          for axis in (0, 1, 2):
              proj = np.any(
                  np.any(
                      np.rollaxis(above_half_max, axis=axis), axis=-1
                  ),
                  axis=-1,
              )
              assert proj.sum() == 9 / np.abs(affine[axis, axis])
  
      # Check that NaNs in the data do not propagate
      data[10, 10, 10] = np.NaN
      img = nib.Nifti1Image(data, affine)
      nib.save(img, "testing.nii")
      series, header = series_from_mask("testing.nii", mask, smooth=9)
      assert np.all(np.isfinite(series))
  
file_path: nipy/nipy/labs/tests/test_mask.py
imports: import nibabel
  import numpy
  from nipy.testing import anatfile, assert_array_equal
  from ..None import mask
  from ..mask import largest_cc, series_from_mask, threshold_connect_components
label_desc: Use image node_id 5 for calling a global function with example usage: test_series_from_mask(in_tmp_path) without return types