psychopy.misc - miscellaneous routines for converting units etc
Tools, nothing to do with psychophysics or experiments
- just handy things like conversion functions etc...
-
psychopy.misc.array2image(a)
- Takes an array and returns an image object (PIL)
-
psychopy.misc.cart2pol(x, y, units='deg')
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
-
psychopy.misc.cm2deg(cm, monitor)
- Convert size in cm to size in degrees for a given Monitor object
-
psychopy.misc.cm2pix(cm, monitor)
- Convert size in degrees to size in pixels for a given Monitor object
-
psychopy.misc.deg2cm(degrees, monitor)
- Convert size in degrees to size in pixels for a given Monitor object
-
psychopy.misc.deg2pix(degrees, monitor)
- Convert size in degrees to size in pixels for a given Monitor object
-
psychopy.misc.extendArr(inArray, newSize)
- Takes a numpy array and returns it padded with zeros to the necessary size
-
psychopy.misc.float_uint16(inarray)
- Converts arrays, lists, tuples and floats ranging -1:1
into an array of Uint16s ranging 0:2^16
-
psychopy.misc.float_uint8(inarray)
- Converts arrays, lists, tuples and floats ranging -1:1
into an array of Uint8s ranging 0:255
-
psychopy.misc.fromFile(filename)
load data (of any sort) from a pickle file
simple wrapper of the cPickle module in core python
-
psychopy.misc.image2array(im)
Takes an image object (PIL) and returns an array
fredrik lundh, october 1998
fredrik@pythonware.com
http://www.pythonware.com
-
psychopy.misc.makeImageAuto(inarray)
- Combines float_uint8 and image2array operations
ie. scales a numeric array from -1:1 to 0:255 and
converts to PIL image format
-
psychopy.misc.pix2cm(pixels, monitor)
- Convert size in pixels to size in cm for a given Monitor object
-
psychopy.misc.pix2deg(pixels, monitor)
- Convert size in pixels to size in degrees for a given Monitor object
-
psychopy.misc.plotFrameIntervals(intervals)
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)
-
psychopy.misc.pol2cart(theta, radius, units='deg')
Convert from polar to cartesian coordinates
- usage:
- x,y = pol2cart(theta, radius, units=’deg’)
-
psychopy.misc.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.
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)
-
psychopy.misc.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. 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()
-
psychopy.misc.toFile(filename, data)
save data (of any sort) as a pickle file
simple wrapper of the cPickle module in core python
-
psychopy.misc.uint8_float(inarray)
- Converts arrays, lists, tuples and UINTs ranging 0:255
into an array of floats ranging -1:1