code: def _generate_feature(
      feature_type, feature_size, signal_magnitude, thickness=1
  ):
      """Generate features corresponding to signal
  
      Generate a single feature, that can be inserted into the signal volume.
      A feature is a region of activation with a specific shape such as cube
      or ring
  
      Parameters
      ----------
  
      feature_type : str
          What shape signal is being inserted? Options are 'cube',
          'loop' (aka ring), 'cavity' (aka hollow sphere), 'sphere'.
  
      feature_size : int
          How big is the signal in diameter?
  
      signal_magnitude : float
          Set the signal size, a value of 1 means the signal is one standard
          deviation of the noise
  
      thickness : int
          How thick is the surface of the loop/cavity
  
      Returns
      ----------
  
      signal : 3 dimensional array
          The volume representing the signal
  
      """
  
      # If the size is equal to or less than 2 then all features are the same
      if feature_size <= 2:
          feature_type = "cube"
  
      # What kind of signal is it?
      if feature_type == "cube":
          # Preset the size of the signal
          signal = np.ones((feature_size, feature_size, feature_size))
  
      elif feature_type == "loop":
          # First make a cube of zeros
          signal = np.zeros((feature_size, feature_size, feature_size))
  
          # Make a mesh grid of the space
          seq = np.linspace(0, feature_size - 1, feature_size)
          xx, yy = np.meshgrid(seq, seq)
  
          # Make a disk corresponding to the whole mesh grid
          xxmesh = (xx - ((feature_size - 1) / 2)) ** 2
          yymesh = (yy - ((feature_size - 1) / 2)) ** 2
          disk = xxmesh + yymesh
  
          # What are the limits of the rings being made
          outer_lim = disk[int((feature_size - 1) / 2), 0]
          inner_lim = disk[int((feature_size - 1) / 2), thickness]
  
          # What is the outer disk
          outer = disk <= outer_lim
  
          # What is the inner disk
          inner = disk <= inner_lim
  
          # Subtract the two disks to get a loop
          loop = outer != inner
  
          # Check if the loop is a disk
          if np.all(inner is False):
              logger.warning(
                  "Loop feature reduces to a disk because the loop "
                  "is too thick"
              )
  
          # If there is complete overlap then make the signal just the
          #  outer one
          if np.all(loop is False):
              loop = outer
  
          # store the loop
          signal[
              0:feature_size,
              0:feature_size,
              int(np.round(feature_size / 2)),
          ] = loop
  
      elif feature_type == "sphere" or feature_type == "cavity":
          # Make a mesh grid of the space
          seq = np.linspace(0, feature_size - 1, feature_size)
          xx, yy, zz = np.meshgrid(seq, seq, seq)
  
          # Make a disk corresponding to the whole mesh grid
          signal = (
              (xx - ((feature_size - 1) / 2)) ** 2
              + (yy - ((feature_size - 1) / 2)) ** 2
              + (zz - ((feature_size - 1) / 2)) ** 2
          )
  
          # What are the limits of the rings being made
          outer_lim = signal[
              int((feature_size - 1) / 2),
              int((feature_size - 1) / 2),
              0,
          ]
          inner_lim = signal[
              int((feature_size - 1) / 2),
              int((feature_size - 1) / 2),
              thickness,
          ]
  
          # Is the signal a sphere or a cavity?
          if feature_type == "sphere":
              signal = signal <= outer_lim
  
          else:
              # Get the inner and outer sphere
              outer = signal <= outer_lim
              inner = signal <= inner_lim
  
              # Subtract the two disks to get a loop
              signal = outer != inner
  
              # Check if the cavity is a sphere
              if np.all(inner is False):
                  logger.warning(
                      "Cavity feature reduces to a sphere because "
                      "the cavity is too thick"
                  )
  
              # If there is complete overlap then make the signal just the
              #  outer one
              if np.all(signal is False):
                  signal = outer
  
      # Assign the signal magnitude
      signal = signal * signal_magnitude
  
      # Return the signal
      return signal
  
imports: import logging
  from itertools import product
  from statsmodels.tsa.arima.model import ARIMA
  import math
  import numpy
  from numpy.linalg import LinAlgError
  from pkg_resources import resource_stream
  from scipy import stats
  from scipy import signal
  import scipy.ndimage
  import copy
  from scipy import optimize
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_feature(feature_type, feature_size, signal_magnitude, thickness) and returns: signal