Post-Registration Processing API

RegistrationGraph.average_am_registrationsFunction
average_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 register
  • param_path::Dict: Dictionary containing paths to parameter files
  • reg_dir_key::String (optional, default path_dir_reg_activity_marker): Key in param_path containing registration directory
  • transform_key::String (optional, default name_transform_activity_marker): Key in param_path contaning transform file names
  • transform_avg_key::String (optional, default name_transform_activity_marker_avg): Key in param_path contaning averaged transform file names (to be created)
  • key_param_key::String (optional, default key_transform_parameters): Key in param_path containing the TransformParameters key.
  • avg_fn::Function (optional, default median): Function used to average together registrations. Default median.
RegistrationGraph.average_registered_imagesFunction
average_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_dictFunction
make_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 of
  • evaluation_functions::Dict: dictionary of metric names to functions that evaluate elastix quality on a pair of images. The evaluation functions will be given rootpath, fixed, moving, resolution, and possibly mask_dir as 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 registrations
  • resolutions: an array of resolution values to be using. Each value is represented as a tuple (i,j), where i is the number of parameter file to use and j is 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 containing path_dir_mask entry to the path of masks (or nothing if 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 registrations
    • good_registration_resolutions: an array of resolution values to be using. Each value is represented as a tuple (i,j), where i is the number of parameter file to use and j is the resolution for registrations using that parameter file. Both are 0-indexed.
  • problems: list of registration problems to compute the quality of
  • evaluation_functions::Dict: dictionary of metric names to functions that evaluate elastix quality on a pair of images. The evaluation functions will be given rootpath, fixed, moving, resolution, and possibly mask_dir as input, so be sure their other parameters have been initialized correctly. It is assumed that the functions output floating-point metric values.
RegistrationGraph.calculate_nccFunction
calculate_ncc(moving, fixed)

Computes the NCC of two image arrays moving and fixed corresponding to a registration.

RegistrationGraph.metric_tfmFunction
metric_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)