From b5087ece061c7b54a952a4b327785dd786b5e50a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:23:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- nobrainer/ext/SynthSeg/evaluate.py | 5 +++-- nobrainer/ext/SynthSeg/metrics_model.py | 5 +++-- nobrainer/ext/SynthSeg/predict.py | 11 ++++++----- nobrainer/ext/SynthSeg/predict_denoiser.py | 9 +++++---- nobrainer/ext/SynthSeg/predict_group.py | 9 +++++---- nobrainer/ext/SynthSeg/predict_qc.py | 9 +++++---- nobrainer/ext/SynthSeg/predict_synthseg.py | 11 ++++++----- .../ext/SynthSeg/sample_segmentation_pairs_d.py | 9 +++++---- nobrainer/ext/SynthSeg/training.py | 15 ++++++++------- nobrainer/ext/SynthSeg/training_denoiser.py | 11 ++++++----- nobrainer/ext/SynthSeg/training_group.py | 13 +++++++------ nobrainer/ext/SynthSeg/training_qc.py | 17 +++++++++-------- nobrainer/ext/SynthSeg/training_supervised.py | 13 +++++++------ nobrainer/ext/SynthSeg/validate.py | 7 ++++--- nobrainer/ext/SynthSeg/validate_qc.py | 7 ++++--- nobrainer/processing/brain_generator.py | 3 +-- 16 files changed, 84 insertions(+), 70 deletions(-) diff --git a/nobrainer/ext/SynthSeg/evaluate.py b/nobrainer/ext/SynthSeg/evaluate.py index 162474ff..c6dd6c40 100644 --- a/nobrainer/ext/SynthSeg/evaluate.py +++ b/nobrainer/ext/SynthSeg/evaluate.py @@ -16,12 +16,13 @@ # python imports import os -# third-party imports -from nobrainer.ext.lab2im import edit_volumes, utils import numpy as np from scipy.ndimage.morphology import distance_transform_edt from scipy.stats import wilcoxon +# third-party imports +from nobrainer.ext.lab2im import edit_volumes, utils + def fast_dice(x, y, labels): """Fast implementation of Dice scores. diff --git a/nobrainer/ext/SynthSeg/metrics_model.py b/nobrainer/ext/SynthSeg/metrics_model.py index 6db8ebb7..2191032b 100644 --- a/nobrainer/ext/SynthSeg/metrics_model.py +++ b/nobrainer/ext/SynthSeg/metrics_model.py @@ -13,8 +13,6 @@ License. """ -# third-party imports -from nobrainer.ext.lab2im import layers import keras.layers as KL from keras.models import Model @@ -22,6 +20,9 @@ import numpy as np import tensorflow as tf +# third-party imports +from nobrainer.ext.lab2im import layers + def metrics_model(input_model, label_list, metrics="dice"): diff --git a/nobrainer/ext/SynthSeg/predict.py b/nobrainer/ext/SynthSeg/predict.py index 78a00b6c..ae7820f9 100644 --- a/nobrainer/ext/SynthSeg/predict.py +++ b/nobrainer/ext/SynthSeg/predict.py @@ -18,17 +18,18 @@ # python imports import os +import keras.backend as K +import keras.layers as KL +from keras.models import Model +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import evaluate # third-party imports from nobrainer.ext.lab2im import edit_volumes, layers, utils from nobrainer.ext.neuron import models as nrn_models -import keras.backend as K -import keras.layers as KL -from keras.models import Model -import numpy as np -import tensorflow as tf def predict( diff --git a/nobrainer/ext/SynthSeg/predict_denoiser.py b/nobrainer/ext/SynthSeg/predict_denoiser.py index 5215e05f..b22fee62 100644 --- a/nobrainer/ext/SynthSeg/predict_denoiser.py +++ b/nobrainer/ext/SynthSeg/predict_denoiser.py @@ -16,6 +16,11 @@ # python imports import os +import keras.layers as KL +from keras.models import Model +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import evaluate from nobrainer.ext.SynthSeg.predict import postprocess, write_csv @@ -23,10 +28,6 @@ # third-party imports from nobrainer.ext.lab2im import edit_volumes, layers, utils from nobrainer.ext.neuron import models as nrn_models -import keras.layers as KL -from keras.models import Model -import numpy as np -import tensorflow as tf def predict( diff --git a/nobrainer/ext/SynthSeg/predict_group.py b/nobrainer/ext/SynthSeg/predict_group.py index 024151f5..1c29d9b9 100644 --- a/nobrainer/ext/SynthSeg/predict_group.py +++ b/nobrainer/ext/SynthSeg/predict_group.py @@ -16,6 +16,11 @@ # python imports import os +import keras.layers as KL +from keras.models import Model +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import evaluate from nobrainer.ext.SynthSeg.predict import write_csv @@ -23,10 +28,6 @@ # third-party imports from nobrainer.ext.lab2im import edit_volumes, layers, utils from nobrainer.ext.neuron import models as nrn_models -import keras.layers as KL -from keras.models import Model -import numpy as np -import tensorflow as tf def predict( diff --git a/nobrainer/ext/SynthSeg/predict_qc.py b/nobrainer/ext/SynthSeg/predict_qc.py index 0bc14f02..75eb040d 100644 --- a/nobrainer/ext/SynthSeg/predict_qc.py +++ b/nobrainer/ext/SynthSeg/predict_qc.py @@ -16,16 +16,17 @@ # python imports import os +import keras.layers as KL +from keras.models import Model +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import evaluate # third-party imports from nobrainer.ext.lab2im import edit_volumes, utils from nobrainer.ext.neuron import models as nrn_models -import keras.layers as KL -from keras.models import Model -import numpy as np -import tensorflow as tf def predict( diff --git a/nobrainer/ext/SynthSeg/predict_synthseg.py b/nobrainer/ext/SynthSeg/predict_synthseg.py index 213bc787..be05a274 100644 --- a/nobrainer/ext/SynthSeg/predict_synthseg.py +++ b/nobrainer/ext/SynthSeg/predict_synthseg.py @@ -18,6 +18,12 @@ import sys import traceback +import keras.backend as K +import keras.layers as KL +from keras.models import Model +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import evaluate from nobrainer.ext.SynthSeg.predict import get_flip_indices, write_csv @@ -25,11 +31,6 @@ # third-party imports from nobrainer.ext.lab2im import edit_volumes, layers, utils from nobrainer.ext.neuron import models as nrn_models -import keras.backend as K -import keras.layers as KL -from keras.models import Model -import numpy as np -import tensorflow as tf def predict( diff --git a/nobrainer/ext/SynthSeg/sample_segmentation_pairs_d.py b/nobrainer/ext/SynthSeg/sample_segmentation_pairs_d.py index a6306a83..a5866388 100644 --- a/nobrainer/ext/SynthSeg/sample_segmentation_pairs_d.py +++ b/nobrainer/ext/SynthSeg/sample_segmentation_pairs_d.py @@ -18,16 +18,17 @@ # python imports import os +from keras import models +import keras.layers as KL +import numpy as np +import tensorflow as tf + # third-party imports from nobrainer.ext.lab2im import edit_tensors as l2i_et from nobrainer.ext.lab2im import edit_volumes from nobrainer.ext.lab2im import layers as layers from nobrainer.ext.lab2im import utils from nobrainer.ext.neuron import models as nrn_models -from keras import models -import keras.layers as KL -import numpy as np -import tensorflow as tf def sample_segmentation_pairs( diff --git a/nobrainer/ext/SynthSeg/training.py b/nobrainer/ext/SynthSeg/training.py index f79c1419..de6475ee 100644 --- a/nobrainer/ext/SynthSeg/training.py +++ b/nobrainer/ext/SynthSeg/training.py @@ -22,20 +22,21 @@ # python imports import os +import keras +from keras import models +import keras.callbacks as KC +from keras.optimizers import Adam +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import metrics_model as metrics -from nobrainer.processing.brain_generator import BrainGenerator # third-party imports from nobrainer.ext.lab2im import layers, utils from nobrainer.ext.neuron import layers as nrn_layers from nobrainer.ext.neuron import models as nrn_models -import keras -from keras import models -import keras.callbacks as KC -from keras.optimizers import Adam -import numpy as np -import tensorflow as tf +from nobrainer.processing.brain_generator import BrainGenerator def training( diff --git a/nobrainer/ext/SynthSeg/training_denoiser.py b/nobrainer/ext/SynthSeg/training_denoiser.py index 7086b3c4..35d04a30 100644 --- a/nobrainer/ext/SynthSeg/training_denoiser.py +++ b/nobrainer/ext/SynthSeg/training_denoiser.py @@ -16,19 +16,20 @@ # python imports import os +from keras import layers as KL +from keras import models +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import metrics_model as metrics -from nobrainer.models.labels_to_image_model import get_shapes from nobrainer.ext.SynthSeg.training import train_model from nobrainer.ext.SynthSeg.training_supervised import build_model_inputs # third-party imports from nobrainer.ext.lab2im import layers, utils from nobrainer.ext.neuron import models as nrn_models -from keras import layers as KL -from keras import models -import numpy as np -import tensorflow as tf +from nobrainer.models.labels_to_image_model import get_shapes def training( diff --git a/nobrainer/ext/SynthSeg/training_group.py b/nobrainer/ext/SynthSeg/training_group.py index 1d5a83d4..1956f474 100644 --- a/nobrainer/ext/SynthSeg/training_group.py +++ b/nobrainer/ext/SynthSeg/training_group.py @@ -21,10 +21,13 @@ # python imports import os +from keras import models +import keras.layers as KL +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import metrics_model as metrics -from nobrainer.processing.brain_generator import BrainGenerator -from nobrainer.models.labels_to_image_model import get_shapes from nobrainer.ext.SynthSeg.training import train_model # third-party imports @@ -32,10 +35,8 @@ from nobrainer.ext.lab2im import layers, utils from nobrainer.ext.lab2im.edit_volumes import get_ras_axes from nobrainer.ext.neuron import models as nrn_models -from keras import models -import keras.layers as KL -import numpy as np -import tensorflow as tf +from nobrainer.models.labels_to_image_model import get_shapes +from nobrainer.processing.brain_generator import BrainGenerator def training( diff --git a/nobrainer/ext/SynthSeg/training_qc.py b/nobrainer/ext/SynthSeg/training_qc.py index dd01df56..d6f1f692 100644 --- a/nobrainer/ext/SynthSeg/training_qc.py +++ b/nobrainer/ext/SynthSeg/training_qc.py @@ -22,6 +22,15 @@ # python imports import os +import keras +from keras import models +import keras.backend as K +import keras.callbacks as KC +import keras.layers as KL +from keras.optimizers import Adam +import numpy as np +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import metrics_model as metrics @@ -31,14 +40,6 @@ from nobrainer.ext.neuron import layers as nrn_layers from nobrainer.ext.neuron import models as nrn_models from nobrainer.ext.neuron import utils as nrn_utils -import keras -from keras import models -import keras.backend as K -import keras.callbacks as KC -import keras.layers as KL -from keras.optimizers import Adam -import numpy as np -import tensorflow as tf def training( diff --git a/nobrainer/ext/SynthSeg/training_supervised.py b/nobrainer/ext/SynthSeg/training_supervised.py index 97123e7f..99c24be7 100644 --- a/nobrainer/ext/SynthSeg/training_supervised.py +++ b/nobrainer/ext/SynthSeg/training_supervised.py @@ -21,9 +21,14 @@ # python imports import os +from keras import models +import keras.layers as KL +import numpy as np +import numpy.random as npr +import tensorflow as tf + # project imports from nobrainer.ext.SynthSeg import metrics_model as metrics -from nobrainer.models.labels_to_image_model import get_shapes from nobrainer.ext.SynthSeg.training import train_model # third-party imports @@ -31,11 +36,7 @@ from nobrainer.ext.lab2im import layers, utils from nobrainer.ext.lab2im.edit_volumes import get_ras_axes from nobrainer.ext.neuron import models as nrn_models -from keras import models -import keras.layers as KL -import numpy as np -import numpy.random as npr -import tensorflow as tf +from nobrainer.models.labels_to_image_model import get_shapes def training( diff --git a/nobrainer/ext/SynthSeg/validate.py b/nobrainer/ext/SynthSeg/validate.py index fbc84496..288f014a 100644 --- a/nobrainer/ext/SynthSeg/validate.py +++ b/nobrainer/ext/SynthSeg/validate.py @@ -19,14 +19,15 @@ import os import re +import matplotlib.pyplot as plt +import numpy as np +from tensorflow.python.summary.summary_iterator import summary_iterator + # project imports from nobrainer.ext.SynthSeg.predict import predict # third-party imports from nobrainer.ext.lab2im import utils -import matplotlib.pyplot as plt -import numpy as np -from tensorflow.python.summary.summary_iterator import summary_iterator def validate_training( diff --git a/nobrainer/ext/SynthSeg/validate_qc.py b/nobrainer/ext/SynthSeg/validate_qc.py index 397264a8..0450d891 100644 --- a/nobrainer/ext/SynthSeg/validate_qc.py +++ b/nobrainer/ext/SynthSeg/validate_qc.py @@ -19,14 +19,15 @@ import os import re +import matplotlib.pyplot as plt +import numpy as np +from tensorflow.python.summary.summary_iterator import summary_iterator + # project imports from nobrainer.ext.SynthSeg.predict_qc import predict # third-party imports from nobrainer.ext.lab2im import utils -import matplotlib.pyplot as plt -import numpy as np -from tensorflow.python.summary.summary_iterator import summary_iterator def validate_training( diff --git a/nobrainer/processing/brain_generator.py b/nobrainer/processing/brain_generator.py index c4dd02fd..aea63b78 100644 --- a/nobrainer/processing/brain_generator.py +++ b/nobrainer/processing/brain_generator.py @@ -16,13 +16,12 @@ # python imports import numpy as np -from nobrainer.models.labels_to_image_model import labels_to_image_model - # project imports from nobrainer.ext.SynthSeg.model_inputs import build_model_inputs # third-party imports from nobrainer.ext.lab2im import edit_volumes, utils +from nobrainer.models.labels_to_image_model import labels_to_image_model class BrainGenerator: