NeuroPAL_ID Generic Methods¶
Legacy Method Classes¶
AutoDetect
- class Methods.AutoDetect¶
- Property Summary
- fsize¶
- options¶
Public Access
- scale¶
- supervoxels¶
- szext¶
- Method Summary
- static BatchDetect(file, worm, num_neurons)¶
BATCHDETECT Batch detect neurons.
- static constrain_eigenvalues(x, lb, ub)¶
Nonlinear inequality constraints (eigenvalues) for fmincon. Amin Nejat
- detect(titlestr, volume, k, min_eig_thresh, scale, worm, exclusion_radius)¶
Matching pursuit algorithm for finding the best mixture of Gaussians that fits to input dataset. The algorithm runs greedy by subtracting off the brightest Gaussian at each iteration.
INPUTS¶
titlestr: a string that is shown in the progress bar volume: 4D image array (x,y,z,c), doesn’t need to be z-scored k: number of objects that the algorithm finds min_eig_thresh (in microns): if the minimum eigenvalue of the
covariance of an object is less than this the object will be removed in the procedure but is not accepted as a neuron
scale (micron per pixel): scaling between image and micron spaces exclusion_radius (in microns): no pair of objects can have distances
less that the exclusion
OUTPUTS¶
- supervoxels: struct containing the locations (positions), shape
parameters (covariances), colors (colors), basline color (baseline), truncation values (trunc), and readout color from the image (color_readout)
- params: struct contining the parameters chosen for running the
algorithm; parameters are half size of a neuron in microns (hnsz), number of objects (k), threshold for minimum eigenvalue (min_eig_thresh), exclusion radius (exclusion_radius)
Amin Nejat
- static evaluation(image, volume, mp_params, centers, scale, precision)¶
Evaluation of the segmentation method, the output contains shape based evaluation (correlation and MSE) in the reconstruction field and location based evaluation (TP, FP, TN, FN, Accuracy, Precision, Recall, F1) in the centeres field. Amin Nejat
- fit_gaussian(bpatch, colorvec, absolute_position)¶
Amin, desperately need comments to explain this method.
- static gaussian_cost(x, vol, norm_factor)¶
Calculating residual between a multi-color Gaussian function and the original image.
Amin Nejat
- static get_filter(sz, sigma_factor, trunc)¶
Creating a Gaussian filter 2D, 3D, or 4D for smoothing an image.
Amin Nejat
- static get_gaussian(x, sz, norm)¶
Creating Gaussian function for a given set of parameters, used for visualization.
Amin Nejat
- static instance()¶
AutoId
- class Methods.AutoId¶
AUTO_ID Auto.
An auto_id object is has a set of possible names (different if tail/head), the method used, a likelihood matrix, and a set of ids for each of observed neurons.
- Property Summary
- annotation_weight¶
- iter_rwc¶
- iter_sinkhorn¶
- max_fp¶
chosen a larger number slows down computations cubicly.
- max_log_likelihood¶
- min_log_likelihood¶
- ncandidates¶
constants
- p_fp¶
parameters for automatic detection of false positives. pf=prob of a detect being a false positive. max_fp is the maximum posible number of false positives.
- theta¶
- Method Summary
- static BatchId(file, worm)¶
Batch ID neurons.
- static MCR_solver(Y, X, sigma, lambda)¶
MCR - Multiple covariance regression solver Y - Target (n x d) X - Source (n x p) Sigma - covariances for each row of Y (d x d x n) Solving: sum_i |Y_i - X_i beta|_{sigma_i}^2
- add_to_image(im, worm)¶
add_to_image function simply updates some properties of the image structure that depend on auto_id
- compute_assignments()¶
compute_assignments computes some secondary properties of auto_id object
- global_alignment(file, col, pos, model, annotated)¶
Global alignment based on search in the theta space
Amin & Erdem
- id(file, im, worm)¶
We don’t have age-specific atlases yet. For now, use the hermaphrodite ID model to approximate anything younger adult.
- static instance()¶
- static isBodyID(sex, body)¶
ISBODYID Can we ID this body part? Input:
sex = the sex of the worm body = the body part we want to ID
- Output:
is_ID = can we ID this body part?
- static local_alignment(col, pos, model, theta, sgn, annotated)¶
local alignment between atlas and rotated points for given theta
- static major_axis_align(pos, sign)¶
- static pdist2_maha(X, Y, Sigma)¶
mahalanobis distance between a set of points and the components of a GMM
- static rotmat(theta)¶
- static scaled_rotation(X, Y)¶
Solves for Y = S*R*X + T where S is a diagonal scaling matrix R is a rotation matrix i.e. orthonormal and det(R)=1 T is a translation
- static sinkhorn_logspace(logP, niter)¶
- static sinkhorn_logspace_extended(logP, niter, p, n1)¶
- update_confidences(im, worm)¶
update_confidences updates the confidence calculations of each manually annotated neuron, according to current alignments
- update_id(im, worm)¶
update_auto_id changes the properties of auto_id given human has given the identity neuron to the neuron_i-th neuron (with the mp order). it also updates the image object accordingly.
- update_log_likelihood(im, worm)¶
read the model and aligned information
- static update_permutation(colors, positions, model, known)¶
- static vec(x)¶
vectorize multi-dimensional array
- visualize(im, worm, varargin)¶
NNDetect
- class Methods.NNDetect¶
NNDETECT Detection of neural centers using neural nets
- Constructor Summary
- NNDetect()¶
NNDETECT Construct an instance of this class Outputs:
obj : an instance of this class
- Property Summary
- NN_model¶
- crop_size¶
- model¶
- model_version¶
- pst_shape¶
- stride¶
- Method Summary
- static BatchDetect(file, worm, num_neurons)¶
BATCHDETECT Batch detect neurons.
- static create_patches(data)¶
- static detect(titlestr, data)¶
DETECT Use a neural network to detect neurons in the image volume. Inputs:
titlestr = a title string for the progress bar data = the image volume to search for neurons
- Outputs:
- supervoxels = struct containing the locations (positions), shape
parameters (covariances), colors (colors), basline color (baseline), truncation values (trunc), and readout color from the image (color_readout)
- params = struct contining the parameters chosen for running the
algorithm; parameters are half size of a neuron in microns (hnsz), number of objects (k), threshold for minimum eigenvalue (min_eig_thresh), exclusion radius (exclusion_radius)
- static instance()¶
- static pad_to_shape(data, pst_shape)¶
- static post_process(pred_p)¶
- predict_nn(patches, pst_shape, titlestr)¶
- static prepare_image(file)¶
- static visualize(data, centers, pred_p, save, varargin)¶
Preprocess
- class Methods.Preprocess¶
PREPROCESS preprocesssing tools for NeuroPAL images
- Method Summary
- static area_filter(volume, point, threshold, dim)¶
Heuristic filter for removing objects in a multi-color volume.
Amin Nejat
- static decimate_frame(video, new_size, method)¶
decimating a multi-dimensional array DECIMATED = DECIMATE_FRAME(VIDEO, NEW_SIZE, METHOD) decimates the multi-dimensional array VIDEO to size specified by NEW_SIZE. METHOD options are:
‘linear’ ‘nearest’
See also RUN_FRAMES
Amin Nejat
- static filter_frame(frame, filter)¶
applying a filter to multi-color RGB image Amin Nejat
- static filter_gut(data)¶
Generate marks for filtering gut (big green area) Input:
data: data to filter
- Output:
green_mask: convex hall over gut area green_square: square over gut area
Ruoxi Sun
- static filter_gut_lysosomes(data)¶
filtering gut cells (big green artifacts) and lysosomes (small blue artifacts) Input:
data: data to filter (z scored)
- Output:
data_filter: data after filtering mask: 2D matrix showing pixels filtered
Ruoxi Sun
- static filter_small_artifacts(data, filter_color)¶
Generate marks for filtering artifacts smaller than neurons. Input:
data: data to filter filter_color: color of small artifacts
- Output:
green_mask: 2D matrix showing pixels to be filtered
Ruoxi Sun
- static histmatch_frame(video)¶
matching the histogram of the intensities for different colors to normalize different color channels for better visualization Amin Nejat
- static instance()¶
- static manual_artifact_removal(data)¶
MANUAL_ARTIFACT_REMOVAL manually remove image artifacts.
- static threshold_frame(video, method, sensitivity)¶
Thresholding multi-color volume
Amin Nejat
- static zscore_frame(video)¶
Z-scoring different color channels of the multi-color multi-dimensional video. The colors must be in the 4th dimension.
Amin Nejat
Utilities¶
- class Methods.Utils¶
UTILS Summary of this class goes here Detailed explanation goes here
- Method Summary
- static placement(sz, loc, F1)¶
Placing a subcube in a bigger cube (helper function).
Amin Nejat
- static removeNearbyNeurons(neurons, min_xy, min_z)¶
REMOVENEARBYNEURONS Remove neurons that are too near each other (duplicate detections). Inputs:
neurons = the image with the list of neurons to check min_xy = the minimum distance allowed between neurons in x & y min_z = the minimum distance allowed between neurons in z
Note: we use the L2 norm for x & y distances, and L1 norm for z. We do this because x & y often have ~3x better resolution than z.
- static save_for_parfor(fname, sp, mp_params)¶
- static simulate_gaussian(sz, mu, sigma, props, baseline, truncation)¶
Simulate a truncated Gaussian function for fitting procedure. This function is used by matching pursuit algorithm.
Amin Nejat
- static simulate_mvt(sz, mu, covariance, props, baseline, truncation)¶
Simulate a truncated Gaussian function for fitting procedure. This function is used by matching pursuit algorithm.
Amin Nejat
- static sp2video(sp, sz, nsz, trunc)¶
- static sub_sp(sp, subset)¶
Calculating a subset of superpixels.
Amin Nejat
- static subcube(cube, loc, center)¶
Grabbing a patch of the image in a given location.
Amin Nejat
- static superpose(vol, loc, F1)¶
- static union_sp(sp1, sp2)¶
Calculating a subset of superpixels.
Amin Nejat
Orphaned Functions¶
- Methods.logsumexp(a, dim)¶
Returns log(sum(exp(a),dim)) while avoiding numerical underflow. Default is dim = 1 (columns). logsumexp(a, 2) will sum across rows instead of columns. Unlike matlab’s “sum”, it will not switch the summing direction if you provide a row vector.
- Methods.find_outlier(aligned, mu, sigma)¶
- Methods.MatchHist(A)¶
- Methods.run_histmatch(image_data, RGBW)¶
- Methods.munkres(costMat)¶
MUNKRES Munkres (Hungarian) Algorithm for Linear Assignment Problem.
[ASSIGN,COST] = munkres(COSTMAT) returns the optimal column indices, ASSIGN assigned to each row and the minimum COST based on the assignment problem represented by the COSTMAT, where the (i,j)th element represents the cost to assign the jth job to the ith worker.
Partial assignment: This code can identify a partial assignment is a full assignment is not feasible. For a partial assignment, there are some zero elements in the returning assignment vector, which indicate un-assigned tasks. The cost returned only contains the cost of partially assigned tasks. This is vectorized implementation of the algorithm. It is the fastest among all Matlab implementations of the algorithm. Examples Example 1: a 5 x 5 example
- Methods.munkres_extended(Cost, p, n1)¶
Solves an assignment problem, but accounts for possible n1 false positives, so each detect is a false positive with probability p/n1.