brainardlab.nben.retina.core documentation

cone-class-responses-to-spectra

(cone-class-responses-to-spectra retina cone-class spectra & {:keys [wavelengths]})
Yields the given cone type's response to the given spectra of light from the given retina.  The
option :wavelengths may be given if the wavelengths at which the spectra are sampled is not
equivalent to (range 400 721 10).

cone-responses

(cone-responses retina image & {:keys [wavelengths]})
Yields the responses of all cones in the retina (in the order listed in both the :coordinates and
the :labels of the retina). The image argument must be a hyperspectral image matrix (ie, a seq of
seqs of seqs or 3D vector) that is being exposed to the retina or a map containing entries for
:rows, :cols, and :image-fn, which must give the size of the retina and provide access to the
hyperspectral seq of numbers when a row and column is passed to the :image-fn.  If the
wavelengths that the image is sampled on are not equivalent to (range 400 720 10), then the
:wavelengths argument should be passed to indicate the wavelengths at which the image was
sampled.

human-lambda-max

label-cones

(label-cones cones retinal-mosaic instructions & {:keys [seed], :or {seed nil}})
Yields a sequence of labels for the cones in the given mosaic using the makeup instructions.  The
cones argument must be a sequable collection of cone id's; retinal-mosaic must be a mosaic map
(ie, (mosaic? retinal-mosaic) must be true), and makeup must be a map of makeup instructions for
each cone id.  These maps may contain the following instructions:
If a cone's id maps to ..., then ...
 nil -> by default, when all other cone types have been placed, the remaining cones in the mosaic
   will be assigned random types from all cone types whose cone id's mapped to nil or were not
   present in the instructions map.
 <number> -> If the cone id maps to a number, this is taken to be a relative ratio part; ie, if
   {:L 5, :M 6, :S 1} then the ratio of :L to :M to :S cones in the final labelling should be
   close to 5:6:1.
 {:even-spacing <boolean>} -> any instruction map containing :spacing will be evenly spaced 
   according to a heuristic; if <spacing> is :hexagonal or :rectilinear then the spacing is such
   that the distance between these cones is approximately hexagonal or rectilinear.
 {:noise <noise>} -> for cones with :even-spacing, this specifies the fraction of the distance 
   between cones to allow for noise in the placement; <noise> is the std.dev. of a Gaussian
   centered at the ideal spacing position where 1 is scaled to be the distance between spaced
   cones (default is 0).
 {:weight <number>} -> same as just <number>, but other options may be provided.
 {:fraction <number>} -> exactly (round (* <number> (count retinal-mosaic))) cones of this type
   should be placed.
 {:count <number>} -> exactly <number> cones of this type should be placed.

mosaic

(mosaic & {:keys [layout filter size separation x0 y0 pixel-epsilon blur spectral-indices], :or {layout :rectilinear, filter nil, size 20, separation 1.0, x0 1.0, y0 1.0, pixel-epsilon 0.0010}})
Yields a mosaic given the parameters provided.  Mosaics are stored as vectors or 2-element
vectors, each of which specifies a cone position.  Note that when showing a retina images, the
images' coordinates are considered to lie at (1,1) for the top left corner to (width,height) for
the lower right corner.  Because the optics of the eye invert the image, it is sensible to
consider a retina covering the same range of coordinates to exist on a standard axis with the y
unit vector pointing up.  The mosaic structure that is returned is a map with three fields:
:coordinates for the cone positions and :signal-fn for the function that, given a hyperspectral
image tensor, returns the hyper-spectrum observed by each cone in the same order as they are
listed in the mosaic.

