Skip to content

Commit

Permalink
Merge 446309b into 3291840
Browse files Browse the repository at this point in the history
  • Loading branch information
adelavega committed Jul 16, 2020
2 parents 3291840 + 446309b commit 0dd2c88
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions pliers/extractors/misc.py
Expand Up @@ -5,29 +5,28 @@
from pliers.stimuli.misc import SeriesStim
from pliers.extractors.base import Extractor, ExtractorResult
from pliers.utils import listify, isiterable
import scipy
import numpy as np
import pandas as pd
from importlib import import_module
import logging


class MetricExtractor(Extractor):
''' Extracts summary metrics from SeriesStim using numpy, scipy or custom
''' Extracts summary metrics from SeriesStim using numpy, scipy or custom
functions
Args:
functions (str, functions or list): function, string referring to
functions (str, functions or list): function, string referring to
absolute import path for a function (e.g. 'numpy.mean') or lambda.
Function must operate on 1-dimensional numpy arrays and return a
Function must operate on 1-dimensional numpy arrays and return a
scalar. A list of functions or import strings may also be passed.
var_names (list): optional list of custom alias names for each metric
subset_idx (list): subset of Series index labels to compute metric on.
kwargs: named arguments for function call
'''
'''

_input_type = SeriesStim
_log_attributes = ('functions', 'subset_idx')

def __init__(self, functions=None, var_names=None,
def __init__(self, functions=None, var_names=None,
subset_idx=None, **kwargs):
functions = listify(functions)
if var_names is not None:
Expand All @@ -53,8 +52,8 @@ def __init__(self, functions=None, var_names=None,
self.functions = functions
self.kwargs = kwargs
self.subset_idx = subset_idx
super(MetricExtractor, self).__init__()
super().__init__()

def _extract(self, stim):
outputs = []
if self.subset_idx is not None:
Expand All @@ -73,5 +72,3 @@ def _extract(self, stim):
metrics = np.array(metrics)
outputs.append(metrics)
return ExtractorResult([outputs], stim, self, self.var_names)


0 comments on commit 0dd2c88

Please sign in to comment.