Skip to content

Commit 8d604e8

Browse files
committed
FIX: Fix ImportError in test_reports.py
1 parent 9edf34c commit 8d604e8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

petprep/interfaces/reports.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,42 @@
4343

4444
LOGGER = logging.getLogger('nipype.interface')
4545

46+
_ORI_TO_NAME = {
47+
'L': 'Left',
48+
'R': 'Right',
49+
'A': 'Anterior',
50+
'P': 'Posterior',
51+
'S': 'Superior',
52+
'I': 'Inferior',
53+
}
54+
55+
_OPPOSITE = {
56+
'L': 'R',
57+
'R': 'L',
58+
'A': 'P',
59+
'P': 'A',
60+
'S': 'I',
61+
'I': 'S',
62+
}
63+
64+
65+
def get_world_pedir(orientation: str, pe_dir: str) -> str:
66+
"""Return the world phase-encoding direction."""
67+
68+
orientation = orientation.upper()
69+
axis = pe_dir[0].lower()
70+
idx = {'i': 0, 'j': 1, 'k': 2}[axis]
71+
letter = orientation[idx]
72+
73+
if pe_dir.endswith('-'):
74+
start = letter
75+
end = _OPPOSITE[letter]
76+
else:
77+
start = _OPPOSITE[letter]
78+
end = letter
79+
80+
return f"{_ORI_TO_NAME[start]}-{_ORI_TO_NAME[end]}"
81+
4682
SUBJECT_TEMPLATE = """\
4783
\t<ul class="elem-desc">
4884
\t\t<li>Subject ID: {subject_id}</li>

0 commit comments

Comments
 (0)