psychopy.monitors
- for those that don’t like Monitor Center¶Most users won’t need to use the code here. In general the Monitor Centre interface is sufficient
and monitors setup that way can be passed as strings to Window
s. If there
is some aspect of the normal calibration that you wish to override. eg:
from psychopy import visual, monitors
mon = monitors.Monitor('SonyG55')#fetch the most recent calib for this monitor
mon.setDistance(114)#further away than normal?
win = visual.Window(size=[1024,768], monitor=mon)
You might also want to fetch the Photometer
class for conducting your own calibrations
Monitor
¶Creates a monitor object for storing calibration details. This will be loaded automatically from disk if the monitor name is already defined (see methods).
Many settings from the stored monitor can easily be overridden either by adding them as arguments during the initial call.
arguments:
width, distance, gamma
are details about the calibration
notes
is a text field to store any useful info
useBits
True, False, None
verbose
True, False, None
currentCalib
is a dictionary object containing variousfields for a calibration. Use with caution since the dictionary may not contain all the necessary fields that a monitor object expects to find.
eg:
myMon = Monitor('sony500', distance=114)
Fetches the info on the sony500 and overrides its usual distance
to be 114cm for this experiment.
These can be saved to the monitor file using
save()
or not (in which case the changes will be lost)
Fetches the calibrations for this monitor from disk, storing them as self.calibs
Stores the settings for the current calibration settings as new monitor.
Remove a specific calibration from the current monitor. Won’t be finalised unless monitor is saved
Returns the DKL->RGB conversion matrix. If one has been saved this will be returned. Otherwise, if power spectra are available for the monitor a matrix will be calculated.
Returns the LMS->RGB conversion matrix. If one has been saved this will be returned. Otherwise (if power spectra are available for the monitor) a matrix will be calculated.
Returns the version of PsychoPy that was used to create this calibration
Gets the wavelength values from the last spectrometer measurement (if available)
nm, power = monitor.getSpectra()
Equivalent of linearizeLums()
.
lums should be uncalibrated luminance values (e.g. a linear ramp) ranging 0:1
create a new (empty) calibration for this monitor and makes this the current calibration
Save the current calibrations to disk.
This will write a json file to the monitors subfolder of your PsychoPy configuration folder (typically ~/.psychopy3/monitors on Linux and macOS, and %APPDATA%psychopy3monitors on Windows).
Sets the current calibration to have a date/time or to the current date/time if none given. (Also returns the date as set)
Sets the current calibration for this monitor. Note that a single file can hold multiple calibrations each stored under a different key (the date it was taken)
The argument is either a string (naming the calib) or an integer eg:
myMon.setCurrent('mainCalib')
fetches the calibration named mainCalib. You can name calibrations what you want but PsychoPy will give them names of date/time by default. In Monitor Center you can ‘copy…’ a calibration and give it a new name to keep a second version.
calibName = myMon.setCurrent(0)
fetches the first calibration (alphabetically) for this monitor
calibName = myMon.setCurrent(-1)
fetches the last alphabetical calibration for this monitor (this is default). If default names are used for calibrations (ie date/time stamp) then this will import the most recent.
Sets the DKL->RGB conversion matrix for a chromatically calibrated monitor (matrix is a 3x3 num array).
Sets the gamma value(s) for the monitor. This only uses a single gamma value for the three guns, which is fairly approximate. Better to use setGammaGrid (which uses one gamma value for each gun)
Sets the LMS->RGB conversion matrix for a chromatically calibrated monitor (matrix is a 3x3 num array).
GammaCalculator
¶Class for managing gamma tables
Parameters:
in range 0.0:1.0, or range 0:255. Should include the min and max of the monitor
Then give EITHER “lums” or “gamma”:
lums = measured luminance at given input levels
gamma = your own gamma value (single float)
bitsIN = number of values in your lookup table
bitsOUT = number of bits in the DACs
myTable.gammaModel myTable.gamma
getAllMonitors()
¶getLumSeriesPR650()
¶getRGBspectra()
¶gammaFun()
¶Returns gamma-transformed luminance values. y = gammaFun(x, minLum, maxLum, gamma)
a and b are calculated directly from minLum, maxLum, gamma
Parameters:
xx are the input values (range 0-255 or 0.0-1.0)
minLum = the minimum luminance of your monitor
maxLum = the maximum luminance of your monitor (for this gun)
gamma = the value of gamma (for this gun)
gammaInvFun()
¶Returns inverse gamma function for desired luminance values. x = gammaInvFun(y, minLum, maxLum, gamma)
a and b are calculated directly from minLum, maxLum, gamma Parameters:
xx are the input values (range 0-255 or 0.0-1.0)
minLum = the minimum luminance of your monitor
maxLum = the maximum luminance of your monitor (for this gun)
gamma = the value of gamma (for this gun)
- eq determines the gamma equation used;
eq==1[default]: yy = a + (b * xx)**gamma eq==2: yy = (a + b*xx)**gamma
makeDKL2RGB()
¶makeLMS2RGB()
¶