pliers.extractors.ExtractorResult

class pliers.extractors.ExtractorResult(data, stim, extractor, features=None, onsets=None, durations=None, orders=None)[source]

Bases: object

Stores feature data produced by an Extractor.

Parameters
  • data (ndarray, iterable) – Extracted feature data. Either an ndarray (1-d or 2-d), an iterable, or a raw result. If a raw result is passed, the source Extractor must implement _to_df().

  • stim (Stim) – The input Stim object from which features were extracted.

  • extractor (Extractor) – The Extractor object used in extraction.

  • features (list, ndarray) – Optional names of extracted features. If passed, must have as many elements as there are columns in data.

  • onsets (list, ndarray) – Optional iterable giving the onsets of the rows in data. Length must match the input data.

  • durations (list, ndarray) – Optional iterable giving the durations associated with the rows in data.

  • orders (list, ndarray) – Optional iterable giving the integer orders associated with the rows in data.

__init__(data, stim, extractor, features=None, onsets=None, durations=None, orders=None)[source]
property data

Creates a DataFrame with default arguments

property history

Returns the transformation history for the input Stim.

property raw

Stores raw result of extraction, prior to postprocessing done in to_df().

to_df(timing=True, metadata=False, format='wide', extractor_name=False, object_id=True, extractor_params=False, **to_df_kwargs)[source]

Convert current instance to a pandas DatasFrame.

Parameters
  • timing (bool) – If True, adds columns for event onset and duration. Note that these columns will be added even if there are no valid values in the current object (NaNs will be inserted). If ‘auto’, timing columns are only inserted if there’s at least one valid (i.e., non-NaN) onset/order/duration.

  • metadata (bool) – If True, adds columns for key metadata (including the name, filename, class, history, and source file of the Stim).

  • format (str) – Format to return the data in. Can be either ‘wide’ or ‘long’. In the wide case, every extracted feature is a column, and every result object is in a row. In the long case, every row contains a single record/feature combination.

  • extractor_name (bool) – If True, includes the Extractor name as a column (in ‘long’ format) or index level (in ‘wide’ format).

  • object_id (bool) – If True, attempts to intelligently add an ‘object_id’ column that differentiates between multiple objects in the results that may share onsets and durations (and would otherwise be impossible to distinguish). This frequently occurs for ImageExtractors that identify multiple target objects (e.g., faces) within a single ImageStim. In addition to boolean values, the special value ‘auto’ can be passed, in which case the object_id column will only be inserted if the resulting constant would be non-constant.

  • extractor_params (bool) – if True, returns log_attributes of at extraction time, as stored in transformer_params attribute in ExtractorResult.history. These are returned as serialized dictionary in extractor_params column.

Returns

A pandas DataFrame.