neuroscout/populate/extract.py
def extract_features(graphs, dataset_name=None, task_name=None, n_jobs=1,
                     **serializer_kwargs):
    """ Extract features using pliers for a dataset/task
        Args:
            graphs - List of Graphs to apply to stimuli
            dataset_name - dataset name (optional;)
            task_name - task name (optional)
            serializer_kwargs - Arguments to pass to FeatureSerializer
        Output:
            list of db ids of extracted features
    """
    serializer = FeatureSerializer(**serializer_kwargs)

    # If no dataset is specified extract for all datasets recursively
    if dataset_name is None:
        return [extract_features(
            graphs, dataset.name, None, **serializer_kwargs)
                for dataset in Dataset.query.filter_by(active=True)]

    # Load Pliers Graph objects
    graphs = [Graph(g) for g in graphs]

    stims = _query_stim_models(dataset_name, task_name, graphs=graphs)

    # Apply graphs to each stim_object in parallel
    with parallel_backend('multiprocessing'):
        with tqdm_joblib(tqdm(desc="Extracting...", total=len(stims))):
            results = Parallel(n_jobs=n_jobs)(
                delayed(_extract_to_serial)(
                    graphs, s, serializer) for s in stims)

    # Flatten
    results = [item for sublist in results for item in sublist]

    if not results:
        raise ValueError("No features could be extracted")

    # Insert resultsw to db as ExtractedFeatures
    ext_feats = _create_efs(results)

    # Create Predictors for ExtractedFeatures
    return create_predictors(
        [ef for ef in ext_feats.values() if ef.active],
        dataset_name, task_name)
 Extract features using pliers for a dataset/task
        Args:
            graphs - List of Graphs to apply to stimuli
            dataset_name - dataset name (optional;)
            task_name - task name (optional)
            serializer_kwargs - Arguments to pass to FeatureSerializer
        Output:
            list of db ids of extracted features
    
Extract features using pliers for a dataset/task
Args:
graphs - List of Graphs to apply to stimuli
dataset_name - dataset name (optional;)
task_name - task name (optional)
serializer_kwargs - Arguments to pass to FeatureSerializer
Output:
list of db ids of extracted features
Extract features using pliers for a dataset / task Args : graphs - List of Graphs to apply to stimuli dataset_name - dataset name ( optional ; ) task_name - task name ( optional ) serializer_kwargs - Arguments to pass to FeatureSerializer Output : list of db ids of extracted features
def extract_features(graphs, dataset_name=None, task_name=None, n_jobs=1,
                     **serializer_kwargs):
    serializer = FeatureSerializer(**serializer_kwargs)
    if dataset_name is None:
        return [extract_features(
            graphs, dataset.name, None, **serializer_kwargs)
                for dataset in Dataset.query.filter_by(active=True)]
    graphs = [Graph(g) for g in graphs]
    stims = _query_stim_models(dataset_name, task_name, graphs=graphs)
    with parallel_backend('multiprocessing'):
        with tqdm_joblib(tqdm(desc="Extracting...", total=len(stims))):
            results = Parallel(n_jobs=n_jobs)(
                delayed(_extract_to_serial)(
                    graphs, s, serializer) for s in stims)
    results = [item for sublist in results for item in sublist]
    if not results:
        raise ValueError("No features could be extracted")
    ext_feats = _create_efs(results)
    return create_predictors(
        [ef for ef in ext_feats.values() if ef.active],
        dataset_name, task_name)
def extract_features ( graphs , dataset_name = None , task_name = None , n_jobs = 1 , ** serializer_kwargs ) : serializer = FeatureSerializer ( ** serializer_kwargs ) if dataset_name is None : return [ extract_features ( graphs , dataset . name , None , ** serializer_kwargs ) for dataset in Dataset . query . filter_by ( active = True ) ] graphs = [ Graph ( g ) for g in graphs ] stims = _query_stim_models ( dataset_name , task_name , graphs = graphs ) with parallel_backend ( 'multiprocessing' ) : with tqdm_joblib ( tqdm ( desc = "Extracting..." , total = len ( stims ) ) ) : results = Parallel ( n_jobs = n_jobs ) ( delayed ( _extract_to_serial ) ( graphs , s , serializer ) for s in stims ) results = [ item for sublist in results for item in sublist ] if not results : raise ValueError ( "No features could be extracted" ) ext_feats = _create_efs ( results ) return create_predictors ( [ ef for ef in ext_feats . values ( ) if ef . active ] , dataset_name , task_name )
Extract features using pliers for a dataset/task
Args:
graphs - List of Graphs to apply to stimuli
dataset_name - dataset name (optional;)
task_name - task name (optional)
serializer_kwargs - Arguments to pass to FeatureSerializer
Output:
list of db ids of extracted features
Extract features using pliers for a dataset / task Args : graphs - List of Graphs to apply to stimuli dataset_name - dataset name ( optional ; ) task_name - task name ( optional ) serializer_kwargs - Arguments to pass to FeatureSerializer Output : list of db ids of extracted features
""" Extract features using pliers for a dataset/task
        Args:
            graphs - List of Graphs to apply to stimuli
            dataset_name - dataset name (optional;)
            task_name - task name (optional)
            serializer_kwargs - Arguments to pass to FeatureSerializer
        Output:
            list of db ids of extracted features
    """ # If no dataset is specified extract for all datasets recursively # Load Pliers Graph objects # Apply graphs to each stim_object in parallel # Flatten # Insert resultsw to db as ExtractedFeatures # Create Predictors for ExtractedFeatures
graphs
dataset_name
task_name
n_jobs