neurotools.spatial.fftzeros module
Code for identifying critical points in phase gradient maps.
- neurotools.spatial.fftzeros.plot_phase_gradient(dz, skip=1, lw=1, zorder=None, cmap='hsv')[source]
Plot a phase-gradient map using a hue wheel to show direction and local flow lines to indicate magnitude
- Parameters:
dz (np.array) – Complex-valued square np.array of phase gradient directions. The gradient in the first dimension (x) is in the real component, anf the second dimension (y) in the imaginary component.
- neurotools.spatial.fftzeros.plot_phase_direction(dz, skip=1, lw=1, zorder=None, cmap='hsv')[source]
Plot a phase-gradient map using a hue wheel to show direction and compass needles. Gradient magnitude is not shown.
- Parameters:
dz (complex128) – phase gradient
(int) (skip)
(numeric) (lw)
- neurotools.spatial.fftzeros.dPhidx(phase)[source]
Phase derivative in the x direction. The returned array is smaller than the input array by one row and column.
- Parameters:
phase (np.array) – two-dimensional array of phases in radians
- Returns:
phases differentiated along the x-axis (first dimension)
- Return type:
np.array
- neurotools.spatial.fftzeros.dPhidy(phase)[source]
Phase derivative in the y direction. The returned array is smaller than the input array by one row and column.
- Parameters:
phase (np.array) – two-dimensional array of phases in radians
- Returns:
phases differentiated along the y-axis (second dimension)
- Return type:
np.array
- neurotools.spatial.fftzeros.get_phase_gradient_as_complex(data)[source]
Computes the phase gradient across an array and stores it in a complex number, in analogy to the complex-valued analytic signal. The complex phase indicates gradient direction, and the amplitude gradient magnitude.
- Parameters:
data (np.array) – Complex-valued array of analytic signals
- Returns:
dx (np.float) – Derivative in the x direction (first dimension)
dy (np.float) – Derivative in the y direction (second dimension)
dz (np.complex1) – Phase gradient stored as a complex number
- neurotools.spatial.fftzeros.getpeaks2d(pp)[source]
This function differentiates the array pp in the x and y direction and then looks for zero crossings. It returns an array the same size as pp but with 1 at points that are local maxima and 0 else.
- Parameters:
pp (np.array) – a 2D array in which to search for local maxima
- Returns:
an array with 1 at points that are local maxima and 0 elsewhere.
- Return type:
np.array
- neurotools.spatial.fftzeros.coalesce(pp, s1=4, s2=None)[source]
Merge nearby peaks using Gaussian smoothing.
- Parameters:
pp (np.array) – Boolean array with 1 indicating peak locations.
S1 (float) – x axis smoothing scale
S2 (float) – y axis smoothing scale
- Returns:
pk – Boolean array with 1 indicating peak location. The smoothing will merge nearby peaks.
- Return type:
np.array
- neurotools.spatial.fftzeros.coalesce_points(pp, radius)[source]
Merge nearby peaks using nearest-neighbords
- Parameters:
pp (np.array) – Boolean array with 1 indicating peak locations.
radius (float) – Merge radius
- Returns:
pk – Boolean array with 1 indicating peak location. The smoothing will merge nearby peaks.
- Return type:
np.array
- neurotools.spatial.fftzeros.find_critical_points(data, docoalesce=False, radius=4.0, edgeavoid=None)[source]
- Parameters:
data (np.array) – 2D array of complex phase values
docoalesce (bool, False) – Whether to merge nearby critical points
radius (float, 4.0) – Merge radius to use if docoalesce is true
edgeavoid (float, None) – If not None, points edgeavoid distance to edge are omitted
- Returns:
clockwise (numpy.ndarray) – Point locations of centers of clockwise rotating waves
anticlockwise (numpy.ndarray) – Point locations of centers of antclockwise rotating waves
saddles (numpy.ndarray) – Saddle points in the phase gradient map
peaks (numpy.ndarray) – All local minima or maxima in the phase gradient map
maxima (numpy.ndarray) – Point locations of local maxima in the phase gradient
minima (numpy.ndarray) – Point locations of local minima in the phase gradient
- neurotools.spatial.fftzeros.plot_critical_points(data, lw=1, ss=14, skip=5, ff=None, plotsaddles=True, aspect='auto', extent=None)[source]
- Parameters:
data (np.array) – 2D complex-valued array of phases
lw (int, default=1) – line width for plotting
ss (int, default=14) – plotting point size
skip (int, default=5) – Skip every skip points when plotting phase direction map
ff – Unknown
plotsaddles (bool, defualt=True) – Whether to plot saddes points
aspect (string, default='auto') – Aspect-ratio parameter forwarded to matplotlib
extent (tuple or None (default)) – extent parameter forwarded to matplotlib
- neurotools.spatial.fftzeros.find_critical_potential_points(data)[source]
Critical points in a potential field (no centers / curl)
- Parameters:
data (numeric array, 2D, complex)
- Returns:
saddles (numpy.ndarray)
peaks (numpy.ndarray)
maxima (numpy.ndarray)
minima (numpy.ndarray)
- neurotools.spatial.fftzeros.get_critical_spectra(ff, wt)[source]
smt and smf are time and frequency smoothing scales in units of pixels
- neurotools.spatial.fftzeros.plot_critical_spectra(ff, wt, ss=5, aspect=None)[source]
smt and smf are time and frequency smoothing scales in units of pixels