In [1]:
%matplotlib inline
import numpy as np
import seaborn as sns
In [2]:
from neurosynth.base.dataset import Dataset
dataset = Dataset.load("data/neurosynth_60_0.4.pkl")
The following two functions are all that is necessary to perform this analysis:
coactivation_contrast
peforms the analysis and returns an image for each region in the analysis. For each region, voxels in the image are those that co-activated to a greater extent with that region, than other regions in the analysis.
make_thresholded_slices
takes a list of images and overlays them using nilearn's plot_roi
In [3]:
from coactivation import coactivation_contrast
from plotting import make_thresholded_slices
In [4]:
cut_coords = np.arange(-15, 60, 12) # I use the same z coordinates for each axial plot
In [5]:
contrast_mas = coactivation_contrast(
dataset, 'images/cluster_labels_k3.nii.gz', q = 0.001)
make_thresholded_slices(contrast_mas, sns.color_palette('Set1', 3),
cut_coords=cut_coords, annotate=False)
Out[5]:
In [6]:
# Here I define the groupings
posterior = [3, 6]
middle = [1, 5, 7, 9]
anterior = [2, 4, 8]
In [7]:
from plotting import nine_colors
contrast_mas = coactivation_contrast(
dataset, 'images/cluster_labels_k9.nii.gz', posterior)
colors = list(reversed([c for i, c in enumerate(nine_colors) if i + 1 in posterior]))
make_thresholded_slices(list(reversed(contrast_mas)), colors,
cut_coords=cut_coords, annotate=False)
Out[7]:
In [8]:
make_thresholded_slices(list(reversed(contrast_mas)), colors,
cut_coords=range(-60, 50, 18), display_mode='y', annotate=False)
Out[8]:
In [9]:
contrast_mas = coactivation_contrast(
dataset, 'images/cluster_labels_k9.nii.gz', middle)
colors = [c for i, c in enumerate(nine_colors) if i + 1 in middle]
make_thresholded_slices(contrast_mas, colors,
cut_coords=cut_coords, annotate=False)
Out[9]:
In [10]:
make_thresholded_slices(contrast_mas, colors, cut_coords=range(-60, 50, 18), display_mode='y', annotate=False)
Out[10]:
In [11]:
contrast_mas = coactivation_contrast(
dataset, 'images/cluster_labels_k9.nii.gz', anterior)
colors = [c for i, c in enumerate(nine_colors) if i + 1 in anterior]
make_thresholded_slices(contrast_mas, colors,
cut_coords=cut_coords, annotate=False)
Out[11]:
In [12]:
make_thresholded_slices(contrast_mas, colors, cut_coords=range(-60, 50, 18),
display_mode='y', annotate=False)
Out[12]: