Simple registration interface example

This tutorial will show how to use the simple registration interface of mermaid.

Introduction

Mermaid can be a rather complex registration package. Hence it provides various convenience functions to make registration reasonably easy. One of them is a simple registration interface that allows setting the most popular parameters. But it also allows passing through all the advanced registration parameters as desired.

Importing modules

We start by importing some popular modules. The used mermaid modules are:

  • mermaid.simple_interface provides a very high level interface to the image registration algorithms
  • mermaid.example_generation allows to generate simply synthetic data and some real image pairs to test the registration algorithms
  • mermaid.module_parameters allows generating mermaid parameter structures which are used to keep track of all the parameters
from __future__ import print_function

import numpy as np
import matplotlib.pyplot as plt

import mermaid.simple_interface as SI
import mermaid.example_generation as EG
import mermaid.module_parameters as pars

Creating some example data

We can use mermaid.example_generation to create some test data as follows:

# We first generate a parameter object to hold settings
params = pars.ParameterDict()

# We select if we want to create synthetic image pairs or would prefer a real image pair
use_synthetic_test_case = True

# Desired dimension (mermaid supports 1D, 2D, and 3D registration)
dim = 2

# If we want to add some noise to the background (for synthetic examples)
add_noise_to_bg = True

# and now create it
if use_synthetic_test_case:
    length = 64
    # size of the desired images: (sz)^dim
    szEx = np.tile(length, dim )
    # create a default image size with two sample squares
    I0, I1, spacing = EG.CreateSquares(dim,add_noise_to_bg).create_image_pair(szEx, params)
else:
    # return a real image example
    I0, I1, spacing = EG.CreateRealExampleImages(dim).create_image_pair() # create a default image size with two sample squares

Out:

Creating new category: root.square_example_images
Using default value = 10 for key = len_s of category = root.square_example_images
Using default value = 16 for key = len_l of category = root.square_example_images

Creating the registration algorithm

We simply instantiate a simple interface object for the registration of image pairs. We can then query it as to what models registration models are currently supported.

# create a simple interface object for pair-wise image registration
si = SI.RegisterImagePair()

# print possible model names
si.print_available_models()

Out:

Known registration models are:
------------------------------
                              affine_map: map-based affine registration
                           diffusion_map: displacement-based diffusion registration
                           curvature_map: displacement-based curvature registration
                     total_variation_map: displacement-based total variation registration
                                 svf_map: map-based stationary velocity field
                               svf_image: image-based stationary velocity field
               svf_scalar_momentum_image: image-based stationary velocity field using the scalar momentum
                 svf_scalar_momentum_map: map-based stationary velocity field using the scalar momentum
               svf_vector_momentum_image: image-based stationary velocity field using the vector momentum
                 svf_vector_momentum_map: map-based stationary velocity field using the vector momentum
                      lddmm_shooting_map: map-based shooting-based LDDMM using the vector momentum
                    lddmm_shooting_image: image-based shooting-based LDDMM using the vector momentum
      lddmm_shooting_scalar_momentum_map: map-based shooting-based LDDMM using the scalar momentum
    lddmm_shooting_scalar_momentum_image: image-based shooting-based LDDMM using the scalar momentum
                svf_quasi_momentum_image: EXPERIMENTAL: Image-based SVF version which estimates velcocity based on a smoothed vetor field
                lddmm_adapt_smoother_map: map-based shooting-based Region specific diffemorphic mapping, with a spatio-temporal regularizer
                  svf_adapt_smoother_map: map-based shooting-based vSVF, with a spatio regularizer
                            one_step_map: map based displacement field

Doing the registration

We are now ready to perform the registration (picking one of the registration model options printed above).

Here, we use a shooting-based LDDMM algorithm which works directly with transformation maps. The simple interface allows setting various registration settings.

Of note, we read in a parameter file (test2d_tst.json) to parametrize the registration algorithm and write out the used parameters (after the run) into the same file as well as into a file with comments explaining all the parameter settings. If params is not specified default settings will be used. By running for one iteration for example, this allows writing out a fresh settings template which can then be edited.

