Post-Registration Processing API
RegistrationGraph.average_am_registrations — Functionaverage_am_registrations(
t_range, param_path::Dict; reg_dir_key::String="path_dir_reg_activity_marker",
transform_key::String="name_transform_activity_marker", transform_avg_key::String="name_transform_activity_marker_avg",
key_param_key::String="key_transform_parameters", avg_fn::Function=median
)Averages together registrations. All regstration parameters (including image size) must be the same except for the TransformParameters.
Arguments
t_range: Time points to registerparam_path::Dict: Dictionary containing paths to parameter filesreg_dir_key::String(optional, defaultpath_dir_reg_activity_marker): Key inparam_pathcontaining registration directorytransform_key::String(optional, defaultname_transform_activity_marker): Key inparam_pathcontaning transform file namestransform_avg_key::String(optional, defaultname_transform_activity_marker_avg): Key inparam_pathcontaning averaged transform file names (to be created)key_param_key::String(optional, defaultkey_transform_parameters): Key inparam_pathcontaining theTransformParameterskey.avg_fn::Function(optional, defaultmedian): Function used to average together registrations. Defaultmedian.
RegistrationGraph.average_registered_images — Functionaverage_registered_images(reg_dir, central_nrrd_path, registration_problems, res_name)Averages all registered images, assuming they are all being registered to the same time point.
Arguments:
reg_dir: Registration directory that contains all the moving images registered to the fixed image.central_nrrd_path: Path to fixed image.registration_problems: List of registration problems of the moving images to the fixed image.res_name: Name of registration file (ie: resolution) to use.
RegistrationGraph.make_quality_dict — Functionmake_quality_dict(problems, evaluation_functions::Dict, selection_metric::String, resolutions; mask_dir::Union{String,Nothing}=nothing)Computes the quality of registration using NCC, nearest-neighbors distance between centroids, and manual annotation. Returns a dictionary of registration quality values for each resolution, another dictionary of the best resolution for each problem, and a dictionary of registration resolutions that failed. Outputs a text file containing registration quality values at the best resolution. It is assumed that smaller values are better for the metrics.
Arguments
problems: list of registration problems to compute the quality ofevaluation_functions::Dict: dictionary of metric names to functions that evaluate elastix quality on a pair of images. The evaluation functions will be givenrootpath,fixed,moving,resolution, and possiblymask_diras input, so be sure their other parameters have been initialized correctly. It is assumed that the functions output floating-point metric values.selection_metric::String: which metric should be used to select the best registration out of the set of possible registrationsresolutions: an array of resolution values to be using. Each value is represented as a tuple(i,j), whereiis the number of parameter file to use andjis the resolution for registrations using that parameter file. Both are 0-indexed.
Optional Keyword Arguments
mask_dir::Union{String,Nothing}: directory to a mask file. Statistics will not be computed on regions outside the mask. If left blank, no mask will be used or passed to the evaluation functions.
make_quality_dict(param_path::Dict, param::Dict, problems, evaluation_functions)Computes the quality of registration using NCC, nearest-neighbors distance between centroids, and manual annotation. Returns a dictionary of registration quality values for each resolution, another dictionary of the best resolution for each problem, and a dictionary of registration resolutions that failed. Outputs a text file containing registration quality values at the best resolution. It is assumed that smaller values are better for the metrics.
Arguments
param_path::Dict: Dictionary containingpath_dir_maskentry to the path of masks (ornothingif no masks are used)param::Dict: Dictionary containing the following keys:quality_metric::String: which metric should be used to select the best registration out of the set of possible registrationsgood_registration_resolutions: an array of resolution values to be using. Each value is represented as a tuple(i,j), whereiis the number of parameter file to use andjis the resolution for registrations using that parameter file. Both are 0-indexed.
problems: list of registration problems to compute the quality ofevaluation_functions::Dict: dictionary of metric names to functions that evaluate elastix quality on a pair of images. The evaluation functions will be givenrootpath,fixed,moving,resolution, and possiblymask_diras input, so be sure their other parameters have been initialized correctly. It is assumed that the functions output floating-point metric values.
RegistrationGraph.calculate_ncc — Functioncalculate_ncc(moving, fixed)Computes the NCC of two image arrays moving and fixed corresponding to a registration.
RegistrationGraph.metric_tfm — Functionmetric_tfm(ncc; threshold=0.9)Applies a function to ncc to make it a cost that increases to infinity if ncc decreases below threshold (default 0.9)