allensdk.brain_observatory.receptive_field_analysis.chisquarerf module¶
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
NLL_to_pvalue
(NLLs, log_base=10.0)[source]¶
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
build_trial_matrix
(LSN_template, num_trials, on_off_luminance=(255, 0))[source]¶ Construct indicator arrays for on/off pixels across trials.
Parameters: - LSN_template : np.ndarray
Dimensions are (nTrials, nYPixels, nXPixels). Luminance values per pixel and trial. The size of the first dimension may be larger than the num_trials argument (in which case only the first num_trials slices will be used) but may not be smaller.
- num_trials : int
The number of trials (left-justified) to build indicators for.
- on_off_luminance : array-like, optional
The zeroth element is the luminance value of a pixel when on, the first when off. Defaults are [255, 0].
Returns: - trial_mat : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}, nTrials). Boolean values indicate that a pixel was on/off on a particular trial.
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
chi_square_binary
(events, LSN_template)[source]¶
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
chi_square_within_mask
(exclusion_mask, events_per_pixel, trials_per_pixel)[source]¶ Determine if cells respond preferentially to on/off pixels in a mask using a chi2 test.
Parameters: - exclusion_mask : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}). Integer indicator for INCLUSION (!) of a pixel within the testing region.
- events_per_pixel : np.ndarray
Dimensions are (nCells, nYPixels, nXPixels, {on, off}). Integer values are response counts by cell to on/off luminance at each pixel.
- trials_per_pixel : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}). Integer values are counts of trials where a pixel is on/off.
Returns: - p_vals : np.ndarray
One-dimensional, of length nCells. Float values are p-values for the hypothesis that a given cell has a receptive field within the exclusion mask.
- chi : np.ndarray
Dimensions are (nCells, nYPixels, nXPixels, {on, off}). Values (float) are squared residual event counts divided by expected event counts.
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
deinterpolate_RF
(rf_map, x_pnts, y_pnts, deg_per_pnt)[source]¶ Downsample an image
Parameters: - rf_map : np.ndarray
Input image
- x_pnts : np.ndarray
Count of sample points along the first (column) axis
- y_pnts : np.ndarray
Count of sample points along the zeroth (row) axis
- deg_per_pnt : numeric
scale factor
Returns: - sampled_yx : np.ndarray
Downsampled image
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
get_disc_masks
(LSN_template, radius=3, on_luminance=255, off_luminance=0)[source]¶ Obtain an indicator mask surrounding each pixel. The mask is a square, excluding pixels which are coactive on any trial with the main pixel.
Parameters: - LSN_template : np.ndarray
Dimensions are (nTrials, nYPixels, nXPixels). Luminance values per pixel and trial.
- radius : int
The base mask will be a box whose sides are 2 * radius + 1 in length.
- on_luminance : int, optional
The value of the luminance for on trials. Default is 255
- off_luminance : int, optional
The value of the luminance for off trials. Default is 0
Returns: - masks : np.ndarray
Dimensions are (nYPixels, nXPixels, nYPixels, nXPixels). The first 2 dimensions describe the pixel from which the mask was computed. The last 2 serve as the dimensions of the mask images themselves. Masks are binary arrays of type float, with 1 indicating inside, 0 outside.
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
get_events_per_pixel
(responses_np, trial_matrix)[source]¶ Obtain a matrix linking cellular responses to pixel activity.
Parameters: - responses_np : np.ndarray
Dimensions are (nTrials, nCells). Boolean values indicate presence/absence of a response on a given trial.
- trial_matrix : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}, nTrials). Boolean values indicate that a pixel was on/off on a particular trial.
Returns: - events_per_pixel : np.ndarray
Dimensions are (nCells, nYPixels, nXPixels, {on, off}). Values for each cell, pixel, and on/off state are the sum of events for that cell across all trials where the pixel was in the on/off state.
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
get_expected_events_by_pixel
(exclusion_mask, events_per_pixel, trials_per_pixel)[source]¶ Calculate expected number of events per pixel
Parameters: - exclusion_mask : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}). Integer indicator for INCLUSION (!) of a pixel within the testing region.
- events_per_pixel : np.ndarray
Dimensions are (nCells, nYPixels, nXPixels, {on, off}). Integer values are response counts by cell to on/off luminance at each pixel.
- trials_per_pixel : np.ndarray
Dimensions are (nYPixels, nXPixels, {on, off}). Integer values are counts of trials where a pixel is on/off.
Returns: - np.ndarray :
Dimensions (nCells, nYPixels, nXPixels, {on, off}). Float values are pixelwise counts of events expected if events are evenly distributed in mask across trials.
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
get_peak_significance
(chi_square_grid_NLL, LSN_template, alpha=0.05)[source]¶
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
interpolate_RF
(rf_map, deg_per_pnt)[source]¶ Upsample an image
Parameters: - rf_map : np.ndarray
Input image
- deg_per_pnt : numeric
scale factor
Returns: - interpolated : np.ndarray
Upsampled image
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
pvalue_to_NLL
(p_values, max_NLL=10.0)[source]¶
-
allensdk.brain_observatory.receptive_field_analysis.chisquarerf.
smooth_STA
(STA, gauss_std=0.75, total_degrees=64)[source]¶ Smooth an image by convolution with a gaussian kernel
Parameters: - STA : np.ndarray
Input image
- gauss_std : numeric, optional
Standard deviation of the gaussian kernel. Will be applied to the upsampled image, so units are visual degrees. Default is 0.75
- total_degrees : int, optional
Size in visual degrees of the input image along its zeroth (row) axis. Used to set the scale factor for up/downsampling.
Returns: - STA_smoothed : np.ndarray
Smoothed image