Encoding¶
Encode text from Rubin et al. (2017) into images.
Start with the necessary imports¶
from os.path import join
from nilearn import plotting
from gclda.model import Model
from gclda.decode import encode
from gclda.utils import get_resource_path
Out:
Bootstrapped meta-analyses are enabled.
Load model¶
model_file = join(get_resource_path(), 'models/Neurosynth2015Filtered2',
'model_200topics_2015Filtered2_10000iters.pklz')
model = Model.load(model_file)
model.display_model_summary()
Out:
--- Model Summary ---
Current State:
Current Iteration = 10000
Initialization Seed = 1
Current Log-Likely = -11268037.3695
Model Hyper-Parameters:
Symmetric = True
n_topics = 200
n_regions = 2
alpha = 0.100
beta = 0.010
gamma = 0.010
delta = 1.000
roi_size = 50.000
dobs = 25
Model Training-Data Information:
Dataset Label = Neurosynth2015Filtered2
Word-Tokens (n_word_tokens) = 520492
Peak-Tokens (n_peak_tokens) = 400801
Word-Types (n_word_labels) = 6755
Documents (n_docs) = 11362
Peak-Dimensions (n_peak_dims) = 3
First text¶
text = 'motor'
text_img, _ = encode(model, text)
fig = plotting.plot_stat_map(text_img, display_mode='z',
threshold=0.00001,
cut_coords=[-18, 4, 32, 60])
Second text¶
text = 'effort difficult demands'
text_img, _ = encode(model, text)
fig = plotting.plot_stat_map(text_img, display_mode='z',
threshold=0.00001,
cut_coords=[-30, -4, 26, 50])
Third text¶
text = 'painful stimulation during a language task'
text_img, _ = encode(model, text)
fig = plotting.plot_stat_map(text_img, display_mode='z',
threshold=0.00001,
cut_coords=[-2, 22, 44, 66])
Total running time of the script: ( 0 minutes 59.833 seconds)