Tools, nothing to do with psychophysics or experiments - just handy things like conversion functions etc...
Takes an array and returns an image object (PIL)
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
Convert size in cm to size in degrees for a given Monitor object
Convert size in degrees to size in pixels for a given Monitor object
Create an Nx2 array of XY values including all combinations of the x and y values provided.
>>> createXYs(x=[1,2,3],y=[4,5,6])
array([[1, 4],
[2, 4],
[3, 4],
[1, 5],
[2, 5],
[3, 5],
[1, 6],
[2, 6],
[3, 6]])
>>> createXYs(x=[1,2,3]) #assumes y=x
array([[1, 1],
[2, 1],
[3, 1],
[1, 2],
[2, 2],
[3, 2],
[1, 3],
[2, 3],
[3, 3]])
Convert size in degrees to size in pixels for a given Monitor object
Convert size in degrees to size in pixels for a given Monitor object
Convert from DKL color space (cone-opponent space from Derrington, Krauskopf & Lennie) to RGB.
Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that this will not be an accurate representation of the color space unless you supply a conversion matrix).
usage:
rgb(Nx3) = dkl2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
Like dkl2rgb except that it uses cartesian coords (LM,S,LUM) rather than spherical coords for DKL (elev, azim, contr)
NB: this may return rgb values >1 or <-1
Takes a numpy array and returns it padded with zeros to the necessary size
>>> misc.extendArr([1,2,3],5)
array([1, 2, 3, 0, 0])
Converts arrays, lists, tuples and floats ranging -1:1 into an array of Uint16s ranging 0:2^16
Converts arrays, lists, tuples and floats ranging -1:1 into an array of Uint8s ranging 0:255
>>> float_uint8(-1)
0
>>> float_uint8(0)
128
load data (of any sort) from a pickle file
simple wrapper of the cPickle module in core python
Takes an image object (PIL) and returns a numpy array
Convert from cone space (Long, Medium, Short) to RGB.
Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that you will not get an accurate representation of the color space unless you supply a conversion matrix)
usage:
rgb(Nx3) = lms2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
Combines float_uint8 and image2array operations ie. scales a numeric array from -1:1 to 0:255 and converts to PIL image format
Merge a folder into another.
Existing files in dst with the same name will be overwritten. Non-existent files/folders will be created.
Convert size in pixels to size in cm for a given Monitor object
Convert size in pixels to size in degrees for a given Monitor object
Plot a histogram of the frame intervals.
Where intervals is either a filename to a file, saved by Window.saveFrameIntervals or simply a list (or array) of frame intervals
Convert from polar to cartesian coordinates
usage:
x,y = pol2cart(theta, radius, units='deg')
Convert degrees to radians
>>> radians(180)
3.1415926535897931
>>> degrees(45)
0.78539816339744828
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
>>> ratioRange(1,nSteps=4,stop=8)
array([ 1., 2., 4., 8.])
>>> ratioRange(1,nSteps=4,stepRatio=2)
array([ 1., 2., 4., 8.])
>>> ratioRange(1,stop=8,stepRatio=2)
array([ 1., 2., 4., 8.])
Convert an RGB image into Cartesian DKL space
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()
Convert from spherical coordinates (elevation, azimuth, radius) to cartesian (x,y,z)
save data (of any sort) as a pickle file
simple wrapper of the cPickle module in core python
Converts arrays, lists, tuples and UINTs ranging 0:255 into an array of floats ranging -1:1