| Total Complexity | 2 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |