Configuration

The configuration summarizes all the parameters used internally by CAREamics. It is used to create a CAREamist instance and is saved together with the checkpoints and saved models.

Configurations are created for specific algorithms using convenience functions. They are Python objects, but can be exported to a dictionary, and contain a hierarchy of parameters.

Configuration example

Here is an example of a configuration for the Noise2Void algorithm.

Noise2Void configuration
version: 0.1.0
experiment_name: N2V 3D
algorithm_config:
  algorithm: n2v
  loss: n2v
  model:
    architecture: UNet
    conv_dims: 3
    num_classes: 1
    in_channels: 1
    depth: 2
    num_channels_init: 32
    final_activation: None
    n2v2: false
    independent_channels: true
  optimizer:
    name: Adam
    parameters:
      lr: 0.0001
  lr_scheduler:
    name: ReduceLROnPlateau
    parameters: {}
  n2v_config:
    name: N2VManipulate
    roi_size: 11
    masked_pixel_percentage: 0.2
    remove_center: true
    strategy: uniform
    struct_mask_axis: none
    struct_mask_span: 5
data_config:
  data_type: tiff
  axes: ZYX
  patch_size:
  - 8
  - 64
  - 64
  batch_size: 8
  transforms:
  - name: XYFlip
    flip_x: true
    flip_y: true
    p: 0.5
  - name: XYRandomRotate90
    p: 0.5
  train_dataloader_params:
    shuffle: true
  val_dataloader_params: {}
training_config:
  num_epochs: 20
  precision: '32'
  max_steps: -1
  check_val_every_n_epoch: 1
  enable_progress_bar: true
  accumulate_grad_batches: 1
  gradient_clip_algorithm: norm
  checkpoint_callback:
    monitor: val_loss
    verbose: false
    save_weights_only: false
    save_last: true
    save_top_k: 3
    mode: min
    auto_insert_metric_name: false

The number of parameters might appear overwhelming, but in practice users only call a function with few parameters. The configuration is designed to hide the complexity of the algorithms and provide a simple interface to the user.

from careamics.config import (
    create_care_configuration,  # CARE
    create_n2n_configuration,  # Noise2Noise
    create_n2v_configuration,  # Noise2Void
)

config = create_n2v_configuration(
    experiment_name="n2v_experiment",
    data_type="array",
    axes="YX",
    patch_size=[64, 64],
    batch_size=8,
    num_epochs=50,
)

In the next sections, you can dive deeper on how to create a configuration and interact with the configuration with different levels of expertise.

Beginner

Intermediate

Advanced