The following optional arguments may be used:
 :layout may be :rectilinear (default) or :hexagonal
 :filter may be :rectangle (default), :circular, or a function that will filter over the mosaic
    parameters
 :size may be a positive integer (default: 20) or 2-element seq of positive integers representing
    the height and width of the retina; the height and width must match the image patches shown
    to this retina.
 :separation (default 1.0) specifies how far a cone is from its nearest neighbors.
 :x0 (default: 1.0) specifies the starting x-value used in tiling the space.
 :y0 (default: 1.0) specifies the starting y-value used in tiling the space.
 :blur (default: nil) specifies the standard deviation of a blurring Gaussian, if any, to use on
    input images when calculating the response signal.
 :spectral-indices (default: nil) should be nil for a normal simulation; these may be set to
    imitate the conditions described in Sugita et al. (2004) Experience in early infancy is
    indispensable for color perception. Curr. Biol. 14(14):1267-1271. The indices given are the
    only wavelengths of the hyperspectral images that will be shown to the retina at each step,
    and each wavelength given will be shown only by itself in turn. These indices should be
    between 0 and 32 (inclusive) with 0 equivalent to 400 nm and 32 equivalent to 720 nm.

mosaic?

(mosaic? m)
Yields true if the give object is a mosaic and false otherwise.

retina

(retina & {:keys [mosaic cones lambda-max cone-makeup type pixel-epsilon surround noise], :or {mosaic :rectilinear, cones :automatic, lambda-max :automatic, :noise :none, cone-makeup :automatic, type :trichromat, pixel-epsilon 0.0010, surround :automatic}})
Yields a retina object using the given arguments.  Optional arguments include:
:mosaic (default :automatic), if :automatic, this creates a rectilinear mosaic with a separation
  of 1 to fill the retina; this may alternately be a formed mosaic or a seq of mosaic
  coordinates, in which case a mosaic structure is created out of the points.
:cones (default :trichromat), indicates the cones in the mosaic; this may be either a seq of
  cone type identifiers (e.g. [:L :M :S]) or one of :trichromat, :tetrachromat, or :dichromat.
  These map to [:L :M :S], [:L :A :M :S], and [:L :S] respectively.  As long as one of these
  tags or seq's is passed, the below arguments will auto-adjust their defaults.
:lambda-max (default :automatic), indicates the lambda-max values of the cones to be used in
  this retina.  This may be either a map of cone id to lambda-max value or a seq in the same
  order as the :cones option.  By default uses {:L 558.9, :A 545.0, :M 530.0, :S 420.7}.
:cone-makeup (default :automatic), indicates the parameters of the random draw for the cones.
  This may be a map of cone id to instruction or a seq in the same order as the :cones option.
  Instructions may be a number (taken as a ratio relative to other ratios) or a map which may
  contain the fields :exact (indicating, if true, that exactly this many cones must be drawn,
  within the limitations placed by using an integer number of cones), :count (indicating that
  a specific number of a cone type should be drawn), :fraction (indicating that this fraction
  of the cones should be this cone type), or :ratio (indicating that the ratio of this cone
  type to that of others should be drawn.
:surround (default :automatic), declares the type of surround suppression; nil indicates none,
  otherwise may be a standard deviation (in which case 0.25 is the assumed weigh) or [weight
  standard-deviation] or [weight standard-deviation opponent?]. In the latter of these, the
  opponent? flag may be set to true (default if not specified is false) to indicate that the
  surround should be composed of only opponent types. This requires that the S cones, at least,
  be represented as :S in the labels, and will compose L-cone surrounds out of M-cones, M-cone
  surrounds out of L-cones, and S-cone surrounds out of L- and M-cones.
:noise (default :none), declares the fraction of a signal's standard deviation should be used
  as the standard deviation for a random variate that is added to the signal. E.g., :noise 0.03
  indicates that 3% of the signal's standard deviation should be added back as noise.
:type (default :trichromat), indicates which kind of default values should be used for the 
  above options.  A value of nil uses the default options; other allowed values are
  :tetrachromat and :dichromat.  Additionally, :Bayer will produce a Bayer-like rectilinear
  mosaic.

retina?

(retina? r)
Yields true if the given object is a retina, otherwise false.

spectral-sensitivities

(spectral-sensitivities cones lambda-max)
Yields a map of cone id to spectral sensitivities for the given cones and given lambda-max values.