class_docstr: Basis function-based reconstruction method
  
  Inverted encoding models (alternatively known as forward models) are used
  to reconstruct a feature represented in some N-dimensional space, here 1D,
  (e.g. color of a stimulus) from patterns across voxels in functional data.
  The model uses n_channels number of idealized basis functions and assumes
  that the transformation from stimulus feature (e.g. color) to basis
  function is one- to-one and invertible. The response of a voxel is
  expressed as the weighted sum of basis functions. In this implementation,
  basis functions were half-wave rectified sinusoid functions raised to a
  power set by the user (e.g. 6).
  
  The model:
  Inverted encoding models reconstruct a stimulus feature from
  patterns of BOLD activity by relating the activity in each
  voxel, B, to the values of hypothetical channels (or basis
  functions), C, according to Equation 1 below.
  
  (1)     B = W*C
  
  where W is a weight matrix that represents the relationship
  between BOLD activity and Channels. W must be estimated from
  training data; this implementation (and most described in the
  literature) uses linear regression to estimate W as in Equation
  2 below [note: inv() represents matrix inverse or
  pseudo-inverse].
  
  (2)     W_est = B_train*inv(C_train)
  
  The weights in W_est (short for "estimated") represent the
  contributions of each channel to the response of each voxel.
  Estimated channel responses can be computed given W_est and
  new voxel activity represented in matrix B_exp (short for
  "experiment") through inversion of Equation 1:
  
  (3)     C_est = inv(W_est)*B_exp
  
  Given estimated channel responses, C_est, it is straightforward
  to obtain the reconstructed feature value by summing over
  channels multiplied by their channel responses and taking the
  argmax (i.e. the feature associated with the maximum value).
  
  Using this model:
  Use fit() to estimate the weights of the basis functions given
  input data (e.g. beta values from fMRI data). This function
  will execute equation 2 above.
  
  Use predict() to compute predicted stimulus values
  from new functional data. This function computes estimated
  channel responses, as in equation 3, then computes summed
  channel output and finds the argmax (within the stimulus
  feature space) associated with those responses.
  
  Use score() to compute a measure of the error of the prediction
  based on known stimuli.
  
  This implementation assumes a circular (or half-
  circular) feature domain. Future implementations might
  generalize the feature input space, and increase the
  possible dimensionality.
  
  Parameters
  ----------
  n_channels: int, default 5. Number of channels
      The number of channels, or basis functions, to be used in
      the inverted encoding model.
  
  channel_exp: int, default 6. Basis function exponent.
      The exponent of the sinuoidal basis functions, which
      establishes the width of the functions.
  
  stimulus_mode: str, default 'halfcircular' (other option is
      'circular'). Describes the feature domain.
  
  range_start: double, default 0. Lowest value of domain.
      Beginning value of range of independent variable
      (usually degrees).
  
  range_stop: double, default 180. Highest value of domain.
      Ending value of range of independent variable
      (usually degrees).
  
  channel_density: int, default 180. Number of points in the
      feature domain.
  
  stimulus_resolution: double, default None will set the stimulus
      resolution to be identical to the channel density. This sets
      the resolution at which the stimuli were presented (e.g. a
      spatial position with some width has a lower stimulus
      resolution).
  
  Attributes
  ----------
  channels_: [n_channels, channel density] NumPy 2D array
      matrix defining channel values
  
  W_: sklearn.linear_model model containing weight matrix that
      relates estimated channel responses to response amplitude
      data
  
  See get_params() for the rest of the attributes.
