ALLEN INSTITUTE

# bmtk.simulator.filternet.lgnmodel package

## Submodules

## bmtk.simulator.filternet.lgnmodel.cellmetrics module

class bmtk.simulator.filternet.lgnmodel.cellmetrics.SubclassMetricsCache(saved_metrics_dir=None)

  Bases: `object`

  Used to calc optimized parameteres for different types of cells using existing data that contains cell responses to different types of stimulus. The existing data should be stored in a single directory with a csv file for reach cell type.

  usage:

    subcell_metrics = SubclassMetricsCache(‘/path/to/observations/’)

  get_metrics(subclass_type)

    Calculates various parameters for a given cell class, using observations stored in saved_metrics_dir

    Parameters:

      subclass_type – name of cell subclass types

    Returns:

      A dictionary of parameters for various types of inputs

  classmethod load_dir(saved_metrics_dir=None)
  property saved_metrics_dir

bmtk.simulator.filternet.lgnmodel.cellmetrics.get_data_metrics_for_each_subclass(ctype)

## bmtk.simulator.filternet.lgnmodel.cellmodel module

class bmtk.simulator.filternet.lgnmodel.cellmodel.LGNOnOffCell(on_filter, off_filter, transfer_function=<bmtk.simulator.filternet.lgnmodel.transferfunction.MultiTransferFunction object>)

  Bases: `MultiLNUnit`

  A cell model for a OnOff cell

class bmtk.simulator.filternet.lgnmodel.cellmodel.OffUnit(linear_filter, transfer_function)

  Bases: `LNUnit`

class bmtk.simulator.filternet.lgnmodel.cellmodel.OnUnit(linear_filter, transfer_function)

  Bases: `LNUnit`

class bmtk.simulator.filternet.lgnmodel.cellmodel.TwoSubfieldLinearCell(dominant_filter, nondominant_filter, subfield_separation=10, onoff_axis_angle=45, dominant_subfield_location=(30, 40), transfer_function=<bmtk.simulator.filternet.lgnmodel.transferfunction.MultiTransferFunction object>)

  Bases: `MultiLNUnit`

## bmtk.simulator.filternet.lgnmodel.cursor module

class bmtk.simulator.filternet.lgnmodel.cursor.FilterCursor(spatiotemporal_filter, movie, threshold=0)

  Bases: `KernelCursor`

class bmtk.simulator.filternet.lgnmodel.cursor.KernelCursor(kernel, movie)

  Bases: `object`

  A class that takes care of the convolution of the (non-separable) spatial-temporal linear filter with the move.

  apply_dot_product(ti_offset)
  property col_range
  evaluate(t_min=None, t_max=None, downsample=1)
  property frame_rate
  property row_range
  property t_range

class bmtk.simulator.filternet.lgnmodel.cursor.LNUnitCursor(lnunit, movie, threshold=0)

  Bases: `KernelCursor`

  A class that takes care of applying a linear-nonlinear filter to a movie. Parent class is used to apply the spatial-termporal filter convolution to the movie, when then the lnunit non-linear transfer function is applied.

class bmtk.simulator.filternet.lgnmodel.cursor.MultiLNUnitCursor(multi_lnunit, movie, threshold=0)

  Bases: `object`

  evaluate(**kwargs)

class bmtk.simulator.filternet.lgnmodel.cursor.MultiLNUnitMultiMovieCursor(multi_lnunit, movie_list, threshold=0.0)

  Bases: `MultiLNUnitCursor`

class bmtk.simulator.filternet.lgnmodel.cursor.SeparableKernelCursor(spatial_kernel, temporal_kernel, movie)

  Bases: `object`

  A class for applying a spatial-temporal convolution to a movie. Unlike the KernelCursor the spatial-temporal filter is broken up into its components, spatial filter is applied then followed by a temporal filter convolution.

  evaluate(threshold=0)

class bmtk.simulator.filternet.lgnmodel.cursor.SeparableLNUnitCursor(lnunit, movie)

  Bases: `SeparableSpatioTemporalFilterCursor`

  evaluate(downsample=1)

class bmtk.simulator.filternet.lgnmodel.cursor.SeparableMultiLNUnitCursor(multilnunit, movie)

  Bases: `object`

  evaluate(*args, **kwargs)

