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_x
andtest_x
should be lists of ndarrays, e.g., if you have 50 functional modes, thentrain_x
is a list of 50 (n_train, n_voxels) ndarrays.train_y
andtest_y
are individual task maps (of a given contrast), e.g.,train_y
is a (n_train, n_voxels) array.- It returns a dictionary of predicted task maps
{"train": pred_train, "test": pred_test}
, wherepred_train
andpred_test
each 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_y
have the same types/formats as inbaseline.py
.rest_ic
can either be an Int, specifying the number of independent compoenents that each array intrain_x
should be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}
, wheretrain_ic
andtest_ic
are precomputed (and concatenated) mixing matrices.task_ic
can either be an Int, specifying the number of independent compoenents thattrain_y
should be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}
, wheretrain_ic
andtest_ic
are precomputed mixing matrix of the given task contrast.- It returns a dictionary of predicted task maps
{"train": pred_train, "test": pred_test}
, wherepred_train
andpred_test
each 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_x
andtest_x
should be lists of ndarrays, e.g., if you have 50 functional modes, thentrain_x
is a list of 50 (n_train, n_voxels) ndarrays.train_y
andtest_y
are individual task maps (of a given contrast), e.g.,train_y
is a (n_train, n_voxels) array.rest_ic
can either be an Int, specifying the number of independent compoenents that each array intrain_x
should be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}
, wheretrain_ic
andtest_ic
are precomputed (and concatenated) mixing matrices.task_ic
can either be an Int, specifying the number of independent compoenents thattrain_y
should be reduced to, or be a dictionary{"train": train_ic, "test": test_ic}
, wheretrain_ic
andtest_ic
are precomputed mixing matrix of the given task contrast.residualise
specifies 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_train
andpred_test
each is a n_subject x n_voxels array.