class_docstr_tok: ["Basis","function-based","reconstruction","method","Inverted","encoding","models","(","alternatively","known","as","forward","models",")","are","used","to","reconstruct","a","feature","represented","in","some","N-dimensional","space",",","here","1D",",","(","e.g",".","color","of","a","stimulus",")","from","patterns","across","voxels","in","functional","data",".","The","model","uses","n_channels","number","of","idealized","basis","functions","and","assumes","that","the","transformation","from","stimulus","feature","(","e.g",".","color",")","to","basis","function","is","one-","to-one","and","invertible",".","The","response","of","a","voxel","is","expressed","as","the","weighted","sum","of","basis","functions",".","In","this","implementation",",","basis","functions","were","half-wave","rectified","sinusoid","functions","raised","to","a","power","set","by","the","user","(","e.g",".","6",")",".","The","model",":","Inverted","encoding","models","reconstruct","a","stimulus","feature","from","patterns","of","BOLD","activity","by","relating","the","activity","in","each","voxel",",","B",",","to","the","values","of","hypothetical","channels","(","or","basis","functions",")",",","C",",","according","to","Equation","1","below",".","(","1",")","B","=","W","*","C","where","W","is","a","weight","matrix","that","represents","the","relationship","between","BOLD","activity","and","Channels",".","W","must","be","estimated","from","training","data",";","this","implementation","(","and","most","described","in","the","literature",")","uses","linear","regression","to","estimate","W","as","in","Equation","2","below","[","note",":","inv","(",")","represents","matrix","inverse","or","pseudo-inverse","]",".","(","2",")","W_est","=","B_train","*","inv","(","C_train",")","The","weights","in","W_est","(","short","for","``","estimated","''",")","represent","the","contributions","of","each","channel","to","the","response","of","each","voxel",".","Estimated","channel","responses","can","be","computed","given","W_est","and","new","voxel","activity","represented","in","matrix","B_exp","(","short","for","''","experiment","''",")","through","inversion","of","Equation","1",":","(","3",")","C_est","=","inv","(","W_est",")","*","B_exp","Given","estimated","channel","responses",",","C_est",",","it","is","straightforward","to","obtain","the","reconstructed","feature","value","by","summing","over","channels","multiplied","by","their","channel","responses","and","taking","the","argmax","(","i.e",".","the","feature","associated","with","the","maximum","value",")",".","Using","this","model",":","Use","fit","(",")","to","estimate","the","weights","of","the","basis","functions","given","input","data","(","e.g",".","beta","values","from","fMRI","data",")",".","This","function","will","execute","equation","2","above",".","Use","predict","(",")","to","compute","predicted","stimulus","values","from","new","functional","data",".","This","function","computes","estimated","channel","responses",",","as","in","equation","3",",","then","computes","summed","channel","output","and","finds","the","argmax","(","within","the","stimulus","feature","space",")","associated","with","those","responses",".","Use","score","(",")","to","compute","a","measure","of","the","error","of","the","prediction","based","on","known","stimuli",".","This","implementation","assumes","a","circular","(","or","half-","circular",")","feature","domain",".","Future","implementations","might","generalize","the","feature","input","space",",","and","increase","the","possible","dimensionality",".","Parameters","--","--","--","--","--","n_channels",":","int",",","default","5",".","Number","of","channels","The","number","of","channels",",","or","basis","functions",",","to","be","used","in","the","inverted","encoding","model",".","channel_exp",":","int",",","default","6",".","Basis","function","exponent",".","The","exponent","of","the","sinuoidal","basis","functions",",","which","establishes","the","width","of","the","functions",".","stimulus_mode",":","str",",","default","'halfcircular","'","(","other","option","is","'circular","'",")",".","Describes","the","feature","domain",".","range_start",":","double",",","default","0",".","Lowest","value","of","domain",".","Beginning","value","of","range","of","independent","variable","(","usually","degrees",")",".","range_stop",":","double",",","default","180",".","Highest","value","of","domain",".","Ending","value","of","range","of","independent","variable","(","usually","degrees",")",".","channel_density",":","int",",","default","180",".","Number","of","points","in","the","feature","domain",".","stimulus_resolution",":","double",",","default","None","will","set","the","stimulus","resolution","to","be","identical","to","the","channel","density",".","This","sets","the","resolution","at","which","the","stimuli","were","presented","(","e.g",".","a","spatial","position","with","some","width","has","a","lower","stimulus","resolution",")",".","Attributes","--","--","--","--","--","channels_",":","[","n_channels",",","channel","density","]","NumPy","2D","array","matrix","defining","channel","values","W_",":","sklearn.linear_model","model","containing","weight","matrix","that","relates","estimated","channel","responses","to","response","amplitude","data","See","get_params","(",")","for","the","rest","of","the","attributes","."]
code: def __init__(
      self,
      n_channels=6,
      channel_exp=5,
      stimulus_mode="halfcircular",
      range_start=0.0,
      range_stop=180.0,
      channel_density=180,
      stimulus_resolution=None,
  ):
      self.n_channels = n_channels
      self.channel_exp = channel_exp
      self.stimulus_mode = stimulus_mode
      self.range_start = range_start
      self.range_stop = range_stop
      self.channel_density = channel_density
      self.channel_domain = np.linspace(
          range_start, range_stop - 1, channel_density
      )
      if stimulus_resolution is None:
          self.stim_res = channel_density
      else:
          self.stim_res = stimulus_resolution
      self._check_params()
  
imports: import logging
  import warnings
  import numpy
  import scipy.stats
  from sklearn.base import BaseEstimator
  from sklearn.metrics.pairwise import cosine_distances, euclidean_distances
  from ..utils.utils import circ_dist
label_desc: Use image node_id 1 to create a new InvertedEncoding1D object from inherited base classes: BaseEstimator with example: obj = InvertedEncoding1D(n_channels, channel_exp, stimulus_mode, range_start, range_stop, channel_density, stimulus_resolution)