This is the repository for https://www.biorxiv.org/content/10.1101/2021.08.19.456783v1.
baseline.py contains the baseline model. For a given task contrast, it seeks to find a linear combination of functional modes to reconstruct the task contrast map for each individual.
from baseline import baseline
baseline_predictions = baseline(train_x, train_y, test_x, test_y)train_xandtest_xshould be lists of ndarrays, e.g., if you have 50 functional modes, thentrain_xis a list of 50 (n_train, n_voxels) ndarrays.train_yandtest_yare individual task maps (of a given contrast), e.g.,train_yis a (n_train, n_voxels) array.- It returns a dictionary of predicted task maps
{"train": pred_train, "test": pred_test}, wherepred_trainandpred_testeach is a n_subject x n_voxels array.
sparse.py contains the sparse model. It introduces more spatial complexity to the baseline mode.
from sparse import sparse
sparse_predictions = sparse(train_x, train_y, test_x, test_y, rest_ic=800, task_ic=800, n_jobs=1, alpha=1)train_x,train_y,test_x, andtest_yhave the same types/formats as inbaseline.py.rest_iccan either be an Int, specifying the number of independent compoenents that each array intrain_xshould be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}, wheretrain_icandtest_icare precomputed (and concatenated) mixing matrices.task_iccan either be an Int, specifying the number of independent compoenents thattrain_yshould be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}, wheretrain_icandtest_icare precomputed mixing matrix of the given task contrast.- It returns a dictionary of predicted task maps
{"train": pred_train, "test": pred_test}, wherepred_trainandpred_testeach is a n_subject x n_voxels array.
ensemble.py runs the baseline model and the sparse model and combines them to give a single set of predictions.
from ensemble import ensemble
ensemble_predictions = ensemble(train_x, train_y, test_x, test_y, rest_ic=800, task_ic=800, residualise=True, n_jobs=-1)train_xandtest_xshould be lists of ndarrays, e.g., if you have 50 functional modes, thentrain_xis a list of 50 (n_train, n_voxels) ndarrays.train_yandtest_yare individual task maps (of a given contrast), e.g.,train_yis a (n_train, n_voxels) array.rest_iccan either be an Int, specifying the number of independent compoenents that each array intrain_xshould be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}, wheretrain_icandtest_icare precomputed (and concatenated) mixing matrices.task_iccan either be an Int, specifying the number of independent compoenents thattrain_yshould be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}, wheretrain_icandtest_icare precomputed mixing matrix of the given task contrast.residualisespecifies whether to run the model on residuals (and add the group-averaged back in at the end) or on the original data.- It returns a dictionary of predicted task maps
{"train": pred_train, "test": pred_test}, wherepred_trainandpred_testeach is a n_subject x n_voxels array.