Skip to content

Commit

Permalink
reorganize architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau committed May 30, 2024
1 parent c278622 commit b26b9a7
Show file tree
Hide file tree
Showing 149 changed files with 470 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ def on_train_end(self, parameters, **kwargs):
class Tracker(Callback):
def on_train_begin(self, parameters, **kwargs):
if parameters["track_exp"] == "wandb":
from clinicadl.utils.tracking_exp import WandB_handler
from clinicadl.callbacks.tracking_exp import WandB_handler

self.run = WandB_handler(
kwargs["split"], parameters, kwargs["maps_path"].name
)

if parameters["track_exp"] == "mlflow":
from clinicadl.utils.tracking_exp import Mlflow_handler
from clinicadl.callbacks.tracking_exp import Mlflow_handler

self.run = Mlflow_handler(
kwargs["split"], parameters, kwargs["maps_path"].name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pydantic import BaseModel, ConfigDict, computed_field, field_validator
from pydantic.types import NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt

from clinicadl.preprocessing.preprocessing import read_preprocessing
from clinicadl.utils.enum import ExperimentTracking
from clinicadl.utils.preprocessing import read_preprocessing

logger = getLogger("clinicadl.callbacks_config")

Expand Down
File renamed without changes.
16 changes: 9 additions & 7 deletions clinicadl/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# coding: utf8
import click

from clinicadl.generate.generate_cli import cli as generate_cli
from clinicadl.hugging_face.hugging_face_cli import cli as hf_cli
from clinicadl.interpret.interpret_cli import cli as interpret_cli
from clinicadl.predict.predict_cli import cli as predict_cli
from clinicadl.prepare_data.prepare_data_cli import cli as prepare_data_cli
from clinicadl.prepare_data.prepare_data_from_bids_cli import (
from clinicadl.commandline.pipelines.generate.cli import cli as generate_cli
from clinicadl.commandline.pipelines.interpret.cli import cli as interpret_cli
from clinicadl.commandline.pipelines.predict.cli import cli as predict_cli
from clinicadl.commandline.pipelines.prepare_data.prepare_data_cli import (
cli as prepare_data_cli,
)
from clinicadl.commandline.pipelines.prepare_data.prepare_data_from_bids_cli import (
cli as prepare_data_from_bids_cli,
)
from clinicadl.commandline.pipelines.train.cli import cli as train_cli
from clinicadl.hugging_face.hugging_face_cli import cli as hf_cli
from clinicadl.quality_check.qc_cli import cli as qc_cli
from clinicadl.random_search.random_search_cli import cli as random_search_cli
from clinicadl.train.train_cli import cli as train_cli
from clinicadl.tsvtools.cli import cli as tsvtools_cli
from clinicadl.utils.logger import setup_logging

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.callbacks import CallbacksConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
from clinicadl.callbacks.config import CallbacksConfig
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

emissions_calculator = click.option(
"--calculate_emissions/--dont_calculate_emissions",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.computational import ComputationalConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.cross_validation import CrossValidationConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# Cross Validation
n_splits = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.data import DataConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# Data
baseline = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.dataloader import DataLoaderConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# DataLoader
batch_size = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.early_stopping import EarlyStoppingConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# Early Stopping
patience = click.option(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click

from clinicadl.config.config.maps_manager import MapsManagerConfig
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
from clinicadl.config.config_utils import get_type_from_config_class as get_type

maps_dir = click.argument("maps_dir", type=get_type("maps_dir", MapsManagerConfig))
data_group = click.option("data_group", type=get_type("data_group", MapsManagerConfig))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
DTIModalityConfig,
PETModalityConfig,
)
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

tracer = click.option(
"--tracer",
Expand Down
20 changes: 20 additions & 0 deletions clinicadl/commandline/modules_options/network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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.network.config import NetworkConfig

# Model
multi_network = click.option(
"--multi_network/--single_network",
default=get_default("multi_network", NetworkConfig),
help="If provided uses a multi-network framework.",
show_default=True,
)
dropout = click.option(
"--dropout",
type=get_type("dropout", NetworkConfig),
default=get_default("dropout", NetworkConfig),
help="Rate value applied to dropout layers in a CNN architecture.",
show_default=True,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.optimization import OptimizationConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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.optimizer.optimization import OptimizationConfig

# Optimization
accumulation_steps = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.optimizer import OptimizerConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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.optimizer.optimizer import OptimizerConfig

# Optimizer
learning_rate = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.preprocessing import PreprocessingConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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.preprocessing.config import PreprocessingConfig

extract_json = click.option(
"-ej",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.reproducibility import ReproducibilityConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# Reproducibility
compensation = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.ssda import SSDAConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# SSDA
caps_target = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.transforms import TransformsConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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.transforms.config import TransformsConfig

# Transform
data_augmentation = click.option(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from clinicadl.config.config.validation import ValidationConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type
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

# Validation
valid_longitudinal = click.option(
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions clinicadl/commandline/pipelines/generate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import (
random,
shepplogan,
trivial,
)
from .artifacts import options
from .hypometabolic import options
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from clinicadl.utils.clinica_utils import clinicadl_file_reader
from clinicadl.utils.maps_manager.iotools import commandline_to_json

from .generate_utils import (
from .....generate.generate_utils import (
find_file_type,
load_and_check_tsv,
write_missing_mods,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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.generate.generate_config import GenerateArtifactsConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type

contrast = click.option(
"--contrast/--no-contrast",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import click

from clinicadl.generate.generate_artifacts_cli import cli as generate_artifacts_cli
from clinicadl.generate.generate_hypometabolic_cli import cli as generate_hypo_cli
from clinicadl.generate.generate_random_cli import cli as generate_random_cli
from clinicadl.generate.generate_shepplogan_cli import cli as generate_shepplogan_cli
from clinicadl.generate.generate_trivial_cli import cli as generate_trivial_cli
from clinicadl.commandline.pipelines.generate.artifacts.cli import (
cli as generate_artifacts_cli,
)
from clinicadl.commandline.pipelines.generate.hypometabolic.cli import (
cli as generate_hypo_cli,
)
from clinicadl.commandline.pipelines.generate.random.cli import (
cli as generate_random_cli,
)
from clinicadl.commandline.pipelines.generate.shepplogan.cli import (
cli as generate_shepplogan_cli,
)
from clinicadl.commandline.pipelines.generate.trivial.cli import (
cli as generate_trivial_cli,
)


class RegistrationOrderGroup(click.Group):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from clinicadl.generate import generate_param
from clinicadl.generate.generate_config import GenerateHypometabolicConfig
from clinicadl.tsvtools.tsvtools_utils import extract_baseline
from clinicadl.utils.caps_dataset.data import CapsDataset
from clinicadl.utils.clinica_utils import (
RemoteFileStructure,
Expand All @@ -22,9 +23,8 @@
)
from clinicadl.utils.exceptions import DownloadError
from clinicadl.utils.maps_manager.iotools import commandline_to_json
from clinicadl.utils.tsvtools_utils import extract_baseline

from .generate_utils import (
from .....generate.generate_utils import (
find_file_type,
load_and_check_tsv,
mask_processing,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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.generate.generate_config import GenerateHypometabolicConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type

pathology = click.option(
"--pathology",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

from clinicadl.generate import generate_param
from clinicadl.generate.generate_config import GenerateRandomConfig
from clinicadl.utils.caps_dataset.data import CapsDataset
from clinicadl.utils.clinica_utils import clinicadl_file_reader
from clinicadl.utils.maps_manager.iotools import commandline_to_json

from .generate_utils import (
from clinicadl.generate.generate_utils import (
find_file_type,
load_and_check_tsv,
write_missing_mods,
)
from clinicadl.utils.caps_dataset.data import CapsDataset
from clinicadl.utils.clinica_utils import clinicadl_file_reader
from clinicadl.utils.maps_manager.iotools import commandline_to_json

logger = getLogger("clinicadl.generate.random")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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.generate.generate_config import GenerateRandomConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type

mean = click.option(
"--mean",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from clinicadl.generate import generate_param
from clinicadl.generate.generate_config import GenerateSheppLoganConfig
from clinicadl.preprocessing.preprocessing import write_preprocessing
from clinicadl.utils.maps_manager.iotools import check_and_clean, commandline_to_json
from clinicadl.utils.preprocessing import write_preprocessing

from .generate_utils import (
from .....generate.generate_utils import (
generate_shepplogan_phantom,
write_missing_mods,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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.generate.generate_config import GenerateSheppLoganConfig
from clinicadl.utils.config_utils import get_default_from_config_class as get_default
from clinicadl.utils.config_utils import get_type_from_config_class as get_type

extract_json = click.option(
"-ej",
Expand Down
Empty file.
Loading

0 comments on commit b26b9a7

Please sign in to comment.