Mermaid configurations

Settings for algorithms are passed via the params parameter. There are also more global settings and reasonable default settings available. These live in the settings directory, but can be overwritten by placing custom setting files (of the same names) in a local .mermaid_settings directory in a user’s home directory. More details can be found in Configurations.

Computational settings

The main computational settings are set via the compute_settings.json file and then directly translate into the module variables CUDA_ON, USE_FLOAT16, nher_of_threads, MATPLOTLIB_AGG. These can for example be imported as

from mermaid.config_parser import CUDA_ON, USE_FLOAT16

The settings filename can be queried via

mermaid.config_parser.get_default_compute_settings_filenames()[source]

Returns the filename string where the compute settings will be read from.

Returns:filename string

The default settings are

{
    "compute": {
        "CUDA_ON": true,
        "MATPLOTLIB_AGG": false,
        "USE_FLOAT16": false,
        "nr_of_threads": 16
    }
}
{
    "compute": {
        "CUDA_ON": "Determines if the code should be run on the GPU",
        "MATPLOTLIB_AGG": "Determines how matplotlib plots images. Set to True for remote debugging",
        "USE_FLOAT16": "if set to True uses half-precision - not recommended",
        "__doc__": "how computations are done",
        "nr_of_threads": "set the maximal number of threads"
    }
}

Algorithm settings

Reasonable initial settings for registration algorithms can be obtained via the provided algconf_settings.json settings file.

The settings filename can be queried via

mermaid.config_parser.get_default_algconf_settings_filenames()[source]

Returns the filename string where the configuration for the registration algorithm will be read from.

Returns:filename string

The settings can be loaded into a parameter structure via

mermaid.config_parser.get_algconf_settings(algconf_settings_filename=None)[source]

Returns the registration algorithm configuration settings as a parameter structure.

Parameters:algconf_settings_filename – loads the settings from the specified filename, otherwise from the default filename or in the absence of such a file creates default settings from scratch.
Returns:parameter structure

The default settings (for these confgurations are)

{
    "algconf": {
        "image_smoothing": {
            "smooth_images": true,
            "smoother": {
                "gaussian_std": 0.01,
                "type": "gaussian"
            }
        },
        "model": {
            "deformation": {
                "map_low_res_factor": 1.0,
                "name": "lddmm_shooting",
                "use_map": true
            },
            "registration_model": {
                "forward_model": {
                    "number_of_time_steps": 10,
                    "smoother": {
                        "gaussian_std": 0.15,
                        "type": "gaussian"
                    }
                },
                "similarity_measure": {
                    "develop_mod": {
                        "smoother": {
                            "gaussian_std": 0.1,
                            "type": "gaussian"
                        }
                    },
                    "develop_mod_on": false,
                    "sigma": 0.1,
                    "type": "ssd"
                }
            }
        },
        "optimizer": {
            "multi_scale": {
                "scale_factors": [
                    1.0,
                    0.5,
                    0.25
                ],
                "scale_iterations": [
                    10,
                    20,
                    20
                ],
                "use_multiscale": false
            },
            "name": "lbfgs_ls",
            "single_scale": {
                "nr_of_iterations": 20
            }
        }
    }
}
{
    "algconf": {
        "__doc__": "settings for the registration algorithms",
        "image_smoothing": {
            "__doc__": "image smoothing settings",
            "smooth_images": "[True|False]; smoothes the images before registration",
            "smoother": {
                "__doc__": "settings for the image smoothing",
                "gaussian_std": "how much smoothing is done",
                "type": "['gaussianSpatial'|'gaussian'|'diffusion']"
            }
        },
        "model": {
            "__doc__": "general model settings",
            "deformation": {
                "__doc__": "model describing the desired deformation model",
                "map_low_res_factor": "Set to a value in (0,1) if a map-based solution should be computed at a lower internal resolution (image matching is still at full resolution",
                "name": "['svf'|'svf_quasi_momentum'|'lddmm_shooting'|'lddmm_shooting_scalar_momentum'] all with '_map' or '_image' suffix",
                "use_map": "[True|False] either do computations via a map or directly using the image"
            },
            "registration_model": {
                "__doc__": "general settings for the registration model",
                "forward_model": {
                    "__doc__": "Holds the parameters for the forward model",
                    "number_of_time_steps": "Number of time steps for integration (if applicable)",
                    "smoother": {
                        "__doc__": "how the smoothing of velocity fields is done",
                        "gaussian_std": "standard deviations for smoothing",
                        "type": "type of smoothing"
                    }
                },
                "similarity_measure": {
                    "__doc__": "model describing the similarity measure",
                    "develop_mod": {
                        "__doc__": "developing mode ",
                        "smoother": {
                            "__doc__": "how the smoothing of velocity fields is done ",
                            "gaussian_std": "standard deviation for smoothing",
                            "type": "type of smoothing"
                        }
                    },
                    "develop_mod_on": "if true would allow develop settings ",
                    "sigma": "1/sigma^2 weighting",
                    "type": "[ssd|ncc]"
                }
            }
        },
        "optimizer": {
            "__doc__": "optimizer settings",
            "multi_scale": {
                "__doc__": "multi scale settings",
                "scale_factors": "how images are scaled",
                "scale_iterations": "number of iterations per scale",
                "use_multiscale": "use multi-scale optimizer"
            },
            "name": "name of the optimizer: [lbfgs_ls|adam]",
            "single_scale": {
                "__doc__": "single scale settings",
                "nr_of_iterations": "number of iterations"
            }
        }
    }
}

Basic settings

If saving and reading of configuration files is desired as an option those can be obtained via the provided baseconf_settings.json settings file.

The settings filename can be queried via

mermaid.config_parser.get_default_baseconf_settings_filenames()[source]

Returns the filename string where the basic configuration will be read from.

Returns:filename string

The settings can be loaded into a parameter structure via

mermaid.config_parser.get_baseconf_settings(baseconf_settings_filename=None)[source]

Returns the basic configuration settings as a parameter structure.

Parameters:baseconf_settings_filename – loads the settings from the specified filename, otherwise from the default filename or in the absence of such a file creates default settings from scratch.
Returns:parameter structure

The default settings (for these confgurations are)

{
    "baseconf": {
        "load_default_settings_from_default_setting_files": false,
        "load_settings_from_file": true,
        "save_settings_to_file": true
    }
}
{
    "baseconf": {
        "__doc__": "determines if settings should be loaded from file and visualization options",
        "load_default_settings_from_default_setting_files": "if set to True default configuration files (in settings directory) are first loaded",
        "load_settings_from_file": "if set to True configuration settings are loaded from file",
        "save_settings_to_file": "if set to True configuration settings are saved to file"
    }
}

Democonf settings

Configurations for the creation of demo data should go into the provided democonf_settings.json settings file.

The settings filename can be queried via

mermaid.config_parser.get_default_democonf_settings_filenames()[source]

Returns the filename string where the configuration for demo datasets will be read from.

Returns:filename string

The settings can be loaded into a parameter structure via

mermaid.config_parser.get_democonf_settings(democonf_settings_filename=None)[source]

Returns the configuration settings for the demo data as a parameter structure.

Parameters:democonf_settings_filename – loads the settings from the specified filename, otherwise from the default filename or in the absence of such a file creates default settings from scratch.
Returns:parameter structure

The default settings (for these confgurations are)

{
    "democonf": {
        "dim": 2,
        "example_img_len": 128,
        "use_real_images": false
    }
}
{
    "democonf": {
        "__doc__": "settings for demo images/examples",
        "dim": "Spatial dimension for demo examples 1/2/3",
        "example_img_len": "side length of image cube for example",
        "use_real_images": "if set to true using real and otherwise synthetic images"
    }
}

Respro settings

Todo

These settings need more explanation. Where are they used?

The settings filename can be queried via

mermaid.config_parser.get_default_respro_settings_filenames()[source]

The settings can be loaded into a parameter structure via

mermaid.config_parser.get_respro_settings(respro_settings_filename=None)[source]

The default settings (for these confgurations are)

{
    "respro": {
        "expr_name": "reg",
        "save_excel": true,
        "save_fig": false,
        "save_fig_path": "../data/saved_results",
        "visualize": true,
        "visualize_step": 5
    }
}
{
    "respro": {
        "__doc__": "settings for the results process",
        "expr_name": "name of experiment",
        "save_excel": "save results in excel",
        "save_fig": "save visualized results",
        "save_fig_path": "path of saved figures",
        "visualize": "if set to true intermediate results are visualized",
        "visualize_step": "Number of iterations between visualization output"
    }
}