Skip to main content

Software for performing silent substitution in Python.

Project description

Welcome to PySilentSubstitution!

DOI PyPI version Contributor Covenant PyPi license PyPI status

photoreceptor-characters

PySilSub is a Python software for performing the method of silent substitution with any multiprimary stimulation system for which accurate calibration data are available. Solutions are found with linear algebra and numerical optimisation via a flexible, intuitive interface:

# Example 1 - Target melanopsin with 100% contrast (no background 
# specified), whilst ignoring rods and minimizing cone contrast, 
# for a 42-year-old observer and field size of 10 degrees. Solved
# with numerical optimization.

from pysilsub.problems import SilentSubstitutionProblem as SSP
from pysilsub.observers import IndividualColorimetricObserver as ICO

problem = SSP.from_package_data('STLAB_1_York')  # Load example data
problem.observer = ICO(age=42, field_size=10)  # Assign custom observer model
problem.ignore = ['rh']  # Ignore rod photoreceptors
problem.minimize = ['sc', 'mc', 'lc']  # Minimise cone contrast
problem.modulate = ['mel']  # Target melanopsin
problem.target_contrast = 1.0  # With 100% contrast 
solution = problem.optim_solve()  # Solve with optimisation
fig = problem.plot_solution(solution.x)  # Plot the solution
Example 1

Another example:

# Example 2 - Target S-cones with 45% contrast against a specified 
# background spectrum (all primaries, half max) whilst ignoring rods 
# and minimizing contrast on L/M cones and melanopsin, assuming 
# 32-year-old observer and 10-degree field size. Solved with linear 
# algebra.

from pysilsub.problems import SilentSubstitutionProblem as SSP

problem = SSP.from_package_data('STLAB_1_York')  # Load example data
problem.background = [.5] * problem.nprimaries  # Specify background spectrum
problem.ignore = ['rh']  # Ignore rod photoreceptors
problem.minimize = ['sc', 'mc', 'lc']  # Minimise cone contrast
problem.modulate = ['mel']  # Target melanopsin
problem.target_contrast = .45  # With 45% contrast 
solution = problem.linalg_solve()  # Solve with optimisation
fig = problem.plot_solution(solution)  # Plot the solution
Example 2

There are many other features and use cases covered. The package also includes 6 example datasets for various multiprimary systems, so you can run the above code after a simple pip install:

pip install pysilsub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysilsub-0.0.14.tar.gz (6.3 MB view details)

Uploaded Source

File details

Details for the file pysilsub-0.0.14.tar.gz.

File metadata

  • Download URL: pysilsub-0.0.14.tar.gz
  • Upload date:
  • Size: 6.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.4

File hashes

Hashes for pysilsub-0.0.14.tar.gz
Algorithm Hash digest
SHA256 1ae537e17171a8115cdb1ab3f62b23cbfb8defa8f2897c98ad2dea29c580684a
MD5 e011a1de05d7fdbc03bc425b75827034
BLAKE2b-256 0ab9bd04b14abd0f96100a3858415f1183ef7b148ade20389a0b9e324dc69957

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page