psychopy.filters
- helper functions for creating filters¶This module has moved to psychopy.visual.filters but you can still (currently) import it as psychopy.filters
Various useful functions for creating filters and textures (e.g. for PatchStim)
Bandpass Butterworth filter in two dimensions.
size of the filter
relative cutin frequency of the filter (0 - 1.0)
relative cutoff frequency of the filter (0 - 1.0)
order of the filter, the higher n is the sharper the transition is.
filter kernel in 2D centered
Highpass Butterworth filter in two dimensions.
size of the filter
relative cutoff frequency of the filter (0 - 1.0)
order of the filter, the higher n is the sharper the transition is.
filter kernel in 2D centered
Create lowpass 2D Butterworth filter.
size of the filter
relative cutoff frequency of the filter (0 - 1.0)
order of the filter, the higher n is the sharper the transition is.
filter kernel in 2D centered
Butterworth lowpass filter of any elliptical shape.
size of the filter
relative cutoff frequency of the filter (0 - 1.0) for x and y axes
rotation angle (in radians)
offsets for the ellipsoid
order of the filter, the higher n is the sharper the transition is.
filter kernel in 2D centered
Convolve a pair of 2d numpy matrices.
Uses fourier transform method, so faster if larger matrix has dimensions of size 2**n
Actually right now the matrices must be the same size (will sort out padding issues another day!)
Returns the RMS contrast (the sample standard deviation) of a array
Return the gaussian distribution for a given set of x-vals
x – should be x and y indexes as might be created by numpy.mgrid
y – should be x and y indexes as might be created by numpy.mgrid
mean (float) – the centre of the distribution - may be a tuple
sd (float) – the width of the distribution - may be a tuple
gain (float) – the height of the distribution
base (float) – an offset added to the result
Return the gaussian distribution for a given set of x-vals
the centre of the distribution
the width of the distribution
the height of the distribution
an offset added to the result
Make an array containing a luminance grating of the specified params
the size of the resulting matrix on both dimensions (e.g 256)
the orientation of the grating in degrees
the number of grating cycles within the array
the phase of the grating in degrees (NB this differs to most PsychoPy phase arguments which use units of fraction of a cycle)
the type of grating to be ‘drawn’
contrast of the grating
a square numpy array of size resXres
Returns a matrix to be used as an alpha mask (circle,gauss,ramp).
the size of the resulting matrix on both dimensions (e.g 256)
‘raisedCosine’ (the edges are blurred by a raised cosine) shape of the mask
scale factor to be applied to the mask (circle with radius of [1,1] will extend just to the edge of the matrix). Radius can asymmetric, e.g. [1.0,2.0] will be wider than it is tall.
the centre of the mask in the matrix ([1,1] is top-right corner, [-1,-1] is bottom-left)
The proportion of the raisedCosine that is being blurred.
The minimum and maximum value in the mask matrix
Generate a square matrix where each element values is its distance from the centre of the matrix.
matrixSize (int) – Matrix size. Corresponds to the number of elements along each dimension. Must be >0.
radius (float) – scale factor to be applied to the mask (circle with radius of [1,1] will extend just to the edge of the matrix). Radius can be asymmetric, e.g. [1.0,2.0] will be wider than it is tall.
center (2x1 tuple or list (default=[0.0,0.0])) – the centre of the mask in the matrix ([1,1] is top-right corner, [-1,-1] is bottom-left)
Square matrix populated with distance values and size == (matrixSize, matrixSize).
ndarray
Make and apply a mask to an input matrix (e.g. a grating)
array to which the mask should be applied
shape of the mask
scale factor to be applied to the mask (circle with radius of [1,1] will extend just to the edge of the matrix). Radius can be asymmetric, e.g. [1.0,2.0] will be wider than it is tall.
the centre of the mask in the matrix ([1,1] is top-right corner, [-1,-1] is bottom-left)