Passed
Push — master ( 4133e1...824ae8 )
by Fernando
06:45
created

torchio.data.orientation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A name_dimensions() 0 6 2
1
import warnings
2
import nibabel as nib
3
4
5
AXCODES_TO_WORDS = {
6
    'L': 'left',
7
    'R': 'right',
8
    'P': 'posterior',
9
    'A': 'anterior',
10
    'I': 'inferior',
11
    'S': 'superior',
12
    # 'C': 'caudal',
13
    # 'R': 'rostral',  # conflic with right
14
    # 'D': 'dorsal',
15
    # 'V': 'ventral',
16
}
17
18
19
def name_dimensions(tensor, affine):
20
    axcodes = nib.aff2axcodes(affine)
21
    names = [AXCODES_TO_WORDS[axcode] for axcode in axcodes]
22
    with warnings.catch_warnings():
23
        warnings.simplefilter('ignore', UserWarning)
24
        tensor.rename_(*names)
25