def extract(self, extractors, merge_events=True): timeline = Timeline() for ext in extractors: events = ext.apply(self) for ev in events: timeline.add_event(ev, merge=merge_events) return timeline
def extract(self, extractors, merge_events=True): timeline = Timeline() # Extractors can either take ComplexTextStim input, in which case we # pass the current instance, or TextStim input, in which case we loop # over all elements. for ext in extractors: if ext.target.__name__ == self.__class__.__name__: events = ext.apply(self) for ev in events: timeline.add_event(ev, merge=merge_events) else: for elem in self.elements: # If no onset is available, index with order onset = elem.onset or elem.order event = Event(onset=onset, values=[ext.apply(elem)]) timeline.add_event(event, merge=merge_events) return timeline
def extract(self, extractors, merge_events=True, **kwargs): period = 1. / self.fps timeline = Timeline(period=period) for ext in extractors: # For VideoExtractors, pass the entire stim if ext.target.__name__ == self.__class__.__name__: events = ext.apply(self, **kwargs) for ev in events: timeline.add_event(ev, merge=merge_events) # Otherwise, for images, loop over frames else: c = 0 for frame in self: if frame.data is not None: event = Event(onset=c * period) event.add_value(ext.apply(frame)) timeline.add_event(event, merge=merge_events) c += 1 return timeline