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
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
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
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
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
File utils.py
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import ast
import gzip
import inspect
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
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
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
- Read upRead up
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.
- Read upRead up
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:
- Read upRead up
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
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
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,
- Read upRead up
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,
- Read upRead up
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`
- Read upRead up
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):
- Read upRead up
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"