class bmtk.simulator.filternet.lgnmodel.cursor.SeparableSpatioTemporalFilterCursor(spatiotemporal_filter, movie)

  Bases: `SeparableKernelCursor`

bmtk.simulator.filternet.lgnmodel.cursor.kernel_dot_product(movie_data, ti_offset, kernel_t_inds, kernel_row_inds, kernel_col_inds, kernel_kernel)

## bmtk.simulator.filternet.lgnmodel.fitfuns module

bmtk.simulator.filternet.lgnmodel.fitfuns.ff(x, c, dc)

bmtk.simulator.filternet.lgnmodel.fitfuns.invnl(x)

bmtk.simulator.filternet.lgnmodel.fitfuns.makeBasis_StimKernel(kbasprs, nkt)

bmtk.simulator.filternet.lgnmodel.fitfuns.makeBasis_StimKernel_exp(kbasprs, nkt)

bmtk.simulator.filternet.lgnmodel.fitfuns.makeFitStruct_GLM(dtsim, kbasprs, nkt, flag_exp)

bmtk.simulator.filternet.lgnmodel.fitfuns.nlin(x)

bmtk.simulator.filternet.lgnmodel.fitfuns.normalizecols(A)

bmtk.simulator.filternet.lgnmodel.fitfuns.sameconv(A, B)

## bmtk.simulator.filternet.lgnmodel.gaborfilter module

class bmtk.simulator.filternet.lgnmodel.gaborfilter.GaborFilter(translate=4.0, sigma_f=1.0, sigma_t=1.0, theta=0.0, Lambda=1.0, psi=0.0, amplitude=1.0, direction=1)

  Bases: `object`

  get_kernel(row_range, col_range, threshold_rel=0.05)

    Creates a 2D gaussian filter (kernel) for the given dimensions which can be used

    Parameters:

      - row_range – array of times

      - col_range – array of frequency centers

      - threshold_rel – crop filter to region with amplitudes greater than threshold_rel * max value

    Returns:

      A Kernel2D object

  imshow(row_range, col_range, threshold=0, **kwargs)
  to_dict()

## bmtk.simulator.filternet.lgnmodel.kernel module

class bmtk.simulator.filternet.lgnmodel.kernel.Kernel1D(t_range, kernel_array, threshold=0.0, reverse=False)

  Bases: `object`

  full(truncate_t=True)
  imshow(ax=None, show=True, save_file_name=None, ylim=None, xlim=None, color='b', reverse=True)
  normalize()
  rescale()

class bmtk.simulator.filternet.lgnmodel.kernel.Kernel2D(row_range, col_range, row_inds, col_inds, kernel)

  Bases: `object`

  apply_threshold(threshold)
  classmethod copy(instance)
  classmethod from_dense(row_range, col_range, kernel_array, threshold=0.0)
  full(truncate_col=False)
  imshow(ax=None, show=True, save_file_name=None, clim=None, colorbar=True, truncate_col=False, xlabel=None, ylabel=None)
  normalize()
  normalize2(remove_offset=True)
  rescale()

class bmtk.simulator.filternet.lgnmodel.kernel.Kernel3D(row_range, col_range, t_range, row_inds, col_inds, t_inds, kernel)

  Bases: `object`

  apply_threshold(threshold)
  classmethod copy(instance)
  full(truncate_t=True)
  imshow(ax=None, t_range=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, N=10, show=True, save_file_name=None, kvals=None)
  normalize()
  rescale()
  t_slice(t)

bmtk.simulator.filternet.lgnmodel.kernel.find_l_r_in_t_range(t_range, t)

bmtk.simulator.filternet.lgnmodel.kernel.get_contour(X, Y, Z, c)

bmtk.simulator.filternet.lgnmodel.kernel.merge_spatial_temporal(spatial_kernel, temporal_kernel, threshold=0)

bmtk.simulator.filternet.lgnmodel.kernel.plot_single_contour(ax, x_contour, y_contour, t, color)

## bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor module

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_lattice_unit(lattice_unit_center=None)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_overlapping_onoff_cell_list(lattice_unit_center)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_sOFF_cell_list(lattice_unit_center)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_sON_cell_list(lattice_unit_center)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_separate_onoff_cell_list(lattice_unit_center)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_tOFF_cell_list(lattice_unit_center)

bmtk.simulator.filternet.lgnmodel.lattice_unit_constructor.make_tON_cell_list(lattice_unit_center)

