make_traversal_order#
- pypulseqpp.make_traversal_order()[source]#
Return the order in which a loop visits
npositions.The result is a permutation
pofrange(n): the loop visits positionp[0]first,p[1]second, and so on. The positions are abstract indices, typically slices, or the entries of a list of selected lines or partitions;[items[i] for i in p]reorders such a list.- Parameters:
n (int) – Number of positions.
order ({'sequential', 'reverse', 'interleaved', 'center_out', 'outside_in', 'random'}, default='sequential') – Traversal scheme.
'interleaved'visits the even positions and then the odd ones, the conventional multi-slice order.'center_out'starts at the middle position and alternates outward, the lower position first on a tie;'outside_in'is its reverse.'random'is a seeded random permutation.seed (int, default=0) – Seed for
order='random'.
- Returns:
Integer permutation of
range(n), in visiting order.- Return type:
- Raises:
ValueError – If
nis negative ororderis unknown.
See also
make_cartesian_axis_samplingselection of the views on one axis.
make_centric_orderassignment of views to echo trains.
Examples
>>> import pypulseqpp as pp >>> pp.make_traversal_order(6, "interleaved").tolist() [0, 2, 4, 1, 3, 5]
The permutation reorders an existing list, here the partitions of a stack-of-stars acquisition:
>>> partitions = [10, 11, 12, 13, 14] >>> order = pp.make_traversal_order(len(partitions), "center_out") >>> order.tolist() [2, 1, 3, 0, 4] >>> [partitions[i] for i in order] [12, 11, 13, 10, 14]