code: def generate_regions_ts(
      n_features, n_regions, overlap=0, random_state=0, window="boxcar"
  ):
      """Generate some regions as timeseries.
  
      Parameters
      ----------
      n_features : :obj:`int`
          Number of features.
  
      n_regions : :obj:`int`
          Number of regions.
  
      overlap : :obj:`int`, default=0
          Number of overlapping voxels between two regions (more or less).
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance, \
                     default=0
          Random number generator, or seed.
  
      window : :obj:`str`, default='boxcar'
          Name of a window in scipy.signal. e.g. "hamming".
  
      Returns
      -------
      regions : :obj:`numpy.ndarray`
          Regions, represented as signals.
          shape (n_features, n_regions)
  
      """
      rand_gen = np.random.default_rng(random_state)
      if window is None:
          window = "boxcar"
  
      assert n_features > n_regions
  
      # Compute region boundaries indices.
      # Start at 1 to avoid getting an empty region
      boundaries = np.zeros(n_regions + 1)
      boundaries[-1] = n_features
      boundaries[1:-1] = rand_gen.permutation(np.arange(1, n_features))[
          : n_regions - 1
      ]
      boundaries.sort()
  
      regions = np.zeros((n_regions, n_features), order="C")
      overlap_end = int((overlap + 1) / 2.0)
      overlap_start = int(overlap / 2.0)
      for n in range(len(boundaries) - 1):
          start = int(max(0, boundaries[n] - overlap_start))
          end = int(min(n_features, boundaries[n + 1] + overlap_end))
          win = scipy.signal.get_window(window, end - start)
          win /= win.mean()  # unity mean
          regions[n, start:end] = win
  
      return regions
  
imports: from __future__ import annotations
  import itertools
  import json
  import string
  from pathlib import Path
  import numpy
  import pandas
  import scipy.linalg
  import scipy.signal
  from nibabel import Nifti1Image
  from scipy.ndimage import binary_dilation
  from nilearn import datasets, image, maskers, masking
  from nilearn._utils import as_ndarray, logger
  from nilearn.interfaces.bids.utils import bids_entities, check_bids_label, create_bids_filename
  from nilearn.interfaces.fmriprep.tests._testing import get_legal_confound
label_desc: Use image node_id 3 for calling a global function with example usage: generate_regions_ts(n_features, n_regions, overlap, random_state, window) and returns: regions