## bmtk.simulator.filternet.lgnmodel.lgnmodel1 module

class bmtk.simulator.filternet.lgnmodel.lgnmodel1.LGNModel(cell_list)

  Bases: `object`

  evaluate(movie, **kwargs)

bmtk.simulator.filternet.lgnmodel.lgnmodel1.heat_plot(evaluate_result, ax=None, show=True, save_file_name=None, colorbar=True, **kwargs)

bmtk.simulator.filternet.lgnmodel.lgnmodel1.line_plot(evaluate_result, ax=None, show=True, save_file_name=None, xlabel=None, plotstyle=None)

## bmtk.simulator.filternet.lgnmodel.linearfilter module

class bmtk.simulator.filternet.lgnmodel.linearfilter.SpatioTemporalFilter(spatial_filter, temporal_filter, amplitude=1.0)

  Bases: `object`

  get_spatiotemporal_kernel(row_range, col_range, t_range=None, threshold=0, reverse=False)
  show_spatial_filter(*args, **kwargs)
  show_temporal_filter(*args, **kwargs)
  t_slice(t, *args, **kwargs)
  to_dict()

class bmtk.simulator.filternet.lgnmodel.linearfilter.SpectroTemporalFilter(spectrotemporal_filter, amplitude=1.0)

  Bases: `object`

  get_spectrotemporal_kernel(freq_range, t_range, threshold=0, reverse=False)
  show_spatial_filter(*args, **kwargs)
  show_temporal_filter(*args, **kwargs)
  t_slice(t, *args, **kwargs)
  to_dict()

## bmtk.simulator.filternet.lgnmodel.lnunit module

class bmtk.simulator.filternet.lgnmodel.lnunit.LNUnit(linear_filter, transfer_function, amplitude=1.0)

  Bases: `object`

  evaluate(movie, **kwargs)
  get_cursor(movie, threshold=0, separable=False)
  get_spatiotemporal_kernel(*args, **kwargs)
  get_spectrotemporal_kernel(*args, **kwargs)
  show_spatial_filter(*args, **kwargs)
  show_temporal_filter(*args, **kwargs)
  to_dict()

class bmtk.simulator.filternet.lgnmodel.lnunit.MultiLNUnit(lnunit_list, transfer_function)

  Bases: `object`

  evaluate(movie, **kwargs)
  get_cursor(*args, **kwargs)
  get_spatiotemporal_kernel(*args, **kwargs)
  show_spatial_filter(*args, **kwargs)
  show_temporal_filter(*args, **kwargs)

## bmtk.simulator.filternet.lgnmodel.make_cell_list module

bmtk.simulator.filternet.lgnmodel.make_cell_list.evaluate_cell_and_plot(input_cell, input_movie, ax, show=False)

bmtk.simulator.filternet.lgnmodel.make_cell_list.make_on_off_cell_list(number_of_cells=None, lattice_unit_center=None, weights_on=None, weights_off=None, kpeaks_on=None, kpeaks_off=None, delays_on=None, delays_off=None, amplitude_on=None, amplitude_off=None, sigma_on=None, sigma_off=None, subfield_separation=None, ang=None, dominant_subunit=None, width=5, transfer_function_str='Heaviside(x)*x + Heaviside(y)*y')

bmtk.simulator.filternet.lgnmodel.make_cell_list.make_single_unit_cell_list(number_of_cells=None, lattice_unit_center=None, weights=None, kpeaks=None, delays=None, amplitude=None, sigma=None, width=5, transfer_function_str='Heaviside(s)*s')

bmtk.simulator.filternet.lgnmodel.make_cell_list.multi_cell_random_generator(cell_creation_function=None, **kwargs)

## bmtk.simulator.filternet.lgnmodel.movie module

class bmtk.simulator.filternet.lgnmodel.movie.FullFieldFlashMovie(row_range, col_range, t_on, t_off, max_intensity=1, frame_rate=24)

  Bases: `FullFieldMovie`

class bmtk.simulator.filternet.lgnmodel.movie.FullFieldMovie(f, rows, cols, frame_rate=24.0)

  Bases: `Movie`

  create_movie(t_max, t_min=0.0)
  property data
  property frame_rate
  full(t_min=0.0, t_max=None)

