fepegar/torchio

View on GitHub

Showing 108 of 108 total issues

File image.py has 800 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import warnings
from collections import Counter
from pathlib import Path
from typing import Any
from typing import Callable
Severity: Major
Found in src/torchio/data/image.py - About 1 day to fix

    File transform.py has 514 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import copy
    import numbers
    import warnings
    from abc import ABC
    from abc import abstractmethod
    Severity: Major
    Found in src/torchio/transforms/transform.py - About 1 day to fix

      File random_affine.py has 424 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from numbers import Number
      from typing import Optional
      from typing import Sequence
      from typing import Tuple
      from typing import Union
      Severity: Minor
      Found in src/torchio/transforms/augmentation/spatial/random_affine.py - About 6 hrs to fix

        File random_labels_to_image.py has 420 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from typing import List
        from typing import Optional
        from typing import Sequence
        from typing import Tuple
        
        

          File io.py has 388 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import warnings
          from pathlib import Path
          from typing import Optional
          from typing import Tuple
          from typing import Union
          Severity: Minor
          Found in src/torchio/data/io.py - About 5 hrs to fix

            File subject.py has 382 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from __future__ import annotations
            
            import copy
            import pprint
            from typing import TYPE_CHECKING
            Severity: Minor
            Found in src/torchio/data/subject.py - About 5 hrs to fix

              File utils.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from __future__ import annotations
              
              import ast
              import gzip
              import inspect
              Severity: Minor
              Found in src/torchio/utils.py - About 4 hrs to fix

                File queue.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from itertools import islice
                from typing import Iterator
                from typing import List
                from typing import Optional
                
                
                Severity: Minor
                Found in src/torchio/data/queue.py - About 4 hrs to fix

                  Image has 31 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Image(dict):
                      r"""TorchIO image.
                  
                      For information about medical image orientation, check out `NiBabel docs`_,
                      the `3D Slicer wiki`_, `Graham Wideman's website`_, `FSL docs`_ or
                  Severity: Minor
                  Found in src/torchio/data/image.py - About 3 hrs to fix

                    Function apply_transform has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def apply_transform(self, subject: Subject) -> Subject:
                            original_image = subject.get(self.image_key)
                    
                            label_map_image = subject[self.label_key]
                            label_map = label_map_image.data

                    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

                    File random_elastic_deformation.py has 302 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import warnings
                    from numbers import Number
                    from typing import Sequence
                    from typing import Tuple
                    from typing import Union

                      Function guess_external_viewer has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def guess_external_viewer() -> Optional[Path]:
                          """Guess the path to an executable that could be used to visualize images.
                      
                          Currently, it looks for 1) ITK-SNAP and 2) 3D Slicer. Implemented
                          for macOS and Windows.
                      Severity: Minor
                      Found in src/torchio/utils.py - About 3 hrs 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 ensure_4d has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def ensure_4d(tensor: TypeData, num_spatial_dims=None) -> torch.Tensor:
                          # I wish named tensors were properly supported in PyTorch
                          tensor = torch.as_tensor(tensor)
                          num_dimensions = tensor.ndim
                          if num_dimensions == 4:
                      Severity: Minor
                      Found in src/torchio/data/io.py - About 2 hrs 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

                      File random_motion.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from collections import defaultdict
                      from typing import Dict
                      from typing import List
                      from typing import Sequence
                      from typing import Tuple
                      Severity: Minor
                      Found in src/torchio/transforms/augmentation/intensity/random_motion.py - About 2 hrs to fix

                        File resample.py has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        from collections.abc import Iterable
                        from numbers import Number
                        from pathlib import Path
                        from typing import Optional
                        from typing import Sized
                        Severity: Minor
                        Found in src/torchio/transforms/preprocessing/spatial/resample.py - About 2 hrs to fix

                          Function plot_volume has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def plot_volume(
                              image: Image,
                              radiological=True,
                              channel=-1,  # default to foreground for binary maps
                              axes=None,
                          Severity: Minor
                          Found in src/torchio/visualization.py - About 2 hrs 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

                          File histogram_standardization.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          from pathlib import Path
                          from typing import Callable
                          from typing import Dict
                          from typing import Iterable
                          from typing import Optional

                            Function _get_subjects has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _get_subjects(
                                    self,
                                    root_dir: Path,
                                    train: bool,
                                    ignore_empty: bool,
                            Severity: Minor
                            Found in src/torchio/datasets/rsna_miccai.py - About 2 hrs 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 get_subjects_from_batch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def get_subjects_from_batch(batch: Dict) -> List:
                                """Get list of subjects from collated batch.
                            
                                Args:
                                    batch: Dictionary generated by a :class:`tio.SubjectsLoader`
                            Severity: Minor
                            Found in src/torchio/utils.py - About 2 hrs 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 apply_transform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def apply_transform(self, subject: Subject) -> Subject:
                                    if self.check_shape:
                                        subject.check_consistent_spatial_shape()
                                    default_value: float
                                    for image in self.get_images(subject):
                            Severity: Minor
                            Found in src/torchio/transforms/augmentation/spatial/random_affine.py - About 1 hr 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

                            Severity
                            Category
                            Status
                            Source
                            Language