neurotools.spatial.dct module

Discrete cosine transform methods. Primarily used with fftzeros code for finding critical points in phase gradient maps.

neurotools.spatial.dct.get_mask_antialiased(h_w, aa, spacing, cutoff)[source]

Computes a frequency space mask for (h,w) shaped domain with cutoff frequency and some anti-aliasing factor as specified by aa.

Parameters:
  • h (int) – height

  • w (int) – width

  • aa (int) – antialiasing supsampling factor

  • spacing (numeric) – array spacing in mm

  • cutoff (numeric) – cutoff scale in mm

  • Retruns – h*2 x w*2 symmetric mask to be used with DCT for smoothing

neurotools.spatial.dct.get_mask(h_w, spacing, cutoff)[source]
Parameters:
  • height – height of array

  • width – width of array

  • spacing – array spacing in mm

  • cutoff – scale in mm

return: h*2 x w*2 symmetric mask to be used with DCT for smoothing

neurotools.spatial.dct.dct_cut(data, cutoff, spacing=0.4)[source]

Low-pass filters image data by discarding high frequency Fourier components. Image data is reflected before being processes (i.e.) mirrored boundary conditions. TODO: I think there is some way to compute the mirrored conditions directly without copying the image data.

This function has been superseded by dct_cut_antialias, which is more accurate.

neurotools.spatial.dct.outer_complex(a, b)[source]

Not quite outer product, intead of a_i * b_k its a_i + 1j * b_k which I guess is like log(outer(exp(a_i),exp(1j*b)))

neurotools.spatial.dct.dct_cut_antialias(data, cutoff, spacing=0.4)[source]

Uses brute-force supsampling to anti-alias the frequency space sinc function, skirting numerical issues that derives either from attempting to evaulate the radial sinc function on a small 2D domain, or select a constant frequency cutoff in the frequency space.

neurotools.spatial.dct.dct_cut_downsampled(data, cutoff, spacing=0.4)[source]

like dctCut but also lowers the sampling rate, creating a compact representation from which the whole downsampled data could be recovered

neurotools.spatial.dct.dct_upsample(data, factor=2)[source]

Uses the DCT to supsample array data. Nice for visualization. Uses a discrete cosine transform to smoothly supsample image data. Boundary conditions are handeled as reflected.

Data is made symmetric, fourier transformed, then inserted into the low-frequency components of a larger array, which is then inverse transformed.

This could probably be optimized with a customized array implimentation to avoid the copying.

Parameters:
  • data (ndarray) – frist two dimensions should be height and width. data may contain aribtrary number of additional dimensions

  • factor (int) – supsampling factor.

Test code grid = arange(10)&1 grid = grid[None,:]^grid[:,None] amp = dct_upsample(grid,supSAMPLE).real

neurotools.spatial.dct.iterated_upsample(data, niter=1)[source]
neurotools.spatial.dct.dct_upsample_notrim(data, factor=2)[source]

Uses the DCT to supsample array data. Nice for visualization. Uses a discrete cosine transform to smoothly supsample image data. Boundary conditions are handeled as reflected.

Data is made symmetric, fourier transformed, then inserted into the low-frequency components of a larger array, which is then inverse transformed.

This could probably be optimized with a customized array implimentation to avoid the copying.

Parameters:
  • data (ndarray) – frist two dimensions should be height and width. data may contain aribtrary number of additional dimensions

  • factor (int) – supsampling factor.