Package psychopy :: Module misc
[frames] | no frames]

Module misc

source code

Tools, nothing to do with psychophysics or experiments - just handy things like conversion functions etc...
Functions
 
toFile(filename, data)
save data (of any sort) as a pickle file
source code
 
fromFile(filename)
load data (of any sort) from a pickle file
source code
 
radians(degrees) source code
 
shuffleArray(inArray, shuffleAxis=-1, seed=None)
Takes a (flat) num array, list or string and returns a shuffled version as a num array with the same shape.
source code
 
extendArr(inArray, newSize)
Takes a numpy array and returns it padded with zeros to the necessary size
source code
 
ratioRange(start, nSteps=None, stop=None, stepRatio=None, stepdB=None, stepLogUnits=None)
Creates a array where each step is a constant ratio rather than a constant addition.
source code
 
makeImageAuto(inarray)
Combines float_uint8 and image2array operations ie.
source code
 
image2array(im)
Takes an image object (PIL) and returns an array
source code
 
array2image(a)
Takes an array and returns an image object (PIL)
source code
 
float_uint8(inarray)
Converts arrays, lists, tuples and floats ranging -1:1 into an array of Uint8s ranging 0:255
source code
 
uint8_float(inarray)
Converts arrays, lists, tuples and UINTs ranging 0:255 into an array of floats ranging -1:1
source code
 
float_uint16(inarray)
Converts arrays, lists, tuples and floats ranging -1:1 into an array of Uint16s ranging 0:2^16
source code
 
sph2cart(*args) source code
 
pix2deg(pixels, monitor)
Convert size in pixels to size in degrees for a given Monitor object
source code
 
deg2pix(degrees, monitor)
Convert size in degrees to size in pixels for a given Monitor object
source code
 
deg2cm(degrees, monitor)
Convert size in degrees to size in pixels for a given Monitor object
source code
 
cm2deg(cm, monitor)
Convert size in cm to size in degrees for a given Monitor object
source code
 
pix2cm(pixels, monitor)
Convert size in pixels to size in cm for a given Monitor object
source code
 
cm2pix(cm, monitor)
Convert size in degrees to size in pixels for a given Monitor object
source code
 
dkl2rgb(dkl_Nx3, conversionMatrix=None) source code
 
lms2rgb(lms_Nx3, conversionMatrix=None) source code
 
pol2cart(theta, radius, units='deg')
Convert from polar to cartesian coordinates
source code
 
cart2pol(x, y, units='deg')
Convert from cartesian to polar coordinates
source code
 
plotFrameIntervals(intervals)
Plot a histogram of the frame intervals.
source code
Function Details

toFile(filename, data)

source code 

save data (of any sort) as a pickle file

simple wrapper of the cPickle module in core python

fromFile(filename)

source code 

load data (of any sort) from a pickle file

simple wrapper of the cPickle module in core python

shuffleArray(inArray, shuffleAxis=-1, seed=None)

source code 

Takes a (flat) num array, list or string and returns a shuffled version as a num array with the same shape. Optional argument ShuffleAxis determines the axis to shuffle along (default=-1 meaning shuffle across entire matrix?)

THIS DOESN'T WORK WITH MATRICES YET - ONLY FLAT ARRAYS - APPEARS TO BE BUG IN EITHER NUMPY.ARGSORT() OR NUMPY.TAKE()

ratioRange(start, nSteps=None, stop=None, stepRatio=None, stepdB=None, stepLogUnits=None)

source code 

Creates a array where each step is a constant ratio rather than a constant addition.

Specify start and any 2 of, nSteps, stop, stepRatio, stepdB, stepLogUnits

examples (all return [1, 2, 4, 8]):
rangeRatio(1,nSteps=4,stop=8) rangeRatio(1,nSteps=4,stepRatio=2) rangeRatio(1,stop=8,stepRatio=2)

makeImageAuto(inarray)

source code 
Combines float_uint8 and image2array operations ie. scales a numeric array from -1:1 to 0:255 and converts to PIL image format

image2array(im)

source code 

Takes an image object (PIL) and returns an array

fredrik lundh, october 1998

fredrik@pythonware.com http://www.pythonware.com

pol2cart(theta, radius, units='deg')

source code 

Convert from polar to cartesian coordinates

usage:
x,y = pol2cart(theta, radius, units='deg')

cart2pol(x, y, units='deg')

source code 

Convert from cartesian to polar coordinates

usage:
theta, radius = pol2cart(x, y, units='deg')

units refers to the units (rad or deg) for theta that should be returned

plotFrameIntervals(intervals)

source code 

Plot a histogram of the frame intervals.

Arguments:
  • intervals: Either a filename to a log file, saved by Window.saveFrameIntervals

    or simply a list (or array of frame intervals)