Skip to content

Commit

Permalink
CLI-controllable legacy NifTI import behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Jul 22, 2024
1 parent f406666 commit a26d031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions darwin/cli_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ def dataset_import(
overwrite,
use_multi_cpu,
cpu_limit,
no_legacy=False if legacy else True,
)

except ImporterNotFoundError:
Expand Down
8 changes: 8 additions & 0 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import concurrent.futures
import uuid
from collections import defaultdict
from functools import partial
from logging import getLogger
from multiprocessing import cpu_count
from pathlib import Path
Expand Down Expand Up @@ -677,6 +678,7 @@ def import_annotations( # noqa: C901
overwrite: bool = False,
use_multi_cpu: bool = False,
cpu_limit: Optional[int] = None,
no_legacy: Optional[bool] = False,
) -> None:
"""
Imports the given given Annotations into the given Dataset.
Expand Down Expand Up @@ -718,6 +720,9 @@ def import_annotations( # noqa: C901
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.
no_legacy : bool, default: False
If ``True`` will not use the legacy isotropic transformation to resize annotations
If ``False`` will use the legacy isotropic transformation to resize annotations
Raises
-------
ValueError
Expand All @@ -731,6 +736,9 @@ def import_annotations( # noqa: C901

console = Console(theme=_console_theme())

if importer.__module__ == "darwin.importer.formats.nifti" and no_legacy:
importer = partial(importer, legacy=True)

if append and delete_for_empty:
raise IncompatibleOptions(
"The options 'append' and 'delete_for_empty' cannot be used together. Use only one of them."
Expand Down

0 comments on commit a26d031

Please sign in to comment.