dacapo

Subpackages

Submodules

Classes

Options

A class that provides options for configuring DaCapo.

Functions

apply(run_name, input_container, input_dataset, ...[, ...])

Load weights and apply a trained model to a dataset. If iteration is None, the best iteration based on the criterion is used. If roi is None, the whole input dataset is used.

train(run_name[, do_validate])

Train a run

validate(run_name[, iteration, datasets_config])

Validate a run at a given iteration. Loads the weights from a previously

validate_run(run, iteration[, datasets_config])

Validate an already loaded run at the given iteration. This does not

Package Contents

class dacapo.Options

A class that provides options for configuring DaCapo.

This class is designed as a singleton and should be accessed using the instance method.

instance()

Returns an instance of the Options class.

config_file()

Returns the path to the configuration file.

__parse_options_from_file()

Parses options from the configuration file.

__parse_options()

Parses options from the configuration file and updates them with the provided kwargs.

classmethod instance(**kwargs) DaCapoConfig

Returns an instance of the Options class.

Parameters:

kwargs – Additional keyword arguments to update the options.

Returns:

An instance of the DaCapoConfig class.

Examples

>>> options = Options.instance()
>>> options
DaCapoConfig(type='files', runs_base_dir=PosixPath('/home/user/dacapo'), compute_context={'type': 'LocalTorch', 'config': {}}, mongo_db_host=None, mongo_db_name=None)
classmethod config_file() upath.UPath | None

Returns the path to the configuration file.

Returns:

The path to the configuration file if found, otherwise None.

Examples

>>> Options.config_file()
PosixPath('/home/user/.config/dacapo/dacapo.yaml')
dacapo.apply(run_name: str, input_container: upath.UPath | str, input_dataset: str, output_path: upath.UPath | str, validation_dataset: dacapo.experiments.datasplits.datasets.dataset.Dataset | str | None = None, criterion: str = 'voi', iteration: int | None = None, parameters: dacapo.experiments.tasks.post_processors.post_processor_parameters.PostProcessorParameters | str | None = None, roi: funlib.geometry.Roi | str | None = None, num_workers: int = 12, output_dtype: numpy.dtype | str = np.uint8, overwrite: bool = True, file_format: str = 'zarr')

Load weights and apply a trained model to a dataset. If iteration is None, the best iteration based on the criterion is used. If roi is None, the whole input dataset is used.

Parameters:
  • run_name (str) – Name of the run to apply.

  • input_container (Path | str) – Path to the input container.

  • input_dataset (str) – Name of the input dataset.

  • output_path (Path | str) – Path to the output container.

  • validation_dataset (Optional[Dataset | str], optional) – Validation dataset to use for finding the best parameters. Defaults to None.

  • criterion (str, optional) – Criterion to use for finding the best parameters. Defaults to “voi”.

  • iteration (Optional[int], optional) – Iteration to use. If None, the best iteration is used. Defaults to None.

  • parameters (Optional[PostProcessorParameters | str], optional) – Post-processor parameters to use. If None, the best parameters are found. Defaults to None.

  • roi (Optional[Roi | str], optional) – Region of interest to use. If None, the whole input dataset is used. Defaults to None.

  • num_workers (int, optional) – Number of workers to use. Defaults to 12.

  • output_dtype (np.dtype | str, optional) – Output dtype. Defaults to np.uint8.

  • overwrite (bool, optional) – Overwrite existing output. Defaults to True.

  • file_format (str, optional) – File format to use. Defaults to “zarr”.

Raises:
  • ValueError – If validation_dataset is None and criterion is not None.

  • ValueError – If parameters is a string that cannot be parsed to PostProcessorParameters.

  • ValueError – If parameters is not a PostProcessorParameters object.

Examples

>>> apply(
...     run_name="run_1",
...     input_container="data.zarr",
...     input_dataset="raw",
...     output_path="output.zarr",
...     validation_dataset="validate",
...     criterion="voi",
...     num_workers=12,
...     output_dtype=np.uint8,
...     overwrite=True,
... )
dacapo.train(run_name: str, do_validate=True)

Train a run

Parameters:

run_name – Name of the run to train

Raises:

ValueError – If run_name is not found in config store

Examples

>>> train("run_name")
dacapo.validate(run_name: str, iteration: int = 0, datasets_config=None)

Validate a run at a given iteration. Loads the weights from a previously stored checkpoint. Returns the best parameters and scores for this iteration.

dacapo.validate_run(run: dacapo.experiments.Run, iteration: int, datasets_config=None)

Validate an already loaded run at the given iteration. This does not load the weights of that iteration, it is assumed that the model is already loaded correctly. Returns the best parameters and scores for this iteration.