diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 466dd1c2f..1a2b6f7d9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,9 +2,9 @@ name: 'Lint codebase' on: pull_request: - branches: [ dev ] + branches: [ "dev", "refactoring" ] push: - branches: [ dev ] + branches: [ "dev", "refactoring" ] permissions: contents: read diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e0fdde33..219e86c2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Test on: push: - branches: [dev] + branches: ["dev", "refactoring"] pull_request: - branches: [dev] + branches: ["dev", "refactoring"] permissions: contents: read diff --git a/.github/workflows/test_cli.yml b/.github/workflows/test_cli.yml index 4efd2b024..5949fab4d 100644 --- a/.github/workflows/test_cli.yml +++ b/.github/workflows/test_cli.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_generate.yml b/.github/workflows/test_generate.yml index 8fc54c025..d3b9ed1d3 100644 --- a/.github/workflows/test_generate.yml +++ b/.github/workflows/test_generate.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_interpret.yml b/.github/workflows/test_interpret.yml index 13db354a9..f20d08194 100644 --- a/.github/workflows/test_interpret.yml +++ b/.github/workflows/test_interpret.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_predict.yml b/.github/workflows/test_predict.yml index e6d790b2a..c49094a12 100644 --- a/.github/workflows/test_predict.yml +++ b/.github/workflows/test_predict.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_prepare_data.yml b/.github/workflows/test_prepare_data.yml index 753634f76..6452703f8 100644 --- a/.github/workflows/test_prepare_data.yml +++ b/.github/workflows/test_prepare_data.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_quality_checks.yml b/.github/workflows/test_quality_checks.yml index 25d1bc752..ffa071db3 100644 --- a/.github/workflows/test_quality_checks.yml +++ b/.github/workflows/test_quality_checks.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_random_search.yml b/.github/workflows/test_random_search.yml index 78ddc2df0..f7910cb84 100644 --- a/.github/workflows/test_random_search.yml +++ b/.github/workflows/test_random_search.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_resume.yml b/.github/workflows/test_resume.yml index 6d145339b..57a72dcd0 100644 --- a/.github/workflows/test_resume.yml +++ b/.github/workflows/test_resume.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_train.yml b/.github/workflows/test_train.yml index b3852bb09..93f390341 100644 --- a/.github/workflows/test_train.yml +++ b/.github/workflows/test_train.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_transfer_learning.yml b/.github/workflows/test_transfer_learning.yml index 9a3a583a3..e82196ce3 100644 --- a/.github/workflows/test_transfer_learning.yml +++ b/.github/workflows/test_transfer_learning.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/.github/workflows/test_tsvtools.yml b/.github/workflows/test_tsvtools.yml index 9e388b8e7..fda362139 100644 --- a/.github/workflows/test_tsvtools.yml +++ b/.github/workflows/test_tsvtools.yml @@ -5,6 +5,7 @@ on: branches: ["dev", "refactoring"] pull_request: branches: ["dev", "refactoring"] + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: read diff --git a/Makefile b/Makefile index 5c8ca37d1..a7b469b16 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ help: Makefile .PHONY: check.lock check.lock: - @$(POETRY) lock --check + @$(POETRY) check --lock ## build : Build the package. .PHONY: build diff --git a/clinicadl/callbacks/config.py b/clinicadl/callbacks/config.py index ce6e0ef2e..aafe2e2f6 100644 --- a/clinicadl/callbacks/config.py +++ b/clinicadl/callbacks/config.py @@ -1,13 +1,8 @@ -from abc import ABC, abstractmethod -from enum import Enum from logging import getLogger -from pathlib import Path -from typing import Any, Dict, Optional, Tuple +from typing import Optional -from pydantic import BaseModel, ConfigDict, computed_field, field_validator -from pydantic.types import NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt +from pydantic import BaseModel, ConfigDict -from clinicadl.preprocessing.preprocessing import read_preprocessing from clinicadl.utils.enum import ExperimentTracking logger = getLogger("clinicadl.callbacks_config") diff --git a/clinicadl/caps_dataset/data_config.py b/clinicadl/caps_dataset/data_config.py index 9265cd555..c2ae3bb49 100644 --- a/clinicadl/caps_dataset/data_config.py +++ b/clinicadl/caps_dataset/data_config.py @@ -28,7 +28,7 @@ class DataConfig(BaseModel): # TODO : put in data module diagnoses: Tuple[str, ...] = ("AD", "CN") data_df: Optional[pd.DataFrame] = None label: Optional[str] = None - label_code: Union[str, dict[str, int], None] = {} + label_code: Union[str, Dict[str, int], None] = {} multi_cohort: bool = False mask_path: Optional[Path] = None preprocessing_json: Optional[Path] = None diff --git a/clinicadl/caps_dataset/data_utils.py b/clinicadl/caps_dataset/data_utils.py index 08a49cd9f..4cd514079 100644 --- a/clinicadl/caps_dataset/data_utils.py +++ b/clinicadl/caps_dataset/data_utils.py @@ -1,6 +1,5 @@ # coding: utf8 # TODO: create a folder for generate/ prepare_data/ data to deal with capsDataset objects ? -import abc from logging import getLogger from pathlib import Path from typing import Any, Callable, Dict, Optional diff --git a/clinicadl/commandline/modules_options/__init__.py b/clinicadl/commandline/modules_options/__init__.py index d7d50b584..e69de29bb 100644 --- a/clinicadl/commandline/modules_options/__init__.py +++ b/clinicadl/commandline/modules_options/__init__.py @@ -1 +0,0 @@ -# from .task import classification, reconstruction, regression diff --git a/clinicadl/commandline/modules_options/caps_dataset.py b/clinicadl/commandline/modules_options/caps_dataset.py deleted file mode 100644 index 8b1378917..000000000 --- a/clinicadl/commandline/modules_options/caps_dataset.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/clinicadl/commandline/modules_options/computational.py b/clinicadl/commandline/modules_options/computational.py index d3c168c47..82333e9c9 100644 --- a/clinicadl/commandline/modules_options/computational.py +++ b/clinicadl/commandline/modules_options/computational.py @@ -2,7 +2,6 @@ from clinicadl.config.config.computational import ComputationalConfig from clinicadl.config.config_utils import get_default_from_config_class as get_default -from clinicadl.config.config_utils import get_type_from_config_class as get_type # Computational amp = click.option( diff --git a/clinicadl/commandline/pipelines/generate/shepplogan/options.py b/clinicadl/commandline/pipelines/generate/shepplogan/options.py index 1fa8ab545..fc15c2009 100644 --- a/clinicadl/commandline/pipelines/generate/shepplogan/options.py +++ b/clinicadl/commandline/pipelines/generate/shepplogan/options.py @@ -1,5 +1,3 @@ -from typing import get_args - import click from clinicadl.config.config_utils import get_default_from_config_class as get_default diff --git a/clinicadl/commandline/pipelines/generate/trivial/cli.py b/clinicadl/commandline/pipelines/generate/trivial/cli.py index 67188a7bf..e456ab400 100644 --- a/clinicadl/commandline/pipelines/generate/trivial/cli.py +++ b/clinicadl/commandline/pipelines/generate/trivial/cli.py @@ -1,4 +1,3 @@ -import tarfile from logging import getLogger from pathlib import Path diff --git a/clinicadl/commandline/pipelines/predict/options.py b/clinicadl/commandline/pipelines/predict/options.py index 3de022d44..003dfe275 100644 --- a/clinicadl/commandline/pipelines/predict/options.py +++ b/clinicadl/commandline/pipelines/predict/options.py @@ -1,7 +1,6 @@ import click from clinicadl.config.config_utils import get_default_from_config_class as get_default -from clinicadl.config.config_utils import get_type_from_config_class as get_type from clinicadl.predict.config import PredictConfig # predict specific diff --git a/clinicadl/commandline/pipelines/prepare_data/prepare_data_cli.py b/clinicadl/commandline/pipelines/prepare_data/prepare_data_cli.py index c77032352..77de01595 100644 --- a/clinicadl/commandline/pipelines/prepare_data/prepare_data_cli.py +++ b/clinicadl/commandline/pipelines/prepare_data/prepare_data_cli.py @@ -1,5 +1,4 @@ from pathlib import Path -from typing import Optional import click diff --git a/clinicadl/commandline/pipelines/prepare_data/prepare_data_from_bids_cli.py b/clinicadl/commandline/pipelines/prepare_data/prepare_data_from_bids_cli.py index 22843c546..725a61c8a 100644 --- a/clinicadl/commandline/pipelines/prepare_data/prepare_data_from_bids_cli.py +++ b/clinicadl/commandline/pipelines/prepare_data/prepare_data_from_bids_cli.py @@ -1,5 +1,5 @@ - import click + from clinicadl.caps_dataset.caps_dataset_config import CapsDatasetConfig from clinicadl.commandline import arguments from clinicadl.commandline.modules_options import ( @@ -10,9 +10,6 @@ ) from clinicadl.prepare_data.prepare_data import DeepLearningPrepareData from clinicadl.utils.enum import ExtractionMethod -from clinicadl.commandline import arguments -from clinicadl.commandline.modules_options import data, dataloader, modality, preprocessing -from clinicadl.utils.enum import ExtractionMethod @click.command(name="image", no_args_is_help=True) @@ -27,7 +24,6 @@ @modality.custom_suffix @data.participants_tsv def image_bids_cli(kwargs): - image_config = CapsDatasetConfig.from_preprocessing_and_extraction_method( extraction=ExtractionMethod.IMAGE, preprocessing_type=kwargs["preprocessing"], diff --git a/clinicadl/config/config/maps_manager.py b/clinicadl/config/config/maps_manager.py index 7641bbbef..6efd489f5 100644 --- a/clinicadl/config/config/maps_manager.py +++ b/clinicadl/config/config/maps_manager.py @@ -1,4 +1,3 @@ -from enum import Enum from logging import getLogger from pathlib import Path from typing import Optional @@ -6,7 +5,6 @@ from pydantic import BaseModel, ConfigDict from clinicadl.utils.exceptions import ClinicaDLArgumentError # type: ignore -from clinicadl.utils.maps_manager.maps_manager import MapsManager # type: ignore logger = getLogger("clinicadl.predict_config") diff --git a/clinicadl/config/config_utils.py b/clinicadl/config/config_utils.py index 8b078282f..85b0ee8bd 100644 --- a/clinicadl/config/config_utils.py +++ b/clinicadl/config/config_utils.py @@ -1,6 +1,6 @@ import typing from enum import Enum -from typing import Any, get_args, get_origin +from typing import Any, get_args import click from pydantic import BaseModel diff --git a/clinicadl/generate/generate_config.py b/clinicadl/generate/generate_config.py index a276d5a93..922a9d59f 100644 --- a/clinicadl/generate/generate_config.py +++ b/clinicadl/generate/generate_config.py @@ -1,4 +1,3 @@ -import tarfile from logging import getLogger from pathlib import Path from time import time @@ -14,22 +13,8 @@ field_validator, ) -from clinicadl.utils.clinica_utils import ( - RemoteFileStructure, - clinicadl_file_reader, - fetch_file, -) -from clinicadl.utils.enum import ( - Pathology, - Preprocessing, - SUVRReferenceRegions, - Tracer, -) -from clinicadl.utils.exceptions import ( - ClinicaDLArgumentError, - ClinicaDLTSVError, - DownloadError, -) +from clinicadl.utils.enum import Pathology +from clinicadl.utils.exceptions import ClinicaDLArgumentError logger = getLogger("clinicadl.predict_config") @@ -52,6 +37,8 @@ class GenerateArtifactsConfig(BaseModel): noise_std: Tuple[NonNegativeFloat, NonNegativeFloat] = (5.0, 15.0) rotation: Tuple[NonNegativeFloat, NonNegativeFloat] = (2.0, 4.0) # float o int ??? translation: Tuple[NonNegativeFloat, NonNegativeFloat] = (2.0, 4.0) + # pydantic config + model_config = ConfigDict(validate_assignment=True) @field_validator("gamma", "noise_std", "rotation", "translation", mode="before") def list_to_tuples(cls, v): @@ -85,16 +72,22 @@ class GenerateHypometabolicConfig(BaseModel): anomaly_degree: NonNegativeFloat = 30.0 pathology: Pathology = Pathology.AD sigma: NonNegativeFloat = 5 + # pydantic config + model_config = ConfigDict(validate_assignment=True) class GenerateRandomConfig(BaseModel): mean: NonNegativeFloat = 0.0 sigma: NonNegativeFloat = 0.5 + # pydantic config + model_config = ConfigDict(validate_assignment=True) class GenerateTrivialConfig(BaseModel): atrophy_percent: PositiveFloat = 60.0 mask_path: Optional[Path] = None + # pydantic config + model_config = ConfigDict(validate_assignment=True) class GenerateSheppLoganConfig(BaseModel): @@ -107,6 +100,8 @@ class GenerateSheppLoganConfig(BaseModel): extract_json: Optional[str] = None image_size: PositiveInt = 128 smoothing: bool = False + # pydantic config + model_config = ConfigDict(validate_assignment=True) @field_validator("extract_json", mode="before") def compute_extract_json(cls, v: str): diff --git a/clinicadl/generate/generate_utils.py b/clinicadl/generate/generate_utils.py index 08ec2523d..9b925e6a4 100755 --- a/clinicadl/generate/generate_utils.py +++ b/clinicadl/generate/generate_utils.py @@ -3,11 +3,10 @@ import random from copy import copy from pathlib import Path -from typing import Dict, Optional, Union +from typing import Dict, Optional import numpy as np import pandas as pd -from pydantic import BaseModel from scipy.ndimage import gaussian_filter from skimage.draw import ellipse @@ -22,15 +21,12 @@ from clinicadl.utils.enum import ( LinearModality, Preprocessing, - SUVRReferenceRegions, - Tracer, ) # from clinicadl.caps_dataset.caps_dataset_config import CapsDatasetConfig from clinicadl.utils.exceptions import ( ClinicaDLArgumentError, ClinicaDLTSVError, - DownloadError, ) diff --git a/clinicadl/hugging_face/pull_cli.py b/clinicadl/hugging_face/pull_cli.py index 36158ef5c..e93a26e18 100644 --- a/clinicadl/hugging_face/pull_cli.py +++ b/clinicadl/hugging_face/pull_cli.py @@ -1,9 +1,6 @@ -from pathlib import Path - import click from clinicadl.utils import cli_param -from clinicadl.utils.maps_manager import MapsManager @click.command(name="pull", no_args_is_help=True) diff --git a/clinicadl/interpret/config.py b/clinicadl/interpret/config.py index 9fad6ac1a..1e59f3efc 100644 --- a/clinicadl/interpret/config.py +++ b/clinicadl/interpret/config.py @@ -1,14 +1,10 @@ -from enum import Enum from logging import getLogger from pathlib import Path -from typing import Dict, Optional, Union +from typing import Optional from pydantic import BaseModel, field_validator from clinicadl.caps_dataset.data_config import DataConfig as DataBaseConfig -from clinicadl.caps_dataset.data_utils import ( - load_data_test, -) from clinicadl.caps_dataset.dataloader_config import DataLoaderConfig from clinicadl.config.config.computational import ComputationalConfig from clinicadl.config.config.cross_validation import CrossValidationConfig diff --git a/clinicadl/mlflow_test.py b/clinicadl/mlflow_test.py index 35a2c0995..85b70b4a1 100644 --- a/clinicadl/mlflow_test.py +++ b/clinicadl/mlflow_test.py @@ -1,5 +1,4 @@ import logging -import os import sys import warnings from urllib.parse import urlparse diff --git a/clinicadl/network/autoencoder/models.py b/clinicadl/network/autoencoder/models.py index 1a9912526..8ac40191e 100644 --- a/clinicadl/network/autoencoder/models.py +++ b/clinicadl/network/autoencoder/models.py @@ -1,7 +1,7 @@ from torch import nn from clinicadl.network.autoencoder.cnn_transformer import CNN_Transformer -from clinicadl.network.cnn.models import Conv4_FC3, Conv5_FC3, resnet18 +from clinicadl.network.cnn.models import Conv4_FC3, Conv5_FC3 from clinicadl.network.sub_network import AutoEncoder from clinicadl.network.vae.vae_layers import ( DecoderLayer3D, diff --git a/clinicadl/network/cnn/random.py b/clinicadl/network/cnn/random.py index 5b19ce726..897a014d1 100644 --- a/clinicadl/network/cnn/random.py +++ b/clinicadl/network/cnn/random.py @@ -2,7 +2,6 @@ from clinicadl.network.network_utils import * from clinicadl.network.sub_network import CNN -from clinicadl.utils.enum import Normalization from clinicadl.utils.exceptions import ClinicaDLNetworksError diff --git a/clinicadl/predict/config.py b/clinicadl/predict/config.py index d0f5e49e5..19d14e4f3 100644 --- a/clinicadl/predict/config.py +++ b/clinicadl/predict/config.py @@ -1,7 +1,5 @@ from logging import getLogger -from pydantic import BaseModel - from clinicadl.caps_dataset.data_config import DataConfig as DataBaseConfig from clinicadl.caps_dataset.dataloader_config import DataLoaderConfig from clinicadl.config.config.maps_manager import ( diff --git a/clinicadl/predict/predict_manager.py b/clinicadl/predict/predict_manager.py index 79f964328..2cc2d6d30 100644 --- a/clinicadl/predict/predict_manager.py +++ b/clinicadl/predict/predict_manager.py @@ -7,7 +7,7 @@ import pandas as pd import torch import torch.distributed as dist -from torch.cuda.amp import GradScaler, autocast +from torch.cuda.amp import autocast from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler diff --git a/clinicadl/prepare_data/prepare_data.py b/clinicadl/prepare_data/prepare_data.py index d8f88e044..23907f984 100644 --- a/clinicadl/prepare_data/prepare_data.py +++ b/clinicadl/prepare_data/prepare_data.py @@ -1,6 +1,6 @@ from logging import getLogger from pathlib import Path -from typing import Optional, Union +from typing import Optional from joblib import Parallel, delayed from torch import save as save_tensor diff --git a/clinicadl/prepare_data/prepare_data_utils.py b/clinicadl/prepare_data/prepare_data_utils.py index 2eb7c7048..73207ec39 100644 --- a/clinicadl/prepare_data/prepare_data_utils.py +++ b/clinicadl/prepare_data/prepare_data_utils.py @@ -1,18 +1,11 @@ # coding: utf8 from pathlib import Path -from time import time -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Dict, List, Optional, Tuple, Union import numpy as np import torch -from clinicadl.caps_dataset.caps_dataset_config import CapsDatasetConfig -from clinicadl.utils.enum import ( - LinearModality, - Preprocessing, - SliceDirection, - SliceMode, -) +from clinicadl.utils.enum import SliceDirection, SliceMode ############ diff --git a/clinicadl/preprocessing/config.py b/clinicadl/preprocessing/config.py index 90c460e5b..6daa838a0 100644 --- a/clinicadl/preprocessing/config.py +++ b/clinicadl/preprocessing/config.py @@ -1,10 +1,10 @@ from logging import getLogger from pathlib import Path from time import time -from typing import Annotated, Any, Dict, Optional, Tuple, Union +from typing import List, Optional, Tuple from pydantic import BaseModel, ConfigDict, field_validator -from pydantic.types import NonNegativeInt, PositiveInt +from pydantic.types import NonNegativeInt from clinicadl.utils.enum import ( ExtractionMethod, @@ -63,7 +63,7 @@ class PreprocessingSliceConfig(PreprocessingConfig): class PreprocessingROIConfig(PreprocessingConfig): - roi_list: list[str] = [] + roi_list: List[str] = [] roi_uncrop_output: bool = False roi_custom_template: str = "" roi_custom_pattern: str = "" diff --git a/clinicadl/quality_check/t1_volume/cli.py b/clinicadl/quality_check/t1_volume/cli.py index 3b41756a6..67e064bb2 100644 --- a/clinicadl/quality_check/t1_volume/cli.py +++ b/clinicadl/quality_check/t1_volume/cli.py @@ -2,6 +2,7 @@ from clinicadl.commandline import arguments + @click.command(name="t1-volume", no_args_is_help=True) @arguments.caps_directory @arguments.output_directory diff --git a/clinicadl/trainer/config/reconstruction.py b/clinicadl/trainer/config/reconstruction.py index b727328c6..4651840ca 100644 --- a/clinicadl/trainer/config/reconstruction.py +++ b/clinicadl/trainer/config/reconstruction.py @@ -1,4 +1,3 @@ -from enum import Enum from logging import getLogger from typing import Tuple diff --git a/clinicadl/trainer/config/regression.py b/clinicadl/trainer/config/regression.py index 42e7d603b..227cbe232 100644 --- a/clinicadl/trainer/config/regression.py +++ b/clinicadl/trainer/config/regression.py @@ -1,8 +1,7 @@ -from enum import Enum from logging import getLogger from typing import Tuple -from pydantic import PositiveFloat, PositiveInt, computed_field, field_validator +from pydantic import computed_field, field_validator from clinicadl.caps_dataset.data_config import DataConfig as BaseDataConfig from clinicadl.config.config.validation import ValidationConfig as BaseValidationConfig diff --git a/clinicadl/transforms/transforms.py b/clinicadl/transforms/transforms.py index c70bf8dae..7b6de09a7 100644 --- a/clinicadl/transforms/transforms.py +++ b/clinicadl/transforms/transforms.py @@ -1,16 +1,12 @@ # coding: utf8 from logging import getLogger -from typing import List, Optional, Tuple, Union import numpy as np import torch import torchio as tio -import torchvision.transforms as transforms -from clinicadl.utils.exceptions import ( - ClinicaDLConfigurationError, -) +from clinicadl.utils.exceptions import ClinicaDLConfigurationError logger = getLogger("clinicadl") diff --git a/clinicadl/tsvtools/analysis/analysis.py b/clinicadl/tsvtools/analysis/analysis.py index c9b0a0732..edcc9d02d 100644 --- a/clinicadl/tsvtools/analysis/analysis.py +++ b/clinicadl/tsvtools/analysis/analysis.py @@ -12,7 +12,6 @@ cleaning_nan_diagnoses, find_label, first_session, - merged_tsv_reader, next_session, ) from clinicadl.utils.exceptions import ClinicaDLArgumentError, ClinicaDLTSVError diff --git a/clinicadl/utils/cli_param/__init__.py b/clinicadl/utils/cli_param/__init__.py index fc18aac1f..88a19d38c 100644 --- a/clinicadl/utils/cli_param/__init__.py +++ b/clinicadl/utils/cli_param/__init__.py @@ -1 +1,2 @@ from . import argument, option, option_group +# TODO : remove this folder when all the options are in commandline folder diff --git a/clinicadl/utils/clinica_utils.py b/clinicadl/utils/clinica_utils.py index dcb18adea..0dded2126 100644 --- a/clinicadl/utils/clinica_utils.py +++ b/clinicadl/utils/clinica_utils.py @@ -4,7 +4,6 @@ import ssl import tempfile from collections import namedtuple -from enum import Enum from functools import partial from glob import glob from pathlib import Path, PurePath diff --git a/clinicadl/utils/enum.py b/clinicadl/utils/enum.py index 776398175..813836e08 100644 --- a/clinicadl/utils/enum.py +++ b/clinicadl/utils/enum.py @@ -245,6 +245,7 @@ class Pooling(str, Enum): # TODO : put in model module MAXPOOLING = "MaxPooling" STRIDE = "stride" + class ReconstructionMetric(str, Enum): # TODO : put in metric module """Available reconstruction metrics in ClinicaDL.""" @@ -274,6 +275,7 @@ class RegressionMetric(str, Enum): # TODO : put in metric module RMSE = "RMSE" LOSS = "loss" + class GenerateType(str, Enum): """Available generation pipelines in ClinicaDL.""" diff --git a/clinicadl/utils/maps_manager/maps_manager_utils.py b/clinicadl/utils/maps_manager/maps_manager_utils.py index 524659ce1..c1f4d7651 100644 --- a/clinicadl/utils/maps_manager/maps_manager_utils.py +++ b/clinicadl/utils/maps_manager/maps_manager_utils.py @@ -5,7 +5,7 @@ import toml from clinicadl.caps_dataset.caps_dataset_utils import compute_folder_and_file_type -from clinicadl.preprocessing.preprocessing import path_decoder, path_encoder +from clinicadl.preprocessing.preprocessing import path_decoder def add_default_values(user_dict: Dict[str, Any]) -> Dict[str, Any]: diff --git a/clinicadl/utils/metric_module.py b/clinicadl/utils/metric_module.py index 319b4a639..171a06792 100644 --- a/clinicadl/utils/metric_module.py +++ b/clinicadl/utils/metric_module.py @@ -2,7 +2,6 @@ from typing import Dict, List import numpy as np -from sklearn.utils import resample metric_optimum = { "MAE": "min", diff --git a/clinicadl/utils/read_utils.py b/clinicadl/utils/read_utils.py index b3ad45e30..c852f2fd1 100644 --- a/clinicadl/utils/read_utils.py +++ b/clinicadl/utils/read_utils.py @@ -4,7 +4,6 @@ from clinicadl.utils.clinica_utils import ( RemoteFileStructure, - clinicadl_file_reader, fetch_file, ) from clinicadl.utils.enum import MaskChecksum, Pathology diff --git a/tests/unittests/generate/test_hypo_config.py b/tests/unittests/generate/test_hypo_config.py deleted file mode 100644 index 9d59270ee..000000000 --- a/tests/unittests/generate/test_hypo_config.py +++ /dev/null @@ -1,97 +0,0 @@ -import pytest -from pydantic import ValidationError - - -@pytest.mark.parametrize( - "parameters", - [ - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "flair-linear", - "n_subjects": 3, - "n_proc": 1, - "pathology_cls": "lvppa", - "anomaly_degree": 6, - "sigma": 5, - "use_uncropped_image": False, - }, - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "t1-linear", - "n_subjects": 3, - "n_proc": 1, - "pathology_cls": "alzheimer", - "anomaly_degree": 6, - "sigma": 5, - "use_uncropped_image": False, - }, - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "t1-linear", - "n_subjects": 3, - "n_proc": 1, - "pathology_cls": "lvppa", - "anomaly_degree": 6, - "sigma": 40.2, - "use_uncropped_image": True, - }, - ], -) -def test_fails_validations(parameters): - from clinicadl.generate.generate_config import GenerateHypometabolicConfig - - with pytest.raises(ValidationError): - GenerateHypometabolicConfig(**parameters) - - -@pytest.mark.parametrize( - "parameters", - [ - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "t1-linear", - "n_subjects": 3, - "n_proc": 2, - "pathology_cls": "lvppa", - "anomaly_degree": 30.5, - "sigma": 35, - "use_uncropped_image": False, - }, - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "pet-linear", - "n_subjects": 3, - "n_proc": 1, - "pathology_cls": "ad", - "anomaly_degree": 6.6, - "sigma": 20, - "use_uncropped_image": True, - }, - { - "caps_directory": "", - "generated_caps_directory": "", - "participants_list": "", - "preprocessing_cls": "t1-linear", - "n_subjects": 3, - "n_proc": 1, - "pathology_cls": "pca", - "anomaly_degree": 6, - "sigma": 5, - "use_uncropped_image": True, - }, - ], -) -def test_passes_validations(parameters): - from clinicadl.generate.generate_config import GenerateHypometabolicConfig - - GenerateHypometabolicConfig(**parameters) diff --git a/tests/unittests/generate/test_trivial_config.py b/tests/unittests/generate/test_trivial_config.py deleted file mode 100644 index e69de29bb..000000000