Skip to content

Commit 57740e1

Browse files
committed
Normalize nipy parameters
1 parent 6fdaa42 commit 57740e1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

nipype/utils/misc.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,25 @@ def unflatten(in_list, prev_structure):
248248
def normalize_mc_params(params, source):
249249
"""
250250
Normalize a single row of motion parameters to the SPM format.
251+
252+
SPM saves motion parameters as:
253+
x Right-Left (mm)
254+
y Anterior-Posterior (mm)
255+
z Superior-Inferior (mm)
256+
rx Pitch (rad)
257+
ry Yaw (rad)
258+
rz Roll (rad)
251259
"""
252-
if source == 'FSL':
260+
if source.upper() == 'FSL':
253261
params = params[[3, 4, 5, 0, 1, 2]]
254-
elif source in ('AFNI', 'FSFAST'):
262+
elif source.upper() in ('AFNI', 'FSFAST'):
255263
params = params[np.asarray([4, 5, 3, 1, 2, 0]) + (len(params) > 6)]
256264
params[3:] = params[3:] * np.pi / 180.
257-
return params
265+
elif source.upper() == 'NIPY':
266+
from nipy.algorithms.registration import to_matrix44, aff2euler
267+
matrix = to_matrix44(params)
268+
params = np.zeros(6)
269+
params[:3] = M[:3, 3]
270+
params[-1:2:-1] = aff2euler(matrix)
271+
272+
return params

0 commit comments

Comments
 (0)