darwin.importer package

Subpackages

Submodules

darwin.importer.importer module

darwin.importer.importer.import_annotations(dataset: RemoteDataset, importer: Callable[[Path], List[AnnotationFile] | AnnotationFile | None], file_paths: List[str | Path], append: bool, class_prompt: bool = True, delete_for_empty: bool = False, import_annotators: bool = False, import_reviewers: bool = False, overwrite: bool = False, use_multi_cpu: bool = False, cpu_limit: int | None = None) None[source]

Imports the given given Annotations into the given Dataset. :param dataset: Dataset where the Annotations will be imported to. :type dataset: RemoteDataset :param importer: Parsing module containing the logic to parse the given Annotation files given in

files_path. See importer/format for a list of out of supported parsers.

Parameters:
  • file_paths (List[PathLike]) – A list of Path’s or strings containing the Annotations we wish to import.

  • append (bool) – If True appends the given annotations to the datasets. If False will override them. Incompatible with delete-for-empty.

  • class_prompt (bool) – If False classes will be created and added to the datasets without requiring a user’s prompt.

  • delete_for_empty (bool, default: False) – If True will use empty annotation files to delete all annotations from the remote file. If False, empty annotation files will simply be skipped. Only works for V2 datasets. Incompatible with append.

  • import_annotators (bool, default: False) – If True it will import the annotators from the files to the dataset, if available. If False it will not import the annotators.

  • import_reviewers (bool, default: False) – If True it will import the reviewers from the files to the dataset, if . If False it will not import the reviewers.

  • overwrite (bool, default: False) – If True it will bypass a warning that the import will overwrite the current annotations if any are present. If False this warning will be skipped and the import will overwrite the current annotations without warning.

  • use_multi_cpu (bool, default: True) – If True will use multiple available CPU cores to parse the annotation files. If False will use only the current Python process, which runs in one core. Processing using multiple cores is faster, but may slow down a machine also running other processes. Processing with one core is slower, but will run well alongside other processes.

  • cpu_limit (int, default: 2 less than total cpu count) – The maximum number of CPU cores to use when use_multi_cpu is True. If cpu_limit is greater than the number of available CPU cores, it will be set to the number of available cores. If cpu_limit is less than 1, it will be set to CPU count - 2. If cpu_limit is omitted, it will be set to CPU count - 2.

Raises:
  • ValueError –

    • If file_paths is not a list. - If the application is unable to fetch any remote classes. - If the application was unable to find/parse any annotation files. - If the application was unable to fetch remote file list.

  • IncompatibleOptions –

    • If both append and delete_for_empty are specified as True.

darwin.importer.importer.slot_is_medical(slot: Dict[str, Any]) bool[source]
darwin.importer.importer.slot_is_handled_by_monai(slot: Dict[str, Any]) bool[source]
darwin.importer.importer.set_text_property_value(annotation_property_map, annotation_id, a_prop, t_prop)[source]

Module contents

exception darwin.importer.ImporterNotFoundError[source]

Bases: ModuleNotFoundError

darwin.importer.get_importer(format: str) Callable[[Path], List[AnnotationFile] | AnnotationFile | None][source]