class bmtk.simulator.filternet.lgnmodel.movie.GratingMovie(row_size, col_size, frame_rate=1000.0)

  Bases: `Movie`

  create_movie(t_min=0, t_max=1, gray_screen_dur=0, cpd=0.05, temporal_f=4, theta=45, phase=0.0, contrast=1.0, degrees_per_pixel=None, row_size_new=None, col_size_new=None)

    Create the grating movie with the desired parameters

    Parameters:

      - t_min – start time in seconds

      - t_max – end time in seconds

      - gray_screen_dur – Duration of gray screen before grating stimulus starts

      - cpd – cycles per degree

      - temporal_f – in Hz

      - theta – orientation angle, in degrees

      - phase – temporal phase, in degrees

      - contrast – the maximum constrast, must be between 0 and 1.0

      - degrees_per_pixel – pixel pitch of the movie in degrees (default (if None) is 1.0/(cpd*10))

      - row_size_new – Use to truncate screen, by default leaves original row dimension

      - col_size_new – Use to truncate screen, by default leaves original col dimension

    Returns:

      Movie object of grating with desired parameters

class bmtk.simulator.filternet.lgnmodel.movie.LoomingMovie(row_size, col_size, frame_rate=1000.0)

  Bases: `Movie`

  create_movie(t_looming=1, gray_screen_dur=0.5)

    Create the looming movie with the desired parameters

    Parameters:

      - t_looming – duration of time looming

      - gray_screen_dur

class bmtk.simulator.filternet.lgnmodel.movie.Movie(data, row_range=None, col_range=None, labels=('time', 'y', 'x'), units=('second', 'pixel', 'pixel'), frame_rate=None, t_range=None, padding=False)

  Bases: `object`

  imshow(t, show=True, vmin=-1, vmax=1, cmap=None)
  imshow_summary(ax=None, show=True, xlabel=None)
  static normalize_matrix(m_data, domain=None)

    Attempts to take a numpy matrix “movie” and normalize the contrast values to range [-1.0, 1.0].

    Parameters:

      - m_data – A numpy matrix TxRxC containing an original “movie” data

      - domain – If A tuple of values [min_contrast, max_contrast], will use those values to normalize. Otherwise will attempt to determine original contrast range from the m_data.

    Returns:

      m_data that has been normalized

  play(interval=None, skip=None, playback_speed=1.0, cmap=None, vmin=-1.0, vmax=1.0, save_as=None, show=True)
    Parameters:

      - interval

      - skip – skip every Nth frame, useful for very large data sets

      - playback_speed

      - cmap – color map, default to gray

      - save_as – If set to a valid (mp4 file) path animation will be saved. Otherwise it won’t

      - show – display the animation, default True

  property ranges

## bmtk.simulator.filternet.lgnmodel.poissongeneration module

bmtk.simulator.filternet.lgnmodel.poissongeneration.generate_inhomogenous_poisson(t_range, y_range, seed=None)

bmtk.simulator.filternet.lgnmodel.poissongeneration.generate_poisson_process(t0, t1, rate)

bmtk.simulator.filternet.lgnmodel.poissongeneration.generate_poisson_rescaling(t, y, seed=None)

bmtk.simulator.filternet.lgnmodel.poissongeneration.generate_poisson_rescaling_function(f, t_min, t_max, seed=None)

bmtk.simulator.filternet.lgnmodel.poissongeneration.generate_renewal_process(t0, t1, renewal_distribution)

## bmtk.simulator.filternet.lgnmodel.singleunitcell module

## bmtk.simulator.filternet.lgnmodel.spatialfilter module

class bmtk.simulator.filternet.lgnmodel.spatialfilter.ArrayFilter(mask)

  Bases: `object`

  get_kernel(row_range, col_range, threshold=0, amplitude=1.0)
  imshow(row_range, col_range, threshold=0, **kwargs)

class bmtk.simulator.filternet.lgnmodel.spatialfilter.GaussianSpatialFilter(translate=(0.0, 0.0), sigma=(1.0, 1.0), rotation=0, origin='center')

  Bases: `object`

  get_kernel(row_range, col_range, threshold=0, amplitude=1.0)

    Creates a 2D gaussian filter (kernel) for the given dimensions which can be used

    Parameters:

      - row_range – field height in pixels

      - col_range – field width in pixels

      - threshold

      - amplitude

    Returns:

      A Kernel2D object

  imshow(row_range, col_range, threshold=0, **kwargs)
  to_dict()

