Showing 106 of 106 total issues
File image.py
has 784 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 512 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_labels_to_image.py
has 418 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 random_affine.py
has 415 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 io.py
has 382 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 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import copy
import pprint
from typing import Any
File queue.py
has 347 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
File utils.py
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import ast
import gzip
import os
Image
has 30 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 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
File random_motion.py
has 274 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
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
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
File histogram_standardization.py
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
from pathlib import Path
from typing import Callable
from typing import Dict
from typing import Optional
from typing import Sequence
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:`torch.utils.data.DataLoader`
- 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"