code: def generate_signal(
      dimensions,
      feature_coordinates,
      feature_size,
      feature_type,
      signal_magnitude=[1],
      signal_constant=1,
  ):
      """Generate volume containing signal
  
      Generate signal, of a specific shape in specific regions, for a single
      volume. This will then be convolved with the HRF across time
  
      Parameters
      ----------
  
      dimensions : 1d array, ndarray
          What are the dimensions of the volume you wish to create
  
      feature_coordinates : multidimensional array
          What are the feature_coordinates of the signal being created.
          Be aware of clipping: features far from the centre of the
          brain will be clipped. If you wish to have multiple features
          then list these as a features x 3 array. To create a feature of
          a unique shape then supply all the individual
          feature_coordinates of the shape and set the feature_size to 1.
  
      feature_size : list, int
          How big is the signal. If feature_coordinates=1 then only one value is
          accepted, if feature_coordinates>1 then either one value must be
          supplied or m values
  
      feature_type : list, string
          What feature_type of signal is being inserted? Options are cube,
          loop, cavity, sphere. If feature_coordinates = 1 then
          only one value is accepted, if feature_coordinates > 1 then either
          one value must be supplied or m values
  
      signal_magnitude : list, float
          What is the (average) magnitude of the signal being generated? A
          value of 1 means that the signal is one standard deviation from the
          noise
  
      signal_constant : list, bool
          Is the signal constant across the feature (for univariate activity)
          or is it a random pattern of a given magnitude across the feature (for
          multivariate activity)
  
      Returns
      ----------
      volume_signal : 3 dimensional array, float
          Creates a single volume containing the signal
  
      """
  
      # Preset the volume
      volume_signal = np.zeros(dimensions)
  
      feature_quantity = round(feature_coordinates.shape[0])
  
      # If there is only one feature_size value then make sure to duplicate it
      # for all signals
      if len(feature_size) == 1:
          feature_size = feature_size * feature_quantity
  
      # Do the same for feature_type
      if len(feature_type) == 1:
          feature_type = feature_type * feature_quantity
  
      if len(signal_magnitude) == 1:
          signal_magnitude = signal_magnitude * feature_quantity
  
      # Iterate through the signals and insert in the data
      for signal_counter in range(feature_quantity):
          # What is the centre of this signal
          if len(feature_size) > 1:
              feature_centre = np.asarray(
                  feature_coordinates[signal_counter,]
              )
          else:
              feature_centre = np.asarray(feature_coordinates)[0]
  
          # Generate the feature to be inserted in the volume
          signal = _generate_feature(
              feature_type[signal_counter],
              feature_size[signal_counter],
              signal_magnitude[signal_counter],
          )
  
          # If the signal is a random noise pattern then multiply these ones by
          # a noise mask
          if signal_constant == 0:
              signal = signal * np.random.random(
                  [
                      feature_size[signal_counter],
                      feature_size[signal_counter],
                      feature_size[signal_counter],
                  ]
              )
  
          # Pull out the idxs for where to insert the data
          x_idx, y_idx, z_idx = _insert_idxs(
              feature_centre, feature_size[signal_counter], dimensions
          )
  
          # Insert the signal into the Volume
          volume_signal[
              x_idx[0] : x_idx[1],
              y_idx[0] : y_idx[1],
              z_idx[0] : z_idx[1],
          ] = signal
  
      return volume_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 3 for calling a global function with example usage: generate_signal(dimensions, feature_coordinates, feature_size, feature_type, signal_magnitude, signal_constant) and returns: volume_signal