mbfmri.utils.report¶
Report module is for make plots or brainmaps from the raw outputs of model-based MVPA. There are two types of reporting module: FitReporter and PostReporter. FitReporter is for reporting every fit results by calculating relevant metric, e.g. “mse.” PostReporter is for making reports of the entire analysis after the total fitting in repeated cross-validation is done. You can configure the FitReporter by giving the list of metrics and the key values in the below metric_function_dict is the pool of available metrics. Similarly, PostReporter can be configured by refering report_function_dict. The parameter defined in the below dictionaries means the list of configuring parameters for corresponding report, e.g. ‘voxel_mask’, ‘standardize’ for ‘brainmap’. It can be used by just giving by keyworded input while initiating the reporter object. Please note that if this module is executed in the wrapper, run_mbfmri, the required input like voxel_mask will be automatically routed in the process of run_mbfmri.
from mbfmri.utils.report import PostReporter
voxel_mask = {NII file of voxel mask} #(generated by VoxelFeautureGenerator)
pr = PostReporter(reports=['brainmap', 'pearsonr'],
voxel_mask=nib.load(voxel_mask),
standardize=False,smoothing_fwhm=0,
pval_threshold=0.05,)
pr.run()
Making brain map from coefficients (betas).
report_function_dict¶
module means class implementing the reporting function in mbfmri.utils.report_utils. data means list of names of data required for the function. ‘{repetition}-{fold}_{data}’ found in REPORT_ROOT/raw_data aggregated by fold-by-fold and run the function (this is done by aggregate function). parameter means list of names of configuring of metainfo parameter. default means dictionary of default value of each parameter if applicable.
'brainmap':{
'module':Report_BrainMap,
'data':['weights'],
'parameter':['voxel_mask',
'experiment_name',
'standardize',
'map_smoothing_fwhm',
'map_threshold',
'cluster_threshold'],
'default':{'experiment_name':'unnamed',
'standardize':False,
'map_smoothing_fwhm':6,
'map_threshold':0,
'cluster_threshold':0
}
},
'r':{
'module':Plot_R,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':['pval_threshold'],
'default':{'pval_threshold':.01}
},
'pearsonr':{
'module':Plot_PearsonR,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':['pval_threshold'],
'default':{'pval_threshold':.01}
},
'spearmanr':{
'module':Plot_SpearmanR,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':['pval_threshold'],
'default':{'pval_threshold':.01}
},
'mse':{
'module':Plot_MSE,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'accuracy':{
'module':Plot_Accuracy,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'roc':{
'module':Plot_ROC,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'elasticnet':{
'module':Plot_ElasticNet,
'data':['cv_mean_score',
'cv_standard_error',
'lambda_path',
'lambda_best',
'coef_path'],
'parameter':['confidence_interval',
'n_coef_plot'],
'default':{'confidence_interval':.99,
'n_coef_plot':'all'
},
}
metric_function_dict¶
module means class implementing the metric function in mbfmri.utils.report_utils. data means list of names of data required for the function. The data will be directly fed by mbfmri.models.mvpa_general.MVPA_CV at the end of fitting for each fold. parameter means list of names of configuring of metainfo parameter. default means dictionary of default value of each parameter if applicable.
'mse':{
'module':Metric_MSE,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'r':{
'module':Metric_R,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'pearsonr':{
'module':Metric_PearsonR,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'spearmanr':{
'module':Metric_SpearmanR,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'auc':{
'module':Metric_AUC,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
},
'accuracy':{
'module':Metric_Accuracy,
'data':['y_train',
'y_test',
'pred_train',
'pred_test'],
'parameter':[],
'default':{}
}
- mbfmri.utils.report.aggregate(search_path, names, invalid_ids=[])¶
find files including input names this function is for navigating raw results from analysis
- class mbfmri.utils.report.PostReporter(reports=['brainmap'], **kwargs)¶
Bases:
objectPostReporter aggregates fitting results by name and makes reports. Several helpful reports are implemented and users can input which kinds of reports should be made for their purposes.
- Parameters
reports (list of str, default=[“brainmap”]) – List of name for reporting function. “brainmap”, “r”, “pearsonr”, “spearmanr”, “mse”, “accuracy”, “roc”, “elasticnet” are available
Some of them require additional arguments like “voxel_mask” in “brainmap.” Please refer to the document.
- run(search_path='.', save=True, save_path='.')¶
- class mbfmri.utils.report.FitReporter(metrics=[], **kwargs)¶
Bases:
objectFitReporter calculates metrics for the fitted result in each fold of cross-validation. Several metrics are implemented and users can input which kinds of reports should be made for their purposes.
- Parameters
metrics (list of str, default=[]) – List of name for metric function. “r”, “pearsonr”, “spearmanr”, “mse”, “accuracy”, “auc” are available
- run(**kwargs)¶