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

class psychopy.monitors.Monitor(name, width=None, distance=None, gamma=None, notes=None, useBits=None, verbose=True, currentCalib=None, autoLog=True)[source]

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 various

    fields 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)

_loadAll()[source]

Fetches the calibrations for this monitor from disk, storing them as self.calibs

copyCalib(calibName=None)[source]

Stores the settings for the current calibration settings as new monitor.

delCalib(calibName)[source]

Remove a specific calibration from the current monitor. Won’t be finalised unless monitor is saved

gammaIsDefault()[source]

Determine whether we’re using the default gamma values

getCalibDate()[source]

As a python date object (convert to string using calibTools.strFromDate

getDKL_RGB(RECOMPUTE=False)[source]

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.

getDistance()[source]

Returns distance from viewer to the screen in cm, or None if not known

getGamma()[source]

Returns just the gamma value (not the whole grid)

getGammaGrid()[source]

Gets the min,max,gamma values for the each gun

getLMS_RGB(recompute=False)[source]

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.

getLevelsPost()[source]

Gets the measured luminance values from last calibration TEST

getLevelsPre()[source]

Gets the measured luminance values from last calibration

getLinearizeMethod()[source]

Gets the method that this monitor is using to linearize the guns

getLumsPost()[source]

Gets the measured luminance values from last calibration TEST

getLumsPre()[source]

Gets the measured luminance values from last calibration

getMeanLum()[source]

Returns the mean luminance of the screen if explicitly stored

getNotes()[source]

Notes about the calibration

getPsychopyVersion()[source]

Returns the version of PsychoPy that was used to create this calibration

getSizePix()[source]

Returns the size of the current calibration in pixels, or None if not defined

getSpectra()[source]

Gets the wavelength values from the last spectrometer measurement (if available)

usage:
  • nm, power = monitor.getSpectra()

getUseBits()[source]

Was this calibration carried out with a bits++ box

getWidth()[source]

Of the viewable screen in cm, or None if not known

lineariseLums(desiredLums, newInterpolators=False, overrideGamma=None)[source]

Equivalent of linearizeLums().

linearizeLums(desiredLums, newInterpolators=False, overrideGamma=None)[source]

lums should be uncalibrated luminance values (e.g. a linear ramp) ranging 0:1

newCalib(calibName=None, width=None, distance=None, gamma=None, notes=None, useBits=False, verbose=True)[source]

create a new (empty) calibration for this monitor and makes this the current calibration

save()[source]

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).

saveMon()[source]

Equivalent of save().

setCalibDate(date=None)[source]

Sets the current calibration to have a date/time or to the current date/time if none given. (Also returns the date as set)

setCurrent(calibration=-1)[source]

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.

setDKL_RGB(dkl_rgb)[source]

Sets the DKL->RGB conversion matrix for a chromatically calibrated monitor (matrix is a 3x3 num array).

setDistance(distance)[source]

To the screen (cm)

setGamma(gamma)[source]

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)

setGammaGrid(gammaGrid)[source]

Sets the min,max,gamma values for the each gun

setLMS_RGB(lms_rgb)[source]

Sets the LMS->RGB conversion matrix for a chromatically calibrated monitor (matrix is a 3x3 num array).

setLevelsPost(levels)[source]

Sets the last set of luminance values measured AFTER calibration

setLevelsPre(levels)[source]

Sets the last set of luminance values measured during calibration

setLineariseMethod(method)[source]

Sets the method for linearising 0 uses y=a+(bx)^gamma 1 uses y=(a+bx)^gamma 2 uses linear interpolation over the curve

setLumsPost(lums)[source]

Sets the last set of luminance values measured AFTER calibration

setLumsPre(lums)[source]

Sets the last set of luminance values measured during calibration

setMeanLum(meanLum)[source]

Records the mean luminance (for reference only)

setNotes(notes)[source]

For you to store notes about the calibration

setPsychopyVersion(version)[source]

To store the version of PsychoPy that this calibration used

setSizePix(pixels)[source]

Set the size of the screen in pixels x,y

setSpectra(nm, rgb)[source]

Sets the phosphor spectra measured by the spectrometer

setUseBits(usebits)[source]

DEPRECATED: Use the new hardware classes to control these devices

setWidth(width)[source]

Of the viewable screen (cm)


GammaCalculator

class psychopy.monitors.GammaCalculator(inputs=(), lums=(), gamma=None, bitsIN=8, bitsOUT=8, eq=1)[source]

Class for managing gamma tables

Parameters:

  • inputs (required)= values at which you measured screen luminance either

    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

fitGammaErrFun(params, x, y, minLum, maxLum)[source]

Provides an error function for fitting gamma function

(used by fitGammaFun)

fitGammaFun(x, y)[source]

Fits a gamma function to the monitor calibration data.

Parameters:

-xVals are the monitor look-up-table vals, either 0-255 or 0.0-1.0 -yVals are the measured luminances from a photometer/spectrometer


getAllMonitors()

psychopy.monitors.getAllMonitors()[source]

Find the names of all monitors for which calibration files exist

getLumSeriesPR650()

psychopy.monitors.getLumSeriesPR650(lumLevels=8, winSize=(800, 600), monitor=None, gamma=1.0, allGuns=True, useBits=False, autoMode='auto', stimSize=0.3, photometer='COM1')[source]

DEPRECATED (since v1.60.01): Use psychopy.monitors.getLumSeries() instead

getRGBspectra()

psychopy.monitors.getRGBspectra(stimSize=0.3, winSize=(800, 600), photometer='COM1')[source]
usage:

getRGBspectra(stimSize=0.3, winSize=(800,600), photometer=’COM1’)

Params:
  • ‘photometer’ could be a photometer object or a serial port name on which a photometer might be found (not recommended)

gammaFun()

psychopy.monitors.gammaFun(xx, minLum, maxLum, gamma, eq=1, a=None, b=None, k=None)[source]

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()

psychopy.monitors.gammaInvFun(yy, minLum, maxLum, gamma, b=None, eq=1)[source]

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()

psychopy.monitors.makeDKL2RGB(nm, powerRGB)[source]

Creates a 3x3 DKL->RGB conversion matrix from the spectral input powers

makeLMS2RGB()

psychopy.monitors.makeLMS2RGB(nm, powerRGB)[source]

Creates a 3x3 LMS->RGB conversion matrix from the spectral input powers


Back to top