diff --git a/dwi_ml/io_utils.py b/dwi_ml/io_utils.py index 4f969b15..b16e5baf 100644 --- a/dwi_ml/io_utils.py +++ b/dwi_ml/io_utils.py @@ -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( diff --git a/dwi_ml/testing/projects/tt_visu_argparser.py b/dwi_ml/testing/projects/tt_visu_argparser.py index cde26c57..9aadbac4 100644 --- a/dwi_ml/testing/projects/tt_visu_argparser.py +++ b/dwi_ml/testing/projects/tt_visu_argparser.py @@ -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 diff --git a/dwi_ml/testing/visu_loss_utils.py b/dwi_ml/testing/visu_loss_utils.py index ef81a594..9db78d52 100644 --- a/dwi_ml/testing/visu_loss_utils.py +++ b/dwi_ml/testing/visu_loss_utils.py @@ -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): diff --git a/scripts_python/dwiml_create_hdf5_dataset.py b/scripts_python/dwiml_create_hdf5_dataset.py index c36a14e7..7266cd15 100644 --- a/scripts_python/dwiml_create_hdf5_dataset.py +++ b/scripts_python/dwiml_create_hdf5_dataset.py @@ -25,8 +25,8 @@ 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 @@ -34,7 +34,6 @@ 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): diff --git a/scripts_python/dwiml_visualize_logs.py b/scripts_python/dwiml_visualize_logs.py index f218e4a0..e8807748 100644 --- a/scripts_python/dwiml_visualize_logs.py +++ b/scripts_python/dwiml_visualize_logs.py @@ -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 diff --git a/scripts_python/dwiml_visualize_logs_correlation.py b/scripts_python/dwiml_visualize_logs_correlation.py index 78d92af6..b1ecfee2 100644 --- a/scripts_python/dwiml_visualize_logs_correlation.py +++ b/scripts_python/dwiml_visualize_logs_correlation.py @@ -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(): diff --git a/scripts_python/l2t_resume_training_from_checkpoint.py b/scripts_python/l2t_resume_training_from_checkpoint.py index 21573424..15739413 100644 --- a/scripts_python/l2t_resume_training_from_checkpoint.py +++ b/scripts_python/l2t_resume_training_from_checkpoint.py @@ -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 diff --git a/scripts_python/l2t_track_from_model.py b/scripts_python/l2t_track_from_model.py index eb0891de..92f65831 100644 --- a/scripts_python/l2t_track_from_model.py +++ b/scripts_python/l2t_track_from_model.py @@ -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, @@ -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 diff --git a/scripts_python/l2t_train_model.py b/scripts_python/l2t_train_model.py index eb1bdf36..68fca3df 100755 --- a/scripts_python/l2t_train_model.py +++ b/scripts_python/l2t_train_model.py @@ -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 diff --git a/scripts_python/l2t_update_deprecated_exp.py b/scripts_python/l2t_update_deprecated_exp.py index 1f3304dd..a62edce7 100644 --- a/scripts_python/l2t_update_deprecated_exp.py +++ b/scripts_python/l2t_update_deprecated_exp.py @@ -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 diff --git a/scripts_python/tt_resume_training_from_checkpoint.py b/scripts_python/tt_resume_training_from_checkpoint.py index 191d0877..b7af9ce6 100644 --- a/scripts_python/tt_resume_training_from_checkpoint.py +++ b/scripts_python/tt_resume_training_from_checkpoint.py @@ -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 diff --git a/scripts_python/tt_track_from_model.py b/scripts_python/tt_track_from_model.py index a579cd8f..8ee0cb10 100644 --- a/scripts_python/tt_track_from_model.py +++ b/scripts_python/tt_track_from_model.py @@ -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, @@ -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 diff --git a/scripts_python/tt_train_model.py b/scripts_python/tt_train_model.py index 00ce15ee..c8ba06da 100755 --- a/scripts_python/tt_train_model.py +++ b/scripts_python/tt_train_model.py @@ -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 @@ -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():