Skip to content

Commit bc833e3

Browse files
committed
feat: Rewrite pe_info creation more compactly
1 parent b4a01f6 commit bc833e3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

sdcflows/transform.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,12 @@ def apply(
490490
ro_time *= n_volumes
491491

492492
pe_info = []
493-
for volid in range(n_volumes):
494-
pe_axis = 'ijk'.index(pe_dir[volid][0])
495-
axis_flip = axcodes[pe_axis] in ('LPI')
496-
pe_flip = pe_dir[volid].endswith('-')
497-
498-
pe_info.append(
499-
(
500-
pe_axis,
501-
# Displacements are reversed if either is true (after ensuring positive cosines)
502-
-ro_time[volid] if (axis_flip ^ pe_flip) else ro_time[volid],
503-
)
504-
)
493+
for vol_pe_dir, vol_ro_time in zip(pe_dir, ro_time):
494+
pe_axis = 'ijk'.index(vol_pe_dir[0])
495+
# Displacements are reversed if either is true (after ensuring positive cosines)
496+
flip = (axcodes[pe_axis] in 'LPI') ^ vol_pe_dir.endswith('-')
497+
498+
pe_info.append((pe_axis, -vol_ro_time if flip else vol_ro_time))
505499

506500
# Reference image's voxel coordinates (in voxel units)
507501
voxcoords = (

0 commit comments

Comments
 (0)