def get_segments(pv_inds):
    """ Get the start and end indices for each segment

    :param pv_inds: A list of list of indices corresponding to certain cycle points.
                    Each outer list contain information about the same point type.
                    E.g. pv_inds[0] gives peak indices, pv_inds[1] gives valley indices.
    :type pv_inds: iterable[ iterable[ int ] ]

    :returns: inds1 and inds2 giving the start and end index for the segment.
              They have the same structure as pv_inds
    :rtype: iterable[ iterable[ int ] ]
    """

    # Find end of segments
    inds2 = [pv[:] for pv in pv_inds[1:]]
    inds2.append(pv_inds[0][1:])

    # Find start of segments (we must ensure that we don't start a segment that
    # has no end index, hence [:len(i2)]
    inds1 = [pv[:len(i2)] for pv, i2 in zip(pv_inds, inds2)]  # Start of segment

    return inds1, inds2