raytraverse.evaluate

MetricSet

class raytraverse.evaluate.MetricSet(vm, vec, omega, lum, metricset=None, scale=179.0, threshold=2000.0, guth=True, tradius=30.0, **kwargs)[source]

Bases: object

object for calculating metrics based on a view direction, and rays consisting on direction, solid angle and luminance information

by encapsulating these calculations within a class, metrics with redundant calculations can take advantage of cached results, for example dgp does not need to recalculate illuminance when it has been directly requested. all metrics can be accessed as properties (and are calculated just in time) or the object can be called (no arguments) to return a np.array of all metrics defined in “metricset”

Parameters
  • vm (raytraverse.mapper.ViewMapper) – the view direction

  • vec (np.array) – (N, 3) directions of all rays in view

  • omega (np.array) – (N,) solid angle of all rays in view

  • lum (np.array) – (N,) luminance of all rays in view (multiplied by “scale”)

  • metricset (list, optional) – keys of metrics to return, same as property names

  • scale (float, optional) – scalefactor for luminance

  • threshold (float, optional) – threshold for glaresource/background similar behavior to evalglare ‘-b’ paramenter. if greater than 100 used as a fixed luminance threshold. otherwise used as a factor times the task luminance (defined by ‘tradius’)

  • guth (bool, optional) – if True, use Guth for the upper field of view and iwata for the lower if False, use Kim

  • tradius (float, optional) – radius in degrees for task luminance calculation

  • kwargs – additional arguments that may be required by additional properties

allmetrics = ['illum', 'avglum', 'gcr', 'ugp', 'dgp', 'tasklum', 'backlum', 'dgp_t1', 'log_gc', 'dgp_t2', 'ugr', 'threshold', 'pwsl2', 'view_area', 'density', 'reldensity', 'lumcenter', 'avgraylum', 'backlum_true', 'srcillum']
defaultmetrics = ['illum', 'avglum', 'gcr', 'ugp', 'dgp']

available metrics (and the default return set)

static check_metrics(metrics, raise_error=False)[source]

returns list of valid metric names from argument if raise_error is True, raises an Atrribute Error

property vec
property lum
property omega
property ctheta

cos angle between ray and view

property radians

cos angle between ray and view

property src_mask

boolean mask for filtering source/background rays

property task_mask
property sources

vec, omega, lum of rays above threshold

property background

vec, omega, lum of rays below threshold

property source_pos_idx
property threshold

threshold for glaresource/background similar behavior to evalglare ‘-b’ paramenter

property pwsl2

position weighted source luminance squared, used by dgp, ugr, etc sum(Ls^2*omega/Ps^2)

property srcillum

average background luminance

property backlum

average background luminance CIE estimate (official for some metrics)

property backlum_true

average background luminance mathematical

property tasklum

average task luminance

property illum

illuminance

property avglum

average luminance

property avgraylum

average luminance (not weighted by omega

property gcr

a unitless measure of relative contrast defined as the average of the squared luminances divided by the average luminance squared

property dgp
property dgp_t1
property log_gc
property dgp_t2
property ugr
property ugp
property density
property reldensity
property lumcenter

PositionIndex

class raytraverse.evaluate.PositionIndex(guth=True)[source]

Bases: object

calculate position index according to guth/iwata or kim

Parameters

guth (bool) – if True, use Guth for the upper field of view and iwata for the lower if False, use Kim

positions(vm, vec)[source]

calculate position indices for a set of vectors

Parameters
  • vm (raytraverse.mapper.ViewMapper) – the view/analysis point, should have 180 degree field of view

  • vec (np.array) – shape (N,3) the view vectors to calculate

Returns

posidx – shape (N,) the position indices

Return type

np.arrray

static _to_plane(n, vec)[source]
static _angle_vv(a, b)[source]
static _get_pidx_guth(sigma, tau)[source]
static _get_pidx_iwata(phi, theta)[source]
static _get_pidx_kim(sigma, tau)[source]

retina

raytraverse.evaluate.retina.rgcf_density_on_meridian(deg, mi)[source]

retinal ganlgion cell field density along a meridian as a functional best fit.

the field density accounts for the input region of the ganglion cell to account for displaced ganglion cells. This value is estimate from cone density and the inferred density of midget ganglion cells. see Watson (2014) for important caveats.

Parameters
  • deg (np.array) – eccentricity in degrees along merdian

  • mi (int) – meridian index. [0, 1, 2, 3] for Temporal, Superior, Nasal, Inferior.

Returns

1d array of retinal ganglion cell density along a merdian

Return type

np.array

raytraverse.evaluate.retina.rgc_density_on_meridian(deg, mi)[source]

retinal ganglion cell density along a merdian as a linear interpolation between non-zero measurements

As opposed to the field density this estimate the actual location of ganglion cells, which could be important to consider for intrinsically photosensitive cells. These are (partially?) responsible for pupillary response. However, even iprgc (may?) receive signals from rods/cones

Parameters
  • deg (np.array) – eccentricity in degrees along merdian

  • mi (int) – meridian index. [0, 1, 2, 3] for Temporal, Superior, Nasal, Inferior.

Returns

1d array of retinal ganglion cell density along a merdian

Return type

np.array

raytraverse.evaluate.retina.rgcf_density_xy(xy, func=<function rgcf_density_on_meridian>)[source]

interpolate density between meridia, selected by quadrant

Parameters
  • xy (np.array) – xy visual field coordinates on a disk in degrees (eccentricity 0-90 from fovea)

  • func (callable) – density function along a meridian, takes r in degrees and an axes index: [0, 1, 2, 3] for Temporal, Superior, Nasal, Inferior.

Returns

1d array of single eye densities

Return type

np.array

raytraverse.evaluate.retina.binocular_density(xy, func=<function rgcf_density_on_meridian>)[source]

average denisty between both eyes.

Parameters
  • xy (np.array) – xy visual field coordinates on a disk (eccentricity 0-1 from fovea)

  • func (callable) – density function along a meridian, takes r in degrees and an axes index: [0, 1, 2, 3] for Temporal, Superior, Nasal, Inferior. coordinates are for the visual field.

Returns

1d array of average binocular densities

Return type

np.array

raytraverse.evaluate.retina.rgcf_density(xy)[source]

retinal ganglion cell field density

Parameters

xy (np.array) – xy visual field coordinates on a disk (eccentricity 0-1 from fovea)

Returns

1d array retinal ganglion cell field density according to model by Watson

Return type

np.array

raytraverse.evaluate.retina.rgc_density(xy)[source]

retinal ganglion cell density (includes displaced ganglion cells)

Parameters

xy (np.array) – xy visual field coordinates on a disk (eccentricity 0-1 from fovea)

Returns

1d array retinal ganglion cell density according to measurements by Curcio

Return type

np.array