si.register_images(I0, I1, spacing, model_name='svf_scalar_momentum_map',
                   nr_of_iterations=100,
                   use_multi_scale=False,
                   visualize_step=5,
                   optimizer_name='sgd',
                   learning_rate=0.1,
                   rel_ftol=1e-7,
                   json_config_out_filename=('test2d_tst.json',
                                             'test2d_tst_with_comments.json'),
                   params='test2d_tst.json',
                   recording_step=None)
../_images/sphx_glr_example_simple_interface_001.png

Out:

Loading parameter file = test2d_tst.json
Overwriting key = use_map; category = root.model.deformation; value =  True -> True
Overwriting key = type; category = root.model.registration_model; value =  svf_scalar_momentum_map -> svf_scalar_momentum_map
Overwriting key = name; category = root.optimizer; value =  sgd -> sgd
Overwriting key = nr_of_iterations; category = root.optimizer.single_scale; value =  100 -> 100
Overwriting key = rel_ftol; category = root.optimizer.single_scale; value =  1e-07 -> 1e-07
Overwriting key = use_map; category = root.model.deformation; value =  True -> True
Overwriting key = map_low_res_factor; category = root.model.deformation; value =  None -> None
Overwriting key = type; category = root.model.registration_model; value =  svf_scalar_momentum_map -> svf_scalar_momentum_map
Overwriting key = type; category = root.model.registration_model; value =  svf_scalar_momentum_map -> svf_scalar_momentum_map
Using map-based svf_scalar_momentum_map model
works in mermaid iter mode
SVFScalarMomentumMapNet(
  (integrator): ODEWrapBlock()
)
Overwriting key = lr; category = root.optimizer.sgd.individual; value =  0.1 -> 0.1
Overwriting key = lr; category = root.optimizer.sgd.shared; value =  0.1 -> 0.1
Using ncc similarity measure
    0-Tot: E=069.5632 | simE=069.5632 | regE=000.0000 | optParE=000.0000 | relF=  n/a    | 
    0-Img: E=069.5632 | simE=069.5632 | regE=000.0000 |
    1-Tot: E=061.8676 | simE=061.8671 | regE=000.0005 | optParE=000.0000 | relF=000.1224 | 
    1-Img: E=061.8676 | simE=061.8671 | regE=000.0005 |
    2-Tot: E=049.0070 | simE=049.0051 | regE=000.0019 | optParE=000.0000 | relF=000.2572 | 
    2-Img: E=049.0070 | simE=049.0051 | regE=000.0019 |
    3-Tot: E=033.5135 | simE=033.5080 | regE=000.0055 | optParE=000.0000 | relF=000.4489 | 
    3-Img: E=033.5135 | simE=033.5080 | regE=000.0055 |
    4-Tot: E=020.3635 | simE=020.3540 | regE=000.0095 | optParE=000.0000 | relF=000.6155 | 
    4-Img: E=020.3635 | simE=020.3540 | regE=000.0095 |
    5-Tot: E=016.4024 | simE=016.3870 | regE=000.0154 | optParE=000.0000 | relF=000.2276 | 
    5-Img: E=016.4024 | simE=016.3870 | regE=000.0154 |
    6-Tot: E=019.1888 | simE=019.1709 | regE=000.0180 | optParE=000.0000 | relF=000.1380 | 
    6-Img: E=019.1888 | simE=019.1709 | regE=000.0180 |
    7-Tot: E=018.8280 | simE=018.8096 | regE=000.0184 | optParE=000.0000 | relF=000.0182 | 
    7-Img: E=018.8280 | simE=018.8096 | regE=000.0184 |
    8-Tot: E=020.8841 | simE=020.8677 | regE=000.0164 | optParE=000.0000 | relF=000.0940 | 
    8-Img: E=020.8841 | simE=020.8677 | regE=000.0164 |
    9-Tot: E=015.0106 | simE=014.9945 | regE=000.0161 | optParE=000.0000 | relF=000.3668 | 
    9-Img: E=015.0106 | simE=014.9945 | regE=000.0161 |
   10-Tot: E=011.6601 | simE=011.6479 | regE=000.0121 | optParE=000.0000 | relF=000.2647 | 
   10-Img: E=011.6601 | simE=011.6479 | regE=000.0121 |
   11-Tot: E=010.9093 | simE=010.8990 | regE=000.0103 | optParE=000.0000 | relF=000.0630 | 
   11-Img: E=010.9093 | simE=010.8990 | regE=000.0103 |
   12-Tot: E=011.3919 | simE=011.3812 | regE=000.0107 | optParE=000.0000 | relF=000.0389 | 
   12-Img: E=011.3919 | simE=011.3812 | regE=000.0107 |
   13-Tot: E=010.1348 | simE=010.1239 | regE=000.0109 | optParE=000.0000 | relF=000.1129 | 
   13-Img: E=010.1348 | simE=010.1239 | regE=000.0109 |
   14-Tot: E=009.7908 | simE=009.7788 | regE=000.0121 | optParE=000.0000 | relF=000.0319 | 
   14-Img: E=009.7908 | simE=009.7788 | regE=000.0121 |
   15-Tot: E=009.8653 | simE=009.8504 | regE=000.0149 | optParE=000.0000 | relF=000.0069 | 
   15-Img: E=009.8653 | simE=009.8504 | regE=000.0149 |
   16-Tot: E=011.9485 | simE=011.9354 | regE=000.0130 | optParE=000.0000 | relF=000.1609 | 
   16-Img: E=011.9485 | simE=011.9354 | regE=000.0130 |
   17-Tot: E=006.7032 | simE=006.6900 | regE=000.0132 | optParE=000.0000 | relF=000.6809 | 
   17-Img: E=006.7032 | simE=006.6900 | regE=000.0132 |
   18-Tot: E=012.9592 | simE=012.9464 | regE=000.0128 | optParE=000.0000 | relF=000.4482 | 
   18-Img: E=012.9592 | simE=012.9464 | regE=000.0128 |
   19-Tot: E=011.0977 | simE=011.0852 | regE=000.0124 | optParE=000.0000 | relF=000.1539 | 
   19-Img: E=011.0977 | simE=011.0852 | regE=000.0124 |
   20-Tot: E=005.8190 | simE=005.8059 | regE=000.0131 | optParE=000.0000 | relF=000.7741 | 
   20-Img: E=005.8190 | simE=005.8059 | regE=000.0131 |
   21-Tot: E=010.2607 | simE=010.2444 | regE=000.0163 | optParE=000.0000 | relF=000.3944 | 
   21-Img: E=010.2607 | simE=010.2444 | regE=000.0163 |
   22-Tot: E=013.9306 | simE=013.9116 | regE=000.0191 | optParE=000.0000 | relF=000.2458 | 
   22-Img: E=013.9306 | simE=013.9116 | regE=000.0191 |
   23-Tot: E=010.2365 | simE=010.2196 | regE=000.0169 | optParE=000.0000 | relF=000.3288 | 
   23-Img: E=010.2365 | simE=010.2196 | regE=000.0169 |
   24-Tot: E=007.9760 | simE=007.9627 | regE=000.0133 | optParE=000.0000 | relF=000.2518 | 
   24-Img: E=007.9760 | simE=007.9627 | regE=000.0133 |
   25-Tot: E=009.7528 | simE=009.7396 | regE=000.0132 | optParE=000.0000 | relF=000.1652 | 
   25-Img: E=009.7528 | simE=009.7396 | regE=000.0132 |
   26-Tot: E=008.4217 | simE=008.4079 | regE=000.0138 | optParE=000.0000 | relF=000.1413 | 
   26-Img: E=008.4217 | simE=008.4079 | regE=000.0138 |
   27-Tot: E=007.8224 | simE=007.8081 | regE=000.0142 | optParE=000.0000 | relF=000.0679 | 
   27-Img: E=007.8224 | simE=007.8081 | regE=000.0142 |
   28-Tot: E=008.0470 | simE=008.0320 | regE=000.0150 | optParE=000.0000 | relF=000.0248 | 
   28-Img: E=008.0470 | simE=008.0320 | regE=000.0150 |
   29-Tot: E=006.4322 | simE=006.4181 | regE=000.0141 | optParE=000.0000 | relF=000.2173 | 
   29-Img: E=006.4322 | simE=006.4181 | regE=000.0141 |
   30-Tot: E=009.5180 | simE=009.5023 | regE=000.0157 | optParE=000.0000 | relF=000.2934 | 
   30-Img: E=009.5180 | simE=009.5023 | regE=000.0157 |
