pliers.stimuli.ComplexTextStim

class pliers.stimuli.ComplexTextStim(filename=None, onset=None, duration=None, columns=None, default_duration=None, elements=None, text=None, unit='word', tokenizer=None, language='english')[source]

Bases: Stim

A collection of text stims (e.g., a story), typically ordered and with onsets and/or durations associated with each element.

Parameters
  • filename (str) – The filename to read from. Must be tab-delimited text. Files must always contain a column containing the text of each stimulus in the collection. Optionally, additional columns can be included that contain duration and onset information. If a header row is present in the file, valid columns must be labeled as ‘text’, ‘onset’, and ‘duration’ where available (though only text is mandatory). If no header is present in the file, the columns argument will be used to infer the indices of the key columns.

  • onset (float) – Optional onset of the ComplexTextStim relative to some more general context.

  • duration (float) – Optional duration of the ComplexTextStim withing some more general context.

  • columns (str) – Optional specification of column order. An abbreviated string denoting the column position of text, onset, and duration in the file. Use t for text, o for onset, d for duration. For example, passing ‘ot’ indicates that the first column contains the onsets and the second contains the text. E.g., passing ‘tod’ indicates that the first three columns contain text, onset, and duration information, respectively. Note that if the input file contains a header row, the columns argument will be ignored.

  • default_duration (float) – the duration to assign to any text elements in the collection that do not have an explicit value provided in the input file.

  • elements (list) – An optional list of TextStims that comprise the ComplexTextStim. If both the filename and elements arguments are passed, the TextStims in elements will be appended to the ones extracted from the file.

  • text (str) – Optional multi-token string to convert to a ComplexTextStim.

  • unit (str) – The unit of segmentation. Either ‘word’ or ‘sentence’. Ignored if text is None.

  • tokenizer – Optional tokenizer to use if initializing from text. If passed, will override the default nltk tokenizers. If a string is passed, it is interpreted as a capturing regex and passed to re.findall(). Otherwise, must be an object that implements a tokenize() method and returns a list of tokens. Ignored if text is None.

  • language (str) – The language to use; passed to nltk. Only used if tokenizer is None. Defaults to English. Ignored if text is None.

__init__(filename=None, onset=None, duration=None, columns=None, default_duration=None, elements=None, text=None, unit='word', tokenizer=None, language='english')[source]
get_filename()

Return the source filename of the current Stim.

property history

Return stimulus history.