Skip to content

Commit

Permalink
a fix for iterating CTS twice
Browse files Browse the repository at this point in the history
  • Loading branch information
qmac committed Jun 1, 2018
1 parent f13698e commit 4e938d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pliers/stimuli/text.py
Expand Up @@ -195,8 +195,10 @@ def __iter__(self):
""" Iterate text elements. """
for elem in self._elements:
offset = 0.0 if self.onset is None else self.onset
elem.onset = offset if elem.onset is None else offset + elem.onset
yield elem
# Calculate element onset relative to this stimulus
rel_onset = offset if elem.onset is None else offset + elem.onset
yield TextStim(elem.filename, elem.text, rel_onset, elem.duration,
elem.order)

def _to_tup(self, sec):
hours = int(sec / 3600)
Expand Down
1 change: 1 addition & 0 deletions pliers/tests/test_stims.py
Expand Up @@ -148,6 +148,7 @@ def test_complex_text_stim():
stim = ComplexTextStim(join(text_dir, 'complex_stim_no_header.txt'),
columns='ot', default_duration=0.2, onset=4.2)
assert stim.elements[2].onset == 38.2
assert stim.elements[1].onset == 24.2
stim = ComplexTextStim(join(text_dir, 'complex_stim_with_header.txt'))
assert len(stim.elements) == 4
assert stim.elements[2].duration == 0.1
Expand Down

0 comments on commit 4e938d7

Please sign in to comment.