Results package¶
Loading of results saved by Analyzer
subclasses.
sekupy.results.base module¶
- sekupy.results.base.aggregate_searchlight(path, dir_id, filter)[source]¶
This should be used for a within subject analysis to collect data from different folders / subjects and collect results.
Be aware of the different parameters of the analysis.
So the best approach is to use get_searchlight_results and then use that to aggregate.
- sekupy.results.base.dataframe_to_afni(dataframe, outpath=None, command='3dttest++', label_attr='task', **filter)[source]¶
This should return a command or similar to perform statistics in AFNI
Use filter to select fields of interest
- sekupy.results.base.filter_dataframe(dataframe, return_mask=False, return_null=False, **selection_dict)[source]¶
- sekupy.results.base.get_configuration_fields(conf, *args)[source]¶
This function is used to collect fields from the configuration file.
- sekupy.results.base.get_connectivity_results(path, dir_id, field_list=['sample_slicer'], load_cv=False)[source]¶
- sekupy.results.base.get_permutation_values(dataframe, keys, scores=['accuracy'], permutation_key='permutation')[source]¶
- sekupy.results.base.get_results(path, pipeline_name, field_list=['sample_slicer'], result_keys=None, filter=None, n_jobs=-1, verbose=1)[source]¶
This function is used to collect the results from analysis folders.
- Parameters:
path (str) – The pathname of the folder in which results are stored
pipeline_name (str) – The id / pattern to be used to filter folders. It is often the id of the Analysis Pipeline used.
field_list (list, optional) – List of different condition used by the AnalysisIterator (the default is [‘sample_slicer’], which is a fields of the configuration)
result_keys (list, optional) – List of strings indicating the other fields to get from the result (e.g. cross_validation folds)
filter (dictionary, optional) –
This is used to filter dataset and include only fields or conditions. See
`sekupy.preprocessing.SampleSlicer`for an example of dictionary(the default is None, which [default_description])
- Returns:
dataframe – A table of the results in pandas format
- Return type:
pandas dataframe
- sekupy.results.base.get_searchlight_results(path, pipeline_name, field_list=['sample_slicer'], load_cv=False)[source]¶
- sekupy.results.base.get_values(path, directory, field_list, result_keys)[source]¶
Extract analysis results and configuration from a results directory.
This function reads configuration and result files from an analysis directory and extracts specified fields and scores for further analysis.
- Parameters:
- Returns:
List of dictionaries containing extracted field values and scores
- Return type:
sekupy.results.bids module¶
- sekupy.results.bids.get_results_bids(path, field_list=['sample_slicer'], result_keys=[], scores=['score'], n_jobs=-1, verbose=1, filter=None, get_function=<function get_values_bids>, subjects=None, **kwargs)[source]¶
This function is used to collect the results from analysis folders.
- Parameters:
path (str) – The pathname of the folder in which results are stored
field_list (list, optional) – List of different condition used by the AnalysisIterator (the default is [‘sample_slicer’], which is a fields of the configuration)
result_keys (list, optional) – List of strings indicating the other fields to get from the result (e.g. cross_validation folds)
filter (dictionary, optional) –
This is used to filter dataset and include only fields or conditions. See
`sekupy.preprocessing.SampleSlicer`for an example of dictionary(the default is None, which [default_description])
scores (list, optional) – Use mse and corr for regression, score for basic decoding
get_function (fx, optional) – The fucntion used to load data
subjects (list, optional) – List of string representing subject’s results to be loaded.
**kwargs (dictionary, optional) – List of parameters used to filter BIDS folder by ‘pipeline’ for example.
- Returns:
dataframe – A table of the results in pandas format
- Return type:
pandas dataframe
- sekupy.results.bids.get_searchlight_results_bids(path, field_list=['sample_slicer'], **kwargs)[source]¶
sekupy.results.dataframe module¶
- sekupy.results.dataframe.apply_function(dataframe, keys, attr='features', fx=<function <lambda>>, **fx_kwargs)[source]¶
This function executes an operation on the dataframe, it groups the dataframe by using the keys parameter and applies a function to values indicated by attr.
- Parameters:
dataframe (pandas Dataframe) – The dataframe to be processed by the function
keys (list of string) – The keys that should be used to group the dataframe. These keys are those that were preserved in the output.
attr (str, optional) – The key were values should be found (the default is ‘features’)
fx (function, optional) – The function that is applied to values. (the default is lambda x:np.vstack(x).sum(0))
fx_kwargs (dictionary, optional) – Arguments passed to the fx function.
- Returns:
dataframe
- Return type:
The processed dataframe.
- sekupy.results.dataframe.clean_dataframe(dataframe, keys=[])[source]¶
Clean columns that are not informative. A list with keys can be provided to delete unuseful columns.
- Parameters:
dataframe ([type]) – [description]
- sekupy.results.dataframe.dataframe_slicer(data, row=None, col=None, hue=None)[source]¶
Generator for name indices and data subsets for each unique value of row, col, hue.
Adaptively stolen from seaborn.
- Yields:
(i, j, k), data_ijk (tuple of ints, DataFrame) – The ints provide an index into the {row, col, hue}_names attribute, and the dataframe contains a subset of the full data corresponding to each facet. The generator yields subsets that correspond with the self.axes.flat iterator, or self.axes[i, j] when col_wrap is None.
sekupy.results.simulations module¶
- sekupy.results.simulations.calculate_centroids(dataframe)[source]¶
Returns the centroid of a clustering experiment
- Parameters:
X (n_samples x n_features array) – The full dataset used for clustering
labels (n_samples array) – The clustering labels for each sample.
- Returns:
centroids – The centroids of the clusters.
- Return type:
n_cluster x n_features shaped array
- sekupy.results.simulations.calculate_metrics(dataframe, metrics_kwargs=None, fixed_variables={})[source]¶
This function calculates the metrics that will be used to identify the number of clusters.
- Parameters:
dataframe (a pandas dataframe) – The dataframe must contain the field
`n_states`, it is supposed to have other fields with unique values (e.g. to identify the analysis)metrics_kwargs (dictionary, optional) – dictionary with other metrics, by default None
fixed_variables (dict, optional) – Variables that will be added to output dataframe, usually they are fields that identify a single analysis, and are used to filter the dataframe, by default {}
- Returns:
A dataframe with a number of rows equal to the number of k specified in n_states column of the original dataframe. The single entry is composed by the metric name, the metric value and the associated k, plus fixed_variables given as input parameter.
- Return type:
dataframe
- sekupy.results.simulations.get_results(path, field_list=['sample_slicer'], result_keys=[], n_jobs=-1, verbose=1, filter={}, **kwargs)[source]¶
This function is used to collect the results from analysis folders.
- Parameters:
path (str) – The pathname of the folder in which results are stored
field_list (list, optional) – List of different condition used by the AnalysisIterator (the default is [‘sample_slicer’], which is a fields of the configuration)
result_keys (list, optional) – List of strings indicating the other fields to get from the result (e.g. cross_validation folds)
filter (dictionary, optional) –
This is used to filter dataset and include only fields or conditions. See
`sekupy.preprocessing.SampleSlicer`for an example of dictionary(the default is None, which [default_description])
scores (list, optional) – Use mse and corr for regression, score for basic decoding
**kwargs (dictionary, optional) – List of parameters used to filter BIDS folder by ‘pipeline’ for example.
- Returns:
dataframe – A table of the results in pandas format
- Return type:
pandas dataframe