File utils.py
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import ast
import gzip
import os
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 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 create_dummy_dataset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_dummy_dataset(
num_images: int,
size_range: Tuple[int, int],
directory: Optional[TypePath] = None,
suffix: str = '.nii.gz',
- 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_to_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_transform_to_file(
Function create_dummy_dataset
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_dummy_dataset(
Function guess_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def guess_type(string: str) -> Any:
# Adapted from
# https://www.reddit.com/r/learnpython/comments/4599hl/module_to_guess_type_from_a_string/czw3f5s
string = string.replace(' ', '')
result_type: Any
- 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
Avoid too many return
statements within this function. Open
return slicer_path
Avoid too many return
statements within this function. Open
return Path(itk_snap_which)
Avoid too many return
statements within this function. Open
return None # for mypy
Avoid too many return
statements within this function. Open
return Path(slicer_which)