Epoch    31: reducing learning rate of group 0 to 5.0000e-02.
Epoch    31: reducing learning rate of group 1 to 5.0000e-02.
   31-Tot: E=007.3418 | simE=007.3264 | regE=000.0154 | optParE=000.0000 | relF=000.2609 | 
   31-Img: E=007.3418 | simE=007.3264 | regE=000.0154 |
   32-Tot: E=007.4306 | simE=007.4165 | regE=000.0140 | optParE=000.0000 | relF=000.0105 | 
   32-Img: E=007.4306 | simE=007.4165 | regE=000.0140 |
   33-Tot: E=004.4076 | simE=004.3934 | regE=000.0142 | optParE=000.0000 | relF=000.5590 | 
   33-Img: E=004.4076 | simE=004.3934 | regE=000.0142 |
   34-Tot: E=006.0336 | simE=006.0179 | regE=000.0157 | optParE=000.0000 | relF=000.2312 | 
   34-Img: E=006.0336 | simE=006.0179 | regE=000.0157 |
   35-Tot: E=004.9244 | simE=004.9091 | regE=000.0153 | optParE=000.0000 | relF=000.1872 | 
   35-Img: E=004.9244 | simE=004.9091 | regE=000.0153 |
   36-Tot: E=004.5009 | simE=004.4870 | regE=000.0139 | optParE=000.0000 | relF=000.0770 | 
   36-Img: E=004.5009 | simE=004.4870 | regE=000.0139 |
   37-Tot: E=004.3886 | simE=004.3739 | regE=000.0147 | optParE=000.0000 | relF=000.0208 | 
   37-Img: E=004.3886 | simE=004.3739 | regE=000.0147 |
   38-Tot: E=005.3785 | simE=005.3642 | regE=000.0143 | optParE=000.0000 | relF=000.1552 | 
   38-Img: E=005.3785 | simE=005.3642 | regE=000.0143 |
   39-Tot: E=004.0750 | simE=004.0610 | regE=000.0139 | optParE=000.0000 | relF=000.2569 | 
   39-Img: E=004.0750 | simE=004.0610 | regE=000.0139 |
   40-Tot: E=004.8721 | simE=004.8574 | regE=000.0147 | optParE=000.0000 | relF=000.1357 | 
   40-Img: E=004.8721 | simE=004.8574 | regE=000.0147 |
   41-Tot: E=004.1322 | simE=004.1179 | regE=000.0143 | optParE=000.0000 | relF=000.1442 | 
   41-Img: E=004.1322 | simE=004.1179 | regE=000.0143 |
   42-Tot: E=004.5222 | simE=004.5082 | regE=000.0140 | optParE=000.0000 | relF=000.0706 | 
   42-Img: E=004.5222 | simE=004.5082 | regE=000.0140 |
   43-Tot: E=004.0501 | simE=004.0359 | regE=000.0141 | optParE=000.0000 | relF=000.0935 | 
   43-Img: E=004.0501 | simE=004.0359 | regE=000.0141 |
   44-Tot: E=004.3232 | simE=004.3091 | regE=000.0141 | optParE=000.0000 | relF=000.0513 | 
   44-Img: E=004.3232 | simE=004.3091 | regE=000.0141 |
   45-Tot: E=004.0164 | simE=004.0025 | regE=000.0140 | optParE=000.0000 | relF=000.0612 | 
   45-Img: E=004.0164 | simE=004.0025 | regE=000.0140 |
   46-Tot: E=004.1650 | simE=004.1508 | regE=000.0142 | optParE=000.0000 | relF=000.0288 | 
   46-Img: E=004.1650 | simE=004.1508 | regE=000.0142 |
   47-Tot: E=003.9848 | simE=003.9710 | regE=000.0138 | optParE=000.0000 | relF=000.0361 | 
   47-Img: E=003.9848 | simE=003.9710 | regE=000.0138 |
   48-Tot: E=004.0452 | simE=004.0309 | regE=000.0143 | optParE=000.0000 | relF=000.0120 | 
   48-Img: E=004.0452 | simE=004.0309 | regE=000.0143 |
   49-Tot: E=003.9392 | simE=003.9253 | regE=000.0138 | optParE=000.0000 | relF=000.0215 | 
   49-Img: E=003.9392 | simE=003.9253 | regE=000.0138 |
   50-Tot: E=003.9422 | simE=003.9279 | regE=000.0143 | optParE=000.0000 | relF=000.0006 | 
   50-Img: E=003.9422 | simE=003.9279 | regE=000.0143 |
   51-Tot: E=003.9016 | simE=003.8877 | regE=000.0139 | optParE=000.0000 | relF=000.0083 | 
   51-Img: E=003.9016 | simE=003.8877 | regE=000.0139 |
   52-Tot: E=003.8440 | simE=003.8296 | regE=000.0144 | optParE=000.0000 | relF=000.0119 | 
   52-Img: E=003.8440 | simE=003.8296 | regE=000.0144 |
   53-Tot: E=003.8649 | simE=003.8510 | regE=000.0139 | optParE=000.0000 | relF=000.0043 | 
   53-Img: E=003.8649 | simE=003.8510 | regE=000.0139 |
   54-Tot: E=003.7638 | simE=003.7494 | regE=000.0145 | optParE=000.0000 | relF=000.0212 | 
   54-Img: E=003.7638 | simE=003.7494 | regE=000.0145 |
   55-Tot: E=003.8331 | simE=003.8191 | regE=000.0139 | optParE=000.0000 | relF=000.0143 | 
   55-Img: E=003.8331 | simE=003.8191 | regE=000.0139 |
   56-Tot: E=003.7097 | simE=003.6952 | regE=000.0145 | optParE=000.0000 | relF=000.0262 | 
   56-Img: E=003.7097 | simE=003.6952 | regE=000.0145 |
   57-Tot: E=003.8403 | simE=003.8262 | regE=000.0141 | optParE=000.0000 | relF=000.0270 | 
   57-Img: E=003.8403 | simE=003.8262 | regE=000.0141 |
   58-Tot: E=003.8193 | simE=003.8048 | regE=000.0145 | optParE=000.0000 | relF=000.0044 | 
   58-Img: E=003.8193 | simE=003.8048 | regE=000.0145 |
   59-Tot: E=004.0708 | simE=004.0563 | regE=000.0145 | optParE=000.0000 | relF=000.0496 | 
   59-Img: E=004.0708 | simE=004.0563 | regE=000.0145 |
   60-Tot: E=003.5676 | simE=003.5531 | regE=000.0146 | optParE=000.0000 | relF=000.1102 | 
   60-Img: E=003.5676 | simE=003.5531 | regE=000.0146 |
   61-Tot: E=004.1002 | simE=004.0857 | regE=000.0145 | optParE=000.0000 | relF=000.1044 | 
   61-Img: E=004.1002 | simE=004.0857 | regE=000.0145 |
   62-Tot: E=003.3804 | simE=003.3660 | regE=000.0144 | optParE=000.0000 | relF=000.1643 | 
   62-Img: E=003.3804 | simE=003.3660 | regE=000.0144 |
   63-Tot: E=004.1078 | simE=004.0933 | regE=000.0145 | optParE=000.0000 | relF=000.1424 | 
   63-Img: E=004.1078 | simE=004.0933 | regE=000.0145 |
   64-Tot: E=003.2580 | simE=003.2437 | regE=000.0143 | optParE=000.0000 | relF=000.1996 | 
   64-Img: E=003.2580 | simE=003.2437 | regE=000.0143 |
   65-Tot: E=004.1951 | simE=004.1804 | regE=000.0148 | optParE=000.0000 | relF=000.1804 | 
   65-Img: E=004.1951 | simE=004.1804 | regE=000.0148 |
   66-Tot: E=003.1704 | simE=003.1562 | regE=000.0142 | optParE=000.0000 | relF=000.2457 | 
   66-Img: E=003.1704 | simE=003.1562 | regE=000.0142 |
   67-Tot: E=004.2748 | simE=004.2599 | regE=000.0149 | optParE=000.0000 | relF=000.2094 | 
   67-Img: E=004.2748 | simE=004.2599 | regE=000.0149 |
   68-Tot: E=003.1301 | simE=003.1158 | regE=000.0143 | optParE=000.0000 | relF=000.2772 | 
   68-Img: E=003.1301 | simE=003.1158 | regE=000.0143 |
   69-Tot: E=004.1197 | simE=004.1052 | regE=000.0145 | optParE=000.0000 | relF=000.1933 | 
   69-Img: E=004.1197 | simE=004.1052 | regE=000.0145 |
   70-Tot: E=003.0977 | simE=003.0834 | regE=000.0143 | optParE=000.0000 | relF=000.2494 | 
   70-Img: E=003.0977 | simE=003.0834 | regE=000.0143 |
   71-Tot: E=004.2609 | simE=004.2459 | regE=000.0150 | optParE=000.0000 | relF=000.2211 | 
   71-Img: E=004.2609 | simE=004.2459 | regE=000.0150 |
   72-Tot: E=003.4856 | simE=003.4710 | regE=000.0146 | optParE=000.0000 | relF=000.1728 | 
   72-Img: E=003.4856 | simE=003.4710 | regE=000.0146 |
   73-Tot: E=003.6351 | simE=003.6213 | regE=000.0139 | optParE=000.0000 | relF=000.0323 | 
   73-Img: E=003.6351 | simE=003.6213 | regE=000.0139 |
   74-Tot: E=003.0905 | simE=003.0760 | regE=000.0145 | optParE=000.0000 | relF=000.1331 | 
   74-Img: E=003.0905 | simE=003.0760 | regE=000.0145 |
   75-Tot: E=004.0408 | simE=004.0266 | regE=000.0142 | optParE=000.0000 | relF=000.1885 | 
   75-Img: E=004.0408 | simE=004.0266 | regE=000.0142 |
   76-Tot: E=002.9283 | simE=002.9137 | regE=000.0146 | optParE=000.0000 | relF=000.2832 | 
   76-Img: E=002.9283 | simE=002.9137 | regE=000.0146 |
   77-Tot: E=004.5524 | simE=004.5381 | regE=000.0143 | optParE=000.0000 | relF=000.2925 | 
   77-Img: E=004.5524 | simE=004.5381 | regE=000.0143 |
   78-Tot: E=002.8665 | simE=002.8519 | regE=000.0145 | optParE=000.0000 | relF=000.4361 | 
   78-Img: E=002.8665 | simE=002.8519 | regE=000.0145 |
   79-Tot: E=005.2399 | simE=005.2238 | regE=000.0162 | optParE=000.0000 | relF=000.3804 | 
   79-Img: E=005.2399 | simE=005.2238 | regE=000.0162 |
   80-Tot: E=003.0751 | simE=003.0597 | regE=000.0154 | optParE=000.0000 | relF=000.5312 | 
   80-Img: E=003.0751 | simE=003.0597 | regE=000.0154 |
   81-Tot: E=003.8405 | simE=003.8267 | regE=000.0138 | optParE=000.0000 | relF=000.1581 | 
   81-Img: E=003.8405 | simE=003.8267 | regE=000.0138 |
   82-Tot: E=003.1878 | simE=003.1734 | regE=000.0145 | optParE=000.0000 | relF=000.1559 | 
   82-Img: E=003.1878 | simE=003.1734 | regE=000.0145 |
   83-Tot: E=003.7209 | simE=003.7055 | regE=000.0154 | optParE=000.0000 | relF=000.1129 | 
   83-Img: E=003.7209 | simE=003.7055 | regE=000.0154 |
   84-Tot: E=002.9631 | simE=002.9483 | regE=000.0149 | optParE=000.0000 | relF=000.1912 | 
   84-Img: E=002.9631 | simE=002.9483 | regE=000.0149 |
   85-Tot: E=003.9692 | simE=003.9540 | regE=000.0152 | optParE=000.0000 | relF=000.2025 | 
   85-Img: E=003.9692 | simE=003.9540 | regE=000.0152 |
   86-Tot: E=002.8231 | simE=002.8084 | regE=000.0148 | optParE=000.0000 | relF=000.2998 | 
   86-Img: E=002.8231 | simE=002.8084 | regE=000.0148 |
   87-Tot: E=004.2305 | simE=004.2151 | regE=000.0154 | optParE=000.0000 | relF=000.2691 | 
   87-Img: E=004.2305 | simE=004.2151 | regE=000.0154 |
   88-Tot: E=002.7439 | simE=002.7291 | regE=000.0148 | optParE=000.0000 | relF=000.3971 | 
   88-Img: E=002.7439 | simE=002.7291 | regE=000.0148 |
   89-Tot: E=004.3772 | simE=004.3619 | regE=000.0153 | optParE=000.0000 | relF=000.3038 | 
   89-Img: E=004.3772 | simE=004.3619 | regE=000.0153 |
   90-Tot: E=002.6952 | simE=002.6803 | regE=000.0149 | optParE=000.0000 | relF=000.4552 | 
   90-Img: E=002.6952 | simE=002.6803 | regE=000.0149 |
   91-Tot: E=004.4210 | simE=004.4059 | regE=000.0151 | optParE=000.0000 | relF=000.3184 | 
   91-Img: E=004.4210 | simE=004.4059 | regE=000.0151 |
   92-Tot: E=002.6718 | simE=002.6570 | regE=000.0147 | optParE=000.0000 | relF=000.4764 | 
   92-Img: E=002.6718 | simE=002.6570 | regE=000.0147 |
   93-Tot: E=004.0538 | simE=004.0380 | regE=000.0158 | optParE=000.0000 | relF=000.2735 | 
   93-Img: E=004.0538 | simE=004.0380 | regE=000.0158 |
   94-Tot: E=002.6442 | simE=002.6291 | regE=000.0151 | optParE=000.0000 | relF=000.3868 | 
   94-Img: E=002.6442 | simE=002.6291 | regE=000.0151 |
   95-Tot: E=004.1189 | simE=004.1037 | regE=000.0152 | optParE=000.0000 | relF=000.2881 | 
   95-Img: E=004.1189 | simE=004.1037 | regE=000.0152 |
   96-Tot: E=002.7061 | simE=002.6914 | regE=000.0148 | optParE=000.0000 | relF=000.3812 | 
   96-Img: E=002.7061 | simE=002.6914 | regE=000.0148 |
   97-Tot: E=004.1238 | simE=004.1080 | regE=000.0158 | optParE=000.0000 | relF=000.2767 | 
   97-Img: E=004.1238 | simE=004.1080 | regE=000.0158 |
   98-Tot: E=002.6161 | simE=002.6009 | regE=000.0152 | optParE=000.0000 | relF=000.4169 | 
   98-Img: E=002.6161 | simE=002.6009 | regE=000.0152 |
   99-Tot: E=004.3099 | simE=004.2947 | regE=000.0151 | optParE=000.0000 | relF=000.3190 | 
   99-Img: E=004.3099 | simE=004.2947 | regE=000.0151 |
-->Elapsed time 43.61767[s]
Writing parameter file = test2d_tst.json
Writing parameter file = test2d_tst_with_comments.json

Plotting some results

We can query the energies over the iterations. Note that this code need to be modified for a multi-scale solution as energies will be returned at each scale.

h = si.get_history()

plt.clf()
e_p, = plt.plot(h['energy'], label='energy')
s_p, = plt.plot(h['similarity_energy'], label='similarity_energy')
r_p, = plt.plot(h['regularization_energy'], label='regularization_energy')
plt.legend(handles=[e_p, s_p, r_p])
plt.show()
../_images/sphx_glr_example_simple_interface_002.png

Total running time of the script: ( 0 minutes 44.136 seconds)

Gallery generated by Sphinx-Gallery