neuroscout/populate/annotate.py
def load(self, res):
        """" Load and annotate features in an extractor result object.
        Args:
            res - Pliers ExtractorResult object

        Returns a dictionary of annotated features
        """
        res_df = res.to_df(format='long')
        if self.object_id == 'max':
            res_df = res_df[res_df.object_id == res_df.object_id.max()]
        features = res_df['feature'].unique().tolist()

        # Find matching extractor schema + attribute combination
        # Entries with no attributes will match any
        ext_schema = {}
        for candidate in self.schema.get(res.extractor.name, []):
            for name, value in candidate.get("attributes", {}).items():
                if getattr(res.extractor, name) != value:
                    break
            else:
                ext_schema = candidate

        # Determine resample frequency. False value will skip
        resample_frequency = self.resample_frequency
        if resample_frequency is None:
            resample_frequency = ext_schema.get('resample_frequency', False)

        # Resample events if
        if resample_frequency:
            res_df = resample(res_df, resample_frequency)

        annotated = []
        # Add all features in schema, popping features that match
        for pattern, schema in ext_schema.get('features', {}).items():
            matching = list(filter(re.compile(pattern).match, features))
            features = set(features) - set(matching)
            for feat in matching:
                annotated += self._annotate_feature(
                    pattern, schema, feat, res.extractor,
                    res_df[res_df.feature == feat],
                    resample_frequency=resample_frequency)

        # Add all remaining features
        if self.add_all is True:
            for feat in features:
                annotated += self._annotate_feature(
                    ".*", {}, feat, res.extractor,
                    res_df[res_df.feature == feat], default_active=False,
                    resample_frequency=resample_frequency)

        # Add extractor constants
        tr_attrs = [getattr(res.extractor, a)
                    for a in res.extractor._log_attributes]
        constants = {
            "extractor_name": res.extractor.name,
            "extractor_parameters": str(dict(
                zip(res.extractor._log_attributes, tr_attrs))),
            "extractor_version": res.extractor.VERSION,
            "modality": stim_map.get(res.extractor._input_type.__name__, '')
        }

        for ee, ef in annotated:
            ef.update(constants)

        return annotated
 Load and annotate features in an extractor result object.
        Args:
            res - Pliers ExtractorResult object

        Returns a dictionary of annotated features
        
Load and annotate features in an extractor result object.
Args:
res - Pliers ExtractorResult object

Returns a dictionary of annotated features
Load and annotate features in an extractor result object . Args : res - Pliers ExtractorResult object Returns a dictionary of annotated features
def load(self, res):
        res_df = res.to_df(format='long')
        if self.object_id == 'max':
            res_df = res_df[res_df.object_id == res_df.object_id.max()]
        features = res_df['feature'].unique().tolist()
        ext_schema = {}
        for candidate in self.schema.get(res.extractor.name, []):
            for name, value in candidate.get("attributes", {}).items():
                if getattr(res.extractor, name) != value:
                    break
            else:
                ext_schema = candidate
        resample_frequency = self.resample_frequency
        if resample_frequency is None:
            resample_frequency = ext_schema.get('resample_frequency', False)
        if resample_frequency:
            res_df = resample(res_df, resample_frequency)
        annotated = []
        for pattern, schema in ext_schema.get('features', {}).items():
            matching = list(filter(re.compile(pattern).match, features))
            features = set(features) - set(matching)
            for feat in matching:
                annotated += self._annotate_feature(
                    pattern, schema, feat, res.extractor,
                    res_df[res_df.feature == feat],
                    resample_frequency=resample_frequency)
        if self.add_all is True:
            for feat in features:
                annotated += self._annotate_feature(
                    ".*", {}, feat, res.extractor,
                    res_df[res_df.feature == feat], default_active=False,
                    resample_frequency=resample_frequency)
        tr_attrs = [getattr(res.extractor, a)
                    for a in res.extractor._log_attributes]
        constants = {
            "extractor_name": res.extractor.name,
            "extractor_parameters": str(dict(
                zip(res.extractor._log_attributes, tr_attrs))),
            "extractor_version": res.extractor.VERSION,
            "modality": stim_map.get(res.extractor._input_type.__name__, '')
        }
        for ee, ef in annotated:
            ef.update(constants)
        return annotated
def load ( self , res ) : res_df = res . to_df ( format = 'long' ) if self . object_id == 'max' : res_df = res_df [ res_df . object_id == res_df . object_id . max ( ) ] features = res_df [ 'feature' ] . unique ( ) . tolist ( ) ext_schema = { } for candidate in self . schema . get ( res . extractor . name , [ ] ) : for name , value in candidate . get ( "attributes" , { } ) . items ( ) : if getattr ( res . extractor , name ) != value : break else : ext_schema = candidate resample_frequency = self . resample_frequency if resample_frequency is None : resample_frequency = ext_schema . get ( 'resample_frequency' , False ) if resample_frequency : res_df = resample ( res_df , resample_frequency ) annotated = [ ] for pattern , schema in ext_schema . get ( 'features' , { } ) . items ( ) : matching = list ( filter ( re . compile ( pattern ) . match , features ) ) features = set ( features ) - set ( matching ) for feat in matching : annotated += self . _annotate_feature ( pattern , schema , feat , res . extractor , res_df [ res_df . feature == feat ] , resample_frequency = resample_frequency ) if self . add_all is True : for feat in features : annotated += self . _annotate_feature ( ".*" , { } , feat , res . extractor , res_df [ res_df . feature == feat ] , default_active = False , resample_frequency = resample_frequency ) tr_attrs = [ getattr ( res . extractor , a ) for a in res . extractor . _log_attributes ] constants = { "extractor_name" : res . extractor . name , "extractor_parameters" : str ( dict ( zip ( res . extractor . _log_attributes , tr_attrs ) ) ) , "extractor_version" : res . extractor . VERSION , "modality" : stim_map . get ( res . extractor . _input_type . __name__ , '' ) } for ee , ef in annotated : ef . update ( constants ) return annotated
Load and annotate features in an extractor result object.
Load and annotate features in an extractor result object .
"""" Load and annotate features in an extractor result object.
        Args:
            res - Pliers ExtractorResult object

        Returns a dictionary of annotated features
        """ # Find matching extractor schema + attribute combination # Entries with no attributes will match any # Determine resample frequency. False value will skip # Resample events if # Add all features in schema, popping features that match # Add all remaining features # Add extractor constants
self
res