def length(streamlines, affine=None): """ Calculate the lengths of many streamlines in a bundle. Parameters ---------- streamlines : list Each item in the list is an array with 3D coordinates of a streamline. affine : 4 x 4 array An affine transformation to move the fibers by, before computing their lengths. Returns ------- Iterator object which then computes the length of each streamline in the bundle, upon iteration. """ if affine is not None: streamlines = move_streamlines(streamlines, affine) return map(metrics.length, streamlines)