## bmtk.simulator.filternet.lgnmodel.temporalfilter module

class bmtk.simulator.filternet.lgnmodel.temporalfilter.ArrayTemporalFilter(mask, t_support)

  Bases: `TemporalFilter`

  get_default_t_grid()

class bmtk.simulator.filternet.lgnmodel.temporalfilter.TemporalFilter

  Bases: `object`

  get_default_t_grid()
  get_kernel(t_range=None, threshold=0, reverse=False, rescale=False)
  imshow(t_range=None, threshold=0, reverse=False, rescale=False, **kwargs)
  to_dict()

class bmtk.simulator.filternet.lgnmodel.temporalfilter.TemporalFilterCosineBump(weights, kpeaks, delays)

  Bases: `TemporalFilter`

  get_default_t_grid()
  to_dict()

## bmtk.simulator.filternet.lgnmodel.transferfunction module

class bmtk.simulator.filternet.lgnmodel.transferfunction.MultiTransferFunction(symbol_tuple, transfer_function_string)

  Bases: `object`

  to_dict()

class bmtk.simulator.filternet.lgnmodel.transferfunction.ScalarTransferFunction(transfer_function_string, symbol=s)

  Bases: `object`

  imshow(rates, times=None, show=True)
  to_dict()

## bmtk.simulator.filternet.lgnmodel.util_fns module

bmtk.simulator.filternet.lgnmodel.util_fns.check_optim_results_against_bounds(bounds, opt_wts, opt_kpeaks)

bmtk.simulator.filternet.lgnmodel.util_fns.chunks(l, n)

  Yield successive n-sized chunks from l.

bmtk.simulator.filternet.lgnmodel.util_fns.compute_FFT_OneCycle(FR, TF, downsample)

bmtk.simulator.filternet.lgnmodel.util_fns.create_ff_mov(frame_rate, tst, tend, xrng, yrng)

bmtk.simulator.filternet.lgnmodel.util_fns.create_grating_movie_list(gr_dir_name)

bmtk.simulator.filternet.lgnmodel.util_fns.cross_from_above(x, threshold)

  Return the indices into x where x crosses some threshold from above.

bmtk.simulator.filternet.lgnmodel.util_fns.get_tcross_from_temporal_kernel(temporal_kernel)

## bmtk.simulator.filternet.lgnmodel.utilities module

bmtk.simulator.filternet.lgnmodel.utilities.apply_transformation_matrix(image, matrix)

bmtk.simulator.filternet.lgnmodel.utilities.convert_tmin_tmax_framerate_to_trange(t_min, t_max, frame_rate)

bmtk.simulator.filternet.lgnmodel.utilities.get_convolution(t, frame_rate, flipped_t_inds, kernel, data)

bmtk.simulator.filternet.lgnmodel.utilities.get_convolution_ind(curr_fi, flipped_t_inds, kernel, data)

bmtk.simulator.filternet.lgnmodel.utilities.get_rotation_matrix(rotation, shape)

  Angle in degrees

bmtk.simulator.filternet.lgnmodel.utilities.get_scale_matrix(scale, shape)

bmtk.simulator.filternet.lgnmodel.utilities.get_translation_matrix(translation)

bmtk.simulator.filternet.lgnmodel.utilities.get_vanhateren(filename, src_dir)

## bmtk.simulator.filternet.lgnmodel.waveletfilter module

class bmtk.simulator.filternet.lgnmodel.waveletfilter.WaveletFilter(translate=4.0, sigma_f=1.0, b_t=1.0, order_t=3, theta=0.0, Lambda=1.0, psi=0.0, delay=0.0, amplitude=1.0, direction=1)

  Bases: `object`

  get_kernel(row_range, col_range, threshold_rel=0.05, show_plot=False, plot_ax=None)

    Creates a 2D gaussian filter (kernel) for the given dimensions which can be used

    Parameters:

      - row_range – array of times

      - col_range – array of frequency centers

      - threshold_rel – crop filter to region with amplitudes greater than threshold_rel * max value

      - plot_ax – plot handle if plot of filter is desired

    Returns:

      A Kernel2D object

  imshow(row_range, col_range, threshold=0, **kwargs)
  to_dict()

## Module contents