Simple interface

Using mermaid can at times get a bit overwhelming. Hence, there is a simple registration interface, which makes it much easier to computer registrations using the most popular settings.

Inheritance diagram of mermaid.simple_interface

This package provides a super-simple interface for standard registration tasks

class mermaid.simple_interface.RegisterImagePair[source]
get_params()[source]

Gets configuration parameters

Returns:ParameterDict instance holding the algorithm parameters
init_analysis_params(par_respro, task_name)[source]
get_opt()[source]
set_opt(opt)[source]
static print_available_models()[source]
static get_available_models()[source]
get_history()[source]

Gets the optimizer history.

Returns:dictionary containing the optimizer history.
get_energy()[source]

Returns the current energy :return: Returns a tuple (energy, similarity energy, regularization energy)

get_warped_image()[source]

Returns the warped image

Returns:the warped image
get_warped_label()[source]

Returns the warped label

Returns:the warped label
get_map()[source]

Returns the deformation map :return: deformation map

get_inverse_map()[source]

Returns the inverse deformation map if available :return: deformation map

set_initial_map(map0, initial_inverse_map=None)[source]

Sets the map that will be used as initial condition. By default this is the identity, but this can be overwritten with this method to for example allow concatenating multiple transforms.

Parameters:
  • map0 – initial map
  • initial_inverse_map – inverse initial map; if this is not set, the inverse map cannot be computed on the fly
Returns:

n/a

set_weight_map(init_weight, freeze_weight=False)[source]

Sets the map that will be used as initial condition. By default this is the identity, but this can be overwritten with this method to for example allow concatenating multiple transforms.

Parameters:
  • map0 – initial map
  • initial_inverse_map – inverse initial map; if this is not set, the inverse map cannot be computed on the fly
Returns:

n/a

get_initial_map()[source]

Returns the map that is used as initial condition (is typically identity)

Returns:returns the initial map
get_initial_inverse_map()[source]

Returns the inverse map that is used as initial condition (is typically identity)

Returns:returns the initial map
get_model_parameters()[source]

Returns the parameters of the model

Returns:model parameters
set_model_parameters_to_zero()[source]

Sets the model parameters to zero; typically not needed, but may be useful in certain scenarios.

set_model_parameters(p)[source]

Sets the model parameters

Parameters:p – model parameters
Returns:
register_images_from_files(source_filename, target_filename, model_name, extra_info=None, lsource_filename=None, ltarget_filename=None, nr_of_iterations=None, learning_rate=None, similarity_measure_type=None, similarity_measure_sigma=None, compute_similarity_measure_at_low_res=None, map_low_res_factor=None, rel_ftol=None, smoother_type=None, json_config_out_filename=None, visualize_step=5, use_multi_scale=False, use_consensus_optimization=False, use_batch_optimization=False, checkpoint_dir='checkpoints', resume_from_last_checkpoint=False, optimizer_name=None, compute_inverse_map=False, params=None)[source]

Registers two images. Only ISource, ITarget, spacing, and model_name need to be specified. Default values will be used for all of the values that are not explicitly specified.

Parameters:
  • source_filename – filename of the source image
  • target_filename – filename for the target image
  • model_name – name of the desired registration model [string]
  • nr_of_iterations – nr of iterations
  • learning_rate – learning rate of optimizer
  • similarity_measure_type – type of similarity measure (‘ssd’ or ‘ncc’)
  • similarity_measure_sigma – similarity measures are weighted by 1/sigma^2
  • compute_similarity_measure_at_low_res – allows computation of similarity measure at lower resolution, specified by map_low_res_factor
  • map_low_res_factor – allows for parameterization of the registration at lower resolution than the image (0,1]
  • rel_ftol – relative function tolerance for optimizer
  • smoother_type – type of smoother (e.g., ‘gaussian’ or ‘multiGaussian’)
  • json_config_out_filename – output file name for the used configuration.
  • visualize_step – step at which the solution is visualized; if set to None, no visualizations will be created
  • use_multi_scale – if set to True a multi-scale solver will be used
  • use_consensus_optimization – if set to True, consensus optimization is used (i.e., independently optimized batches with the contraint that shared parameters are the same)
  • use_batch_optimization – if set to True, batch optimization is used (i.e., optimization done w/ mini batches)
  • checkpoint_dir – directory in which the checkpoints are written for consensus optimization
  • resume_from_last_checkpoint – for consensus optimizer, resumes optimization from last checkpoint
  • optimizer_name – name of the optimizer lbfgs_ls|adam|sgd
  • compute_inverse_map – for map-based models that inverse map can optionally be computed
  • params – parameter structure to pass settings or filename to load the settings from file.
Returns:

n/a

register_images(ISource, ITarget, spacing, model_name=None, extra_info=None, LSource=None, LTarget=None, nr_of_iterations=None, learning_rate=None, similarity_measure_type=None, similarity_measure_sigma=None, compute_similarity_measure_at_low_res=None, map_low_res_factor=None, rel_ftol=None, smoother_type=None, json_config_out_filename=None, visualize_step=5, use_multi_scale=False, use_consensus_optimization=False, use_batch_optimization=False, checkpoint_dir=None, resume_from_last_checkpoint=False, optimizer_name=None, compute_inverse_map=False, params=None, recording_step=None)[source]

Registers two images. Only ISource, ITarget, spacing, and model_name need to be specified. Default values will be used for all of the values that are not explicitly specified.

Parameters:
  • ISource – source image
  • ITarget – target image
  • spacing – image spacing [dx,dy,dz]
  • model_name – name of the desired registration model [string]
  • nr_of_iterations – nr of iterations
  • learning_rate – learning rate of optimizer
  • similarity_measure_type – type of similarity measure (‘ssd’ or ‘ncc’)
  • similarity_measure_sigma – similarity measures are weighted by 1/sigma^2
  • compute_similarity_measure_at_low_res – allows computation of similarity measure at lower resolution, specified by map_low_res_factor
  • map_low_res_factor – allows for parameterization of the registration at lower resolution than the image (0,1]
  • rel_ftol – relative function tolerance for optimizer
  • smoother_type – type of smoother (e.g., ‘gaussian’ or ‘multiGaussian’)
  • json_config_out_filename – output file name for the used configuration.
  • visualize_step – step at which the solution is visualized; if set to None, no visualizations will be created
  • use_multi_scale – if set to True a multi-scale solver will be used
  • use_consensus_optimization – if set to True, consensus optimization is used (i.e., independently optimized batches with the contraint that shared parameters are the same)
  • use_batch_optimization – if set to True, batch optimization is used (i.e., optimization done w/ mini batches)
  • checkpoint_dir – directory in which the checkpoints are written for consensus optimization
  • resume_from_last_checkpoint – for consensus optimizer, resumes optimization from last checkpoint
  • optimizer_name – name of the optimizer lbfgs_ls|adam|sgd
  • compute_inverse_map – for map-based models that inverse map can optionally be computed
  • params – parameter structure to pass settings or filename to load the settings from file.
  • recording_step – set tracking of all intermediate results in history each n-th step
Returns:

n/a