Skip to content

Commit

Permalink
Use scilpy's add_verbose_arg
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed May 23, 2024
1 parent 77f80b1 commit c809fbb
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 39 deletions.
9 changes: 0 additions & 9 deletions dwi_ml/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
from scilpy.io.utils import add_processes_arg


def add_verbose_arg(p):
# Can eventually become scilpy.io.utils.add_verbose_arg
p.add_argument('-v', default="WARNING", const='INFO', nargs='?',
choices=['DEBUG', 'INFO', 'WARNING'], dest='verbose',
help='Produces verbose output depending on '
'the provided level. \nDefault level is warning, '
'default when using -v is info.')


def add_resample_or_compress_arg(p: ArgumentParser):
g = p.add_mutually_exclusive_group()
g.add_argument(
Expand Down
6 changes: 3 additions & 3 deletions dwi_ml/testing/projects/tt_visu_argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"""
import argparse

from scilpy.io.utils import (add_overwrite_arg, add_reference_arg)
from scilpy.io.utils import (add_overwrite_arg, add_reference_arg,
add_verbose_arg)

from dwi_ml.io_utils import (add_arg_existing_experiment_path,
add_verbose_arg, add_memory_args)
from dwi_ml.io_utils import add_arg_existing_experiment_path, add_memory_args
from dwi_ml.testing.utils import add_args_testing_subj_hdf5


Expand Down
4 changes: 2 additions & 2 deletions dwi_ml/testing/visu_loss_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import os.path
from argparse import ArgumentParser

from scilpy.io.utils import (add_overwrite_arg,
from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg,
assert_inputs_exist, assert_outputs_exist,
add_reference_arg, ranged_type)

from dwi_ml.io_utils import add_memory_args, add_verbose_arg
from dwi_ml.io_utils import add_memory_args


def prepare_args_visu_loss(p: ArgumentParser):
Expand Down
5 changes: 2 additions & 3 deletions scripts_python/dwiml_create_hdf5_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
import shutil
from pathlib import Path

from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist,
assert_outputs_exist)
from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg,
assert_inputs_exist, assert_outputs_exist)

from dipy.io.stateful_tractogram import set_sft_logger_level

from dwi_ml.data.hdf5.hdf5_creation import HDF5Creator
from dwi_ml.data.hdf5.utils import (
add_hdf5_creation_args, add_streamline_processing_args)
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg


def _initialize_intermediate_subdir(hdf5_file, save_intermediate):
Expand Down
4 changes: 2 additions & 2 deletions scripts_python/dwiml_visualize_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import matplotlib.pyplot as plt
import numpy as np

from scilpy.io.utils import assert_outputs_exist, add_overwrite_arg
from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg,
assert_outputs_exist)

from dwi_ml.io_utils import add_verbose_arg
from dwi_ml.viz.logs_plots import visualize_logs


Expand Down
4 changes: 1 addition & 3 deletions scripts_python/dwiml_visualize_logs_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import matplotlib.pyplot as plt
import numpy as np

from scilpy.io.utils import add_overwrite_arg

from dwi_ml.io_utils import add_verbose_arg
from scilpy.io.utils import add_overwrite_arg, add_verbose_arg


def _build_arg_parser():
Expand Down
3 changes: 2 additions & 1 deletion scripts_python/l2t_resume_training_from_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
# Importing now to solve issues later.
import comet_ml

from scilpy.io.utils import add_verbose_arg

from dwi_ml.data.dataset.utils import prepare_multisubjectdataset
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg
from dwi_ml.models.projects.learn2track_model import Learn2TrackModel
from dwi_ml.training.batch_loaders import DWIMLBatchLoaderOneInput
from dwi_ml.training.batch_samplers import DWIMLBatchIDSampler
Expand Down
4 changes: 1 addition & 3 deletions scripts_python/l2t_track_from_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
from dipy.io.utils import is_header_compatible
import h5py
import nibabel as nib
import torch

from scilpy.io.utils import (add_sphere_arg,
from scilpy.io.utils import (add_sphere_arg, add_verbose_arg,
assert_inputs_exist, assert_outputs_exist,
verify_compression_th)
from scilpy.tracking.utils import (add_seeding_options,
Expand All @@ -23,7 +22,6 @@

from dwi_ml.experiment_utils.prints import format_dict_to_str
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg
from dwi_ml.models.projects.learn2track_model import Learn2TrackModel
from dwi_ml.testing.utils import prepare_dataset_one_subj, \
find_hdf5_associated_to_experiment
Expand Down
5 changes: 3 additions & 2 deletions scripts_python/l2t_train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
import comet_ml
import torch

from scilpy.io.utils import assert_inputs_exist, assert_outputs_exist
from scilpy.io.utils import (add_verbose_arg, assert_inputs_exist,
assert_outputs_exist)

from dwi_ml.data.dataset.utils import prepare_multisubjectdataset
from dwi_ml.experiment_utils.prints import format_dict_to_str
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg, add_memory_args
from dwi_ml.io_utils import add_memory_args
from dwi_ml.models.projects.learn2track_model import Learn2TrackModel
from dwi_ml.models.projects.learn2track_utils import add_model_args
from dwi_ml.models.utils.direction_getters import check_args_direction_getter
Expand Down
3 changes: 1 addition & 2 deletions scripts_python/l2t_update_deprecated_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@

import numpy as np
import torch
from scilpy.io.utils import add_overwrite_arg
from scilpy.io.utils import add_overwrite_arg, add_verbose_arg

from dwi_ml.data.dataset.utils import prepare_multisubjectdataset
from dwi_ml.experiment_utils.prints import format_dict_to_str
from dwi_ml.io_utils import add_verbose_arg
from dwi_ml.models.projects.learn2track_model import Learn2TrackModel
from dwi_ml.training.batch_loaders import DWIMLBatchLoaderOneInput
from dwi_ml.training.batch_samplers import DWIMLBatchIDSampler
Expand Down
4 changes: 3 additions & 1 deletion scripts_python/tt_resume_training_from_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
# Importing now to solve issues later.
import comet_ml

from scilpy.io.utils import add_verbose_arg

from dwi_ml.data.dataset.utils import prepare_multisubjectdataset
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg, verify_which_model_in_path
from dwi_ml.io_utils import verify_which_model_in_path
from dwi_ml.models.projects.transformer_models import find_transformer_class
from dwi_ml.training.batch_loaders import DWIMLBatchLoaderOneInput
from dwi_ml.training.batch_samplers import DWIMLBatchIDSampler
Expand Down
4 changes: 2 additions & 2 deletions scripts_python/tt_track_from_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import h5py
import nibabel as nib

from scilpy.io.utils import (add_sphere_arg,
from scilpy.io.utils import (add_sphere_arg, add_verbose_arg,
assert_inputs_exist, assert_outputs_exist,
verify_compression_th)
from scilpy.tracking.utils import (add_seeding_options,
Expand All @@ -23,7 +23,7 @@

from dwi_ml.experiment_utils.prints import format_dict_to_str
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_verbose_arg, verify_which_model_in_path
from dwi_ml.io_utils import verify_which_model_in_path
from dwi_ml.models.projects.transformer_models import find_transformer_class
from dwi_ml.testing.utils import prepare_dataset_one_subj, \
find_hdf5_associated_to_experiment
Expand Down
14 changes: 8 additions & 6 deletions scripts_python/tt_train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
import comet_ml
import torch

from scilpy.io.utils import assert_inputs_exist, assert_outputs_exist
from scilpy.io.utils import (add_verbose_arg, assert_inputs_exist,
assert_outputs_exist)

from dwi_ml.data.dataset.utils import prepare_multisubjectdataset
from dwi_ml.experiment_utils.prints import format_dict_to_str
from dwi_ml.experiment_utils.timer import Timer
from dwi_ml.io_utils import add_memory_args, add_verbose_arg
from dwi_ml.models.projects.transformer_models import \
OriginalTransformerModel, TransformerSrcAndTgtModel, TransformerSrcOnlyModel
from dwi_ml.io_utils import add_memory_args
from dwi_ml.models.projects.transformer_models import (
OriginalTransformerModel, TransformerSrcAndTgtModel,
TransformerSrcOnlyModel)
from dwi_ml.models.projects.transformers_utils import (
add_transformers_model_args)
from dwi_ml.models.utils.direction_getters import check_args_direction_getter
Expand All @@ -32,8 +34,8 @@
prepare_batch_loader)
from dwi_ml.training.utils.experiment import (
add_mandatory_args_experiment_and_hdf5_path)
from dwi_ml.training.utils.trainer import add_training_args, run_experiment, \
format_lr
from dwi_ml.training.utils.trainer import (add_training_args, run_experiment,
format_lr)


def prepare_arg_parser():
Expand Down

0 comments on commit c809fbb

Please sign in to comment.