Add consecutive_frames (previously removed by Nils)
@@ -230,3 +230,18 @@ class MantaScalar(DerivedStream):
def frames(self, datasource):
return self.stream.frames(datasource)
+
+
+def consecutive_frames(channel, n):
+ """
+Constructs n DataChannels to load a consequtive sequence of frames.
+For each sequence, the i-th DataChannel loads the i-th frame in that sequence.
+The number of sequences depends on the number of frames contained in each source.
+
+The frames of each source are assumed to be ordered and without frame gaps.
+Every DataSource accessed through these channels must contain at least n frames.
+ :param channel: Source channel holding the data
+ :param n: Number of frames to load
+ :return: tuple containing n DataChannels
+ """
+ return tuple([FrameSelect(lambda frames, i=i: frames[i:i-n+1+len(frames)], channel) for i in range(n)])
