Combine Single Target Results - pwollstadt/IDTxl GitHub Wiki

First, let's load the single target analysis dictionaries using pickle. In this example, the dictionaries res.0.pkl, res.1.pkl, res.2.pkl will be loaded from my_directory:

import pickle

# Set target numbers to combine
targets = [0, 1, 2]

# Load results using pickle
res_list = []
for target_id in targets:
    path = 'my_directory/res.{}.pkl'.format(str(target_id))
    res_list.append(pickle.load(open(path, 'rb')))

When combining the results, we can either perform the FDR correction (Benjamini et al. (1995)):

from idtxl.stats import network_fdr
res = network_fdr({'alpha_fdr': 0.05}, *res_list)

Or we can combine them withouth performing the FDR correction:

res = res_list[0]
res.combine_results(*res_list[1:])