allensdk.brain_observatory.r_neuropil module

class allensdk.brain_observatory.r_neuropil.NeuropilSubtract(lam=0.05, dt=1.0, folds=4)[source]

Bases: object

TODO: docs


Estimate error values for a given r for each fold and return the mean.

fit(r_range=[0.0, 2.0], iterations=3, dr=0.1, dr_factor=0.1)[source]

Estimate error values for a range of r values. Identify a new r range around the minimum error values and repeat multiple times. TODO: docs

fit_block_coordinate_desc(r_init=5.0, min_delta_r=1e-08)[source]
set_F(F_M, F_N)[source]

Break the F_M and F_N traces into the number of folds specified in the class constructor and normalize each fold of F_M and R_N relative to F_N.

allensdk.brain_observatory.r_neuropil.ab_from_T(T, lam, dt)[source]

Constructs value for scipy.linalg.solve_banded

mat_dict: dictionary of diagonals keyed by offsets
ab: value for scipy.linalg.solve_banded
allensdk.brain_observatory.r_neuropil.alpha_filter(A=1.0, alpha=0.05, beta=0.25, T=100)[source]
allensdk.brain_observatory.r_neuropil.error_calc(F_M, F_N, F_C, r)[source]
allensdk.brain_observatory.r_neuropil.error_calc_outlier(F_M, F_N, F_C, r)[source]
allensdk.brain_observatory.r_neuropil.estimate_contamination_ratios(F_M, F_N, lam=0.05, folds=4, iterations=3, r_range=[0.0, 2.0], dr=0.1, dr_factor=0.1)[source]

Calculates neuropil contamination of ROI

F_M: ROI trace
F_N: Neuropil trace
dictionary: key-value pairs
  • ‘r’: the contamination ratio – corrected trace = M - r*N

  • ‘err’: RMS error

  • ‘min_error’: minimum error

  • ‘bounds_error’: boolean. True if error or R are outside tolerance


Returns a dictionary of diagonals keyed by offsets

mat: scipy.sparse matrix
dictionary: diagonals keyed by offsets
allensdk.brain_observatory.r_neuropil.normalize_F(F_M, F_N)[source]
allensdk.brain_observatory.r_neuropil.synthesize_F(T, af1, af2, p1=0.05, p2=0.1)[source]

Build a synthetic F_C, F_M, F_N, and r of length T TODO: docs

allensdk.brain_observatory.r_neuropil.validate_with_synthetic_F(T, N)[source]

Compute N synthetic traces of length T with known values of r, then estimate r. TODO: docs