DeepRegNet/DeepReg

View on GitHub

Showing 113 of 113 total issues

Avoid deeply nested control flow statements.
Open

                if "T1" in file:
                    arr = nib.load(
                        os.path.join(path_to_data, folder, sub_folder, file)
                    ).get_data()
                    img = nib.Nifti1Image(arr, affine=np.eye(4))
Severity: Major
Found in demos/paired_mrus_brain/demo_data.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if case in file:
                            os.chdir(os.path.join(path_to_train, folder))
                            source = file
                            destination = os.path.join(path_to_test, folder)
                            shutil.move(source, destination)
    Severity: Major
    Found in demos/paired_ct_lung/demo_data.py - About 45 mins to fix

      Function gif_warp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def gif_warp(
          img_paths, ddf_path, slice_inds=None, num_interval=100, interval=50, save_path=""
      ):
          """
          Apply ddf to image slice/s to generate gif.
      Severity: Minor
      Found in deepreg/vis.py - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Minor
      Found in deepreg/dataset/loader/unpaired_loader.py - About 45 mins to fix

        Function get_data_loader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_data_loader(data_config: dict, split: str) -> Optional[DataLoader]:
            """
            Return the corresponding data loader.
        
            Can't be placed in the same file of loader interfaces as it causes import cycle.
        Severity: Minor
        Found in deepreg/dataset/load.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid deeply nested control flow statements.
        Open

                        if np.sum((values - values_fi) ** 2) > 1:
                            it_voxel_fi += 1
                            break
        
        
        Severity: Major
        Found in demos/unpaired_mr_brain/demo_data.py - About 45 mins to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Minor
          Found in deepreg/model/backbone/global_net.py - About 45 mins to fix

            Function predict_on_dataset has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def predict_on_dataset(
            Severity: Minor
            Found in deepreg/predict.py - About 45 mins to fix

              Function calculate_metrics has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def calculate_metrics(
              Severity: Minor
              Found in deepreg/util.py - About 45 mins to fix

                Function get_dataset_and_preprocess has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_dataset_and_preprocess(
                Severity: Minor
                Found in deepreg/dataset/loader/interface.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  if np.max(im_data) > 255.0:
                                      im_data = ((im_data + 285) / (3770 + 285)) * 255.0  # rescale image
                                      img = nib.Nifti1Image(im_data, affine=None)
                                      nib.save(img, os.path.join(data_dir, folder, subfolder, file))
                                      if np.max(img.dataobj) > 255.0:
                  Severity: Major
                  Found in demos/paired_ct_lung/demo_data.py - About 45 mins to fix

                    Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(
                    Severity: Minor
                    Found in deepreg/loss/label.py - About 45 mins to fix

                      Function build_up_sampling_block has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def build_up_sampling_block(
                      Severity: Minor
                      Found in deepreg/model/backbone/u_net.py - About 45 mins to fix

                        Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(
                        Severity: Minor
                        Found in deepreg/loss/image.py - About 45 mins to fix

                          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def __init__(
                          Severity: Minor
                          Found in deepreg/loss/label.py - About 45 mins to fix

                            Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def __init__(
                            Severity: Minor
                            Found in deepreg/dataset/preprocess.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                              if np.max(im_data) > 255.0:
                                                  im_data = ((im_data + 285) / (3770 + 285)) * 255.0  # rescale image
                                                  img = nib.Nifti1Image(im_data, affine=None)
                                                  nib.save(img, os.path.join(data_dir, folder, subfolder, file))
                                                  if np.max(img.dataobj) > 255.0:
                              Severity: Major
                              Found in demos/unpaired_ct_lung/demo_data.py - About 45 mins to fix

                                Function gif_warp has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def gif_warp(
                                Severity: Minor
                                Found in deepreg/vis.py - About 45 mins to fix

                                  Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def __init__(
                                  Severity: Minor
                                  Found in deepreg/model/layer.py - About 45 mins to fix

                                    Function build_up_sampling_block has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def build_up_sampling_block(
                                    Severity: Minor
                                    Found in deepreg/model/backbone/local_net.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language