From d2e22274e5ca88660a04b33d721ce9f45c352cff Mon Sep 17 00:00:00 2001 From: IsraMekki0 Date: Fri, 1 Mar 2024 08:18:14 +0100 Subject: [PATCH] Make ants an optional dependency --- brainles_preprocessing/registration/__init__.py | 10 +++++++++- pyproject.toml | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/brainles_preprocessing/registration/__init__.py b/brainles_preprocessing/registration/__init__.py index 0550373..70b18fd 100644 --- a/brainles_preprocessing/registration/__init__.py +++ b/brainles_preprocessing/registration/__init__.py @@ -1,2 +1,10 @@ -from .ANTs.ANTs import ANTsRegistrator +import warnings + +try: + from .ANTs.ANTs import ANTsRegistrator +except ImportError: + warnings.warn( + "ANTS package not found. If you want to use it, please install it using 'pip install antspyx'" + ) + from .niftyreg.niftyreg import NiftyRegRegistrator diff --git a/pyproject.toml b/pyproject.toml index f824fb1..a7e5b42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ classifiers = [ "Operating System :: OS Independent", ] - [tool.poetry.dependencies] python = "^3.10" # core @@ -58,6 +57,12 @@ tqdm = "^4.64.1" auxiliary = "^0.0.41" rich = "^13.6.0" + +antspyx = { version = "^0.4.2", optional = true } + +[tool.poetry.extras] +ants = ["antspyx"] + [tool.poetry.dev-dependencies] pytest = "^6.2"