Independet Component Analysis with Nilearn (depressiv subjects)¶
from nilearn.decomposition import CanICA
from nilearn.plotting import plot_prob_atlas
from nilearn.image import iter_img
from nilearn.plotting import plot_stat_map, show, plot_prob_atlas, plot_matrix, plot_connectome, find_probabilistic_atlas_cut_coords
/home/jt/.local/lib/python3.8/site-packages/nilearn/datasets/__init__.py:86: FutureWarning: Fetchers from the nilearn.datasets module will be updated in version 0.9 to return python strings instead of bytes and Pandas dataframes instead of Numpy arrays.
warn("Fetchers from the nilearn.datasets module will be "
Data import¶
We are working with 2 different datasets, so we created a list with the corresponding files. We exluded 3 subjects, subject 17, 39 and 48 because of to much movement or artefacts.
files_list=[]
all_list=list(range(1,73))
healthy_list=list(range(52,73))
dep_list=list(range(1,52))
exclution_list=[17,39,48]
for i in dep_list:
if i not in exclution_list:
j="{:02d}".format(i)
files_list.append("/media/jt/Daten1/preproc/datasink/smooth/sub-"+j+"/task-restingstatewithclosedeyes/fwhm-8_swarsub-"+j+"_task-rest_bold.nii")
Checking the subject list if everything worked well. In this case we are working with the depressiv group.
for i in files_list:
print (i)
/media/jt/Daten1/preproc/datasink/smooth/sub-01/task-restingstatewithclosedeyes/fwhm-8_swarsub-01_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-02/task-restingstatewithclosedeyes/fwhm-8_swarsub-02_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-03/task-restingstatewithclosedeyes/fwhm-8_swarsub-03_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-04/task-restingstatewithclosedeyes/fwhm-8_swarsub-04_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-05/task-restingstatewithclosedeyes/fwhm-8_swarsub-05_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-06/task-restingstatewithclosedeyes/fwhm-8_swarsub-06_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-07/task-restingstatewithclosedeyes/fwhm-8_swarsub-07_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-08/task-restingstatewithclosedeyes/fwhm-8_swarsub-08_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-09/task-restingstatewithclosedeyes/fwhm-8_swarsub-09_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-10/task-restingstatewithclosedeyes/fwhm-8_swarsub-10_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-11/task-restingstatewithclosedeyes/fwhm-8_swarsub-11_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-12/task-restingstatewithclosedeyes/fwhm-8_swarsub-12_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-13/task-restingstatewithclosedeyes/fwhm-8_swarsub-13_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-14/task-restingstatewithclosedeyes/fwhm-8_swarsub-14_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-15/task-restingstatewithclosedeyes/fwhm-8_swarsub-15_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-16/task-restingstatewithclosedeyes/fwhm-8_swarsub-16_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-18/task-restingstatewithclosedeyes/fwhm-8_swarsub-18_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-19/task-restingstatewithclosedeyes/fwhm-8_swarsub-19_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-20/task-restingstatewithclosedeyes/fwhm-8_swarsub-20_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-21/task-restingstatewithclosedeyes/fwhm-8_swarsub-21_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-22/task-restingstatewithclosedeyes/fwhm-8_swarsub-22_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-23/task-restingstatewithclosedeyes/fwhm-8_swarsub-23_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-24/task-restingstatewithclosedeyes/fwhm-8_swarsub-24_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-25/task-restingstatewithclosedeyes/fwhm-8_swarsub-25_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-26/task-restingstatewithclosedeyes/fwhm-8_swarsub-26_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-27/task-restingstatewithclosedeyes/fwhm-8_swarsub-27_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-28/task-restingstatewithclosedeyes/fwhm-8_swarsub-28_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-29/task-restingstatewithclosedeyes/fwhm-8_swarsub-29_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-30/task-restingstatewithclosedeyes/fwhm-8_swarsub-30_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-31/task-restingstatewithclosedeyes/fwhm-8_swarsub-31_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-32/task-restingstatewithclosedeyes/fwhm-8_swarsub-32_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-33/task-restingstatewithclosedeyes/fwhm-8_swarsub-33_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-34/task-restingstatewithclosedeyes/fwhm-8_swarsub-34_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-35/task-restingstatewithclosedeyes/fwhm-8_swarsub-35_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-36/task-restingstatewithclosedeyes/fwhm-8_swarsub-36_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-37/task-restingstatewithclosedeyes/fwhm-8_swarsub-37_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-38/task-restingstatewithclosedeyes/fwhm-8_swarsub-38_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-40/task-restingstatewithclosedeyes/fwhm-8_swarsub-40_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-41/task-restingstatewithclosedeyes/fwhm-8_swarsub-41_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-42/task-restingstatewithclosedeyes/fwhm-8_swarsub-42_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-43/task-restingstatewithclosedeyes/fwhm-8_swarsub-43_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-44/task-restingstatewithclosedeyes/fwhm-8_swarsub-44_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-45/task-restingstatewithclosedeyes/fwhm-8_swarsub-45_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-46/task-restingstatewithclosedeyes/fwhm-8_swarsub-46_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-47/task-restingstatewithclosedeyes/fwhm-8_swarsub-47_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-49/task-restingstatewithclosedeyes/fwhm-8_swarsub-49_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-50/task-restingstatewithclosedeyes/fwhm-8_swarsub-50_task-rest_bold.nii
/media/jt/Daten1/preproc/datasink/smooth/sub-51/task-restingstatewithclosedeyes/fwhm-8_swarsub-51_task-rest_bold.nii
Run ICA¶
Now we are running the ICA (indipendent component analysis with 20 different components. We made this twice, once with the depressiv group and once with the healthy control group.
canica = CanICA(n_components=20,
memory="/media/jt/Daten1/preproc/ICA_nilearn/nilearn_cache", memory_level=2,
verbose=10,
smoothing_fwhm=8,
n_jobs=-2,
mask_strategy='template',
random_state=0)
canica.fit(files_list)
# Retrieve the independent components in brain space. Directly
# accesible through attribute `components_img_`.
canica_components_img = canica.components_img_
# components_img is a Nifti Image object, and can be saved to a file with
# the following line:
canica_components_img.to_filename('//media/jt/Daten1/preproc/ICA_nilearn/canica_resting_state_dep.nii.gz')
[MultiNiftiMasker.fit] Loading data from [/media/jt/Daten1/preproc/datasink/smooth/sub-01/task-restingstatewithclosedeyes/fwhm-8_swarsub-01_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-02/task-restingstatewithclosedeyes/fwhm-8_swarsub-02_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-03/task-restingstatewithclosedeyes/fwhm-8_swarsub-03_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-04/task-restingstatewithclosedeyes/fwhm-8_swarsub-04_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-05/task-restingstatewithclosedeyes/fwhm-8_swarsub-05_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-06/task-restingstatewithclosedeyes/fwhm-8_swarsub-06_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-07/task-restingstatewithclosedeyes/fwhm-8_swarsub-07_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-08/task-restingstatewithclosedeyes/fwhm-8_swarsub-08_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-09/task-restingstatewithclosedeyes/fwhm-8_swarsub-09_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-10/task-restingstatewithclosedeyes/fwhm-8_swarsub-10_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-11/task-restingstatewithclosedeyes/fwhm-8_swarsub-11_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-12/task-restingstatewithclosedeyes/fwhm-8_swarsub-12_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-13/task-restingstatewithclosedeyes/fwhm-8_swarsub-13_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-14/task-restingstatewithclosedeyes/fwhm-8_swarsub-14_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-15/task-restingstatewithclosedeyes/fwhm-8_swarsub-15_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-16/task-restingstatewithclosedeyes/fwhm-8_swarsub-16_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-18/task-restingstatewithclosedeyes/fwhm-8_swarsub-18_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-19/task-restingstatewithclosedeyes/fwhm-8_swarsub-19_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-20/task-restingstatewithclosedeyes/fwhm-8_swarsub-20_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-21/task-restingstatewithclosedeyes/fwhm-8_swarsub-21_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-22/task-restingstatewithclosedeyes/fwhm-8_swarsub-22_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-23/task-restingstatewithclosedeyes/fwhm-8_swarsub-23_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-24/task-restingstatewithclosedeyes/fwhm-8_swarsub-24_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-25/task-restingstatewithclosedeyes/fwhm-8_swarsub-25_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-26/task-restingstatewithclosedeyes/fwhm-8_swarsub-26_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-27/task-restingstatewithclosedeyes/fwhm-8_swarsub-27_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-28/task-restingstatewithclosedeyes/fwhm-8_swarsub-28_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-29/task-restingstatewithclosedeyes/fwhm-8_swarsub-29_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-30/task-restingstatewithclosedeyes/fwhm-8_swarsub-30_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-31/task-restingstatewithclosedeyes/fwhm-8_swarsub-31_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-32/task-restingstatewithclosedeyes/fwhm-8_swarsub-32_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-33/task-restingstatewithclosedeyes/fwhm-8_swarsub-33_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-34/task-restingstatewithclosedeyes/fwhm-8_swarsub-34_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-35/task-restingstatewithclosedeyes/fwhm-8_swarsub-35_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-36/task-restingstatewithclosedeyes/fwhm-8_swarsub-36_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-37/task-restingstatewithclosedeyes/fwhm-8_swarsub-37_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-38/task-restingstatewithclosedeyes/fwhm-8_swarsub-38_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-40/task-restingstatewithclosedeyes/fwhm-8_swarsub-40_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-41/task-restingstatewithclosedeyes/fwhm-8_swarsub-41_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-42/task-restingstatewithclosedeyes/fwhm-8_swarsub-42_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-43/task-restingstatewithclosedeyes/fwhm-8_swarsub-43_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-44/task-restingstatewithclosedeyes/fwhm-8_swarsub-44_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-45/task-restingstatewithclosedeyes/fwhm-8_swarsub-45_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-46/task-restingstatewithclosedeyes/fwhm-8_swarsub-46_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-47/task-restingstatewithclosedeyes/fwhm-8_swarsub-47_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-49/task-restingstatewithclosedeyes/fwhm-8_swarsub-49_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-50/task-restingstatewithclosedeyes/fwhm-8_swarsub-50_task-rest_bold.nii,
/media/jt/Daten1/preproc/datasink/smooth/sub-51/task-restingstatewithclosedeyes/fwhm-8_swarsub-51_task-rest_bold.nii]
[MultiNiftiMasker.fit] Computing mask
Template mask computation
[MultiNiftiMasker.transform] Resampling mask
[CanICA] Loading data
/home/jt/.local/lib/python3.8/site-packages/nilearn/masking.py:627: UserWarning: Persisting input arguments took 0.71s to run.
If this happens often in your code, it can cause performance problems
(results will be correct in all cases).
The reason for this is probably some large input arguments for a wrapped
function (e.g. large strings).
THIS IS A JOBLIB ISSUE. If you can, kindly provide the joblib's team with an
example so that they can fix the problem.
resampled_template = cache(resample_to_img, memory)(template, target_img)
________________________________________________________________________________
[Memory] Calling sklearn.utils.extmath.randomized_svd...
randomized_svd(array([[ 0.001254, ..., 0.00049 ],
...,
[ 0.00032 , ..., -0.002165]]), n_components=20, transpose=True, random_state=0, n_iter=3)
/home/jt/.local/lib/python3.8/site-packages/nilearn/decomposition/multi_pca.py:180: UserWarning: Persisting input arguments took 2.48s to run.
If this happens often in your code, it can cause performance problems
(results will be correct in all cases).
The reason for this is probably some large input arguments for a wrapped
function (e.g. large strings).
THIS IS A JOBLIB ISSUE. If you can, kindly provide the joblib's team with an
example so that they can fix the problem.
components_, self.variance_, _ = self._cache(
__________________________________________________randomized_svd - 11.6s, 0.2min
[Parallel(n_jobs=-2)]: Using backend LokyBackend with 7 concurrent workers.
[Parallel(n_jobs=-2)]: Done 3 out of 10 | elapsed: 1.2s remaining: 2.9s
[Parallel(n_jobs=-2)]: Done 5 out of 10 | elapsed: 1.4s remaining: 1.4s
[Parallel(n_jobs=-2)]: Done 7 out of 10 | elapsed: 1.6s remaining: 0.7s
[Parallel(n_jobs=-2)]: Done 10 out of 10 | elapsed: 1.8s finished
/home/jt/.local/lib/python3.8/site-packages/nilearn/image/image.py:1054: FutureWarning: The parameter "sessions" will be removed in 0.9.0 release of Nilearn. Please use the parameter "runs" instead.
data = signal.clean(
In case you don’t make this whole script in one time you can start here now loading the created ICA file to continue.
# Only run for plotting without processing or further processing of the ICA data without CanICA them again
canica_components_img="/media/jt/Daten1/preproc/ICA_nilearn/canica_resting_state_dep.nii.gz"
ICA plotting¶
Here we plot the calculated components by CanICA.
# Plot all ICA components together
plot_prob_atlas(canica_components_img, title='All ICA components')
/usr/local/lib/python3.8/dist-packages/numpy/ma/core.py:2825: UserWarning: Warning: converting a masked element to nan.
_data = np.array(data, dtype=dtype, copy=copy,
/home/jt/.local/lib/python3.8/site-packages/nilearn/plotting/displays.py:101: UserWarning: No contour levels were found within the data range.
im = getattr(ax, type)(data_2d.copy(),
/home/jt/.local/lib/python3.8/site-packages/nilearn/plotting/displays.py:101: UserWarning: linewidths is ignored by contourf
im = getattr(ax, type)(data_2d.copy(),
<nilearn.plotting.displays.OrthoSlicer at 0x7fde1b7b1160>
#plot the different slices of components
for i, cur_img in enumerate(iter_img(canica_components_img)):
plot_stat_map(cur_img, display_mode="z", title="IC %d" % i,
cut_coords=1, colorbar=False)
Region extraction¶
Next step is to extract the different regions of the 20 components. Therefore we used the nilearn region extractor with a min region size of 2000. That corresponds to about 100 voxel (2x2x5mm voxel size).
components_img=canica_components_img
# Import Region Extractor algorithm from regions module
# threshold=0.5 indicates that we keep nominal of amount nonzero voxels across all
# maps, less the threshold means that more intense non-voxels will be survived.
from nilearn.regions import RegionExtractor
from nilearn import datasets
atlas = datasets.fetch_atlas_msdl()
# Loading atlas image stored in 'maps'
atlas_filename = atlas['maps']
extractor = RegionExtractor(components_img, threshold=1.0,
thresholding_strategy='ratio_n_voxels',
extractor='local_regions',
standardize=True, min_region_size=2000)
# Just call fit() to process for regions extraction
extractor.fit()
# Extracted regions are stored in regions_img_
regions_extracted_img = extractor.regions_img_
# Each region index is stored in index_
regions_index = extractor.index_
# Total number of regions extracted
n_regions_extracted = regions_extracted_img.shape[-1]
# Visualization of region extraction results
title = ('%d regions are extracted from %d components.'
'\nEach separate color of region indicates extracted region'
% (n_regions_extracted, 20))
plot_prob_atlas(regions_extracted_img, view_type='filled_contours',
title=title)
/usr/local/lib/python3.8/dist-packages/numpy/lib/npyio.py:2405: VisibleDeprecationWarning: Reading unicode strings without specifying the encoding argument is deprecated. Set the encoding, use None for the system default.
output = genfromtxt(fname, **kwargs)
/home/jt/.local/lib/python3.8/site-packages/nilearn/image/image.py:1054: FutureWarning: The parameter "sessions" will be removed in 0.9.0 release of Nilearn. Please use the parameter "runs" instead.
data = signal.clean(
/usr/local/lib/python3.8/dist-packages/numpy/ma/core.py:2825: UserWarning: Warning: converting a masked element to nan.
_data = np.array(data, dtype=dtype, copy=copy,
/home/jt/.local/lib/python3.8/site-packages/nilearn/plotting/displays.py:101: UserWarning: No contour levels were found within the data range.
im = getattr(ax, type)(data_2d.copy(),
/home/jt/.local/lib/python3.8/site-packages/nilearn/plotting/displays.py:101: UserWarning: linewidths is ignored by contourf
im = getattr(ax, type)(data_2d.copy(),
<nilearn.plotting.displays.OrthoSlicer at 0x7f1f3127b700>
Timeseries extraction¶
Now we are ready to extract the different timeseries of the subjects.
# First we need to do subjects timeseries signals extraction and then estimating
# correlation matrices on those signals.
# To extract timeseries signals, we call transform() from RegionExtractor object
# onto each subject functional data stored in files_list.
# To estimate correlation matrices we import connectome utilities from nilearn
from nilearn.connectome import ConnectivityMeasure
correlations = []
# Initializing ConnectivityMeasure object with kind='correlation'
connectome_measure = ConnectivityMeasure(kind='correlation')
for filename in files_list:
# call transform from RegionExtractor object to extract timeseries signals
timeseries_each_subject = extractor.transform(filename)
# call fit_transform from ConnectivityMeasure object
correlation = connectome_measure.fit_transform([timeseries_each_subject])
# saving each subject correlation to correlations
correlations.append(correlation)
# Mean of all correlations
import numpy as np
mean_correlations = np.mean(correlations, axis=0).reshape(n_regions_extracted,
n_regions_extracted)
Atlas import¶
Importing the atlas for labeling the matrices later.
from nilearn import image
from nilearn import input_data
from nilearn import datasets
msdl_atlas_dataset = datasets.fetch_atlas_msdl()
# A "memory" to avoid recomputation
from joblib import Memory
mem = Memory('nilearn_cache')
masker = input_data.NiftiMapsMasker(
msdl_atlas_dataset.maps, resampling_target="maps", detrend=True,
high_variance_confounds=True, low_pass=None, high_pass=0.01,
t_r=2, standardize=True, memory='nilearn_cache', memory_level=1,
verbose=2)
masker.fit()
subject_time_series = []
func_filenames = files_list
for func_filename in (func_filenames):
print("Processing file %s" % func_filename)
region_ts = masker.transform(func_filename)
subject_time_series.append(region_ts)
/usr/local/lib/python3.8/dist-packages/numpy/lib/npyio.py:2405: VisibleDeprecationWarning: Reading unicode strings without specifying the encoding argument is deprecated. Set the encoding, use None for the system default.
output = genfromtxt(fname, **kwargs)
[NiftiMapsMasker.fit] loading regions from /home/jt/nilearn_data/msdl_atlas/MSDL_rois/msdl_rois.nii
/home/jt/.local/lib/python3.8/site-packages/nilearn/image/image.py:1054: FutureWarning: The parameter "sessions" will be removed in 0.9.0 release of Nilearn. Please use the parameter "runs" instead.
data = signal.clean(
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-01/task-restingstatewithclosedeyes/fwhm-8_swarsub-01_task-rest_bold.nii
[Memory]0.0s, 0.0min : Loading high_variance_confounds...
[Memory]0.1s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-02/task-restingstatewithclosedeyes/fwhm-8_swarsub-02_task-rest_bold.nii
[Memory]0.1s, 0.0min : Loading high_variance_confounds...
[Memory]0.1s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-03/task-restingstatewithclosedeyes/fwhm-8_swarsub-03_task-rest_bold.nii
[Memory]0.1s, 0.0min : Loading high_variance_confounds...
[Memory]0.2s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-04/task-restingstatewithclosedeyes/fwhm-8_swarsub-04_task-rest_bold.nii
[Memory]0.2s, 0.0min : Loading high_variance_confounds...
[Memory]0.2s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-05/task-restingstatewithclosedeyes/fwhm-8_swarsub-05_task-rest_bold.nii
[Memory]0.2s, 0.0min : Loading high_variance_confounds...
[Memory]0.3s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-06/task-restingstatewithclosedeyes/fwhm-8_swarsub-06_task-rest_bold.nii
[Memory]0.3s, 0.0min : Loading high_variance_confounds...
[Memory]0.3s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-07/task-restingstatewithclosedeyes/fwhm-8_swarsub-07_task-rest_bold.nii
[Memory]0.3s, 0.0min : Loading high_variance_confounds...
[Memory]0.3s, 0.0min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-08/task-restingstatewithclosedeyes/fwhm-8_swarsub-08_task-rest_bold.nii
[Memory]0.3s, 0.0min : Loading high_variance_confounds...
________________________________________________________________________________
[Memory] Calling nilearn.input_data.base_masker.filter_and_extract...
filter_and_extract('/media/jt/Daten1/preproc/datasink/smooth/sub-08/task-restingstatewithclosedeyes/fwhm-8_swarsub-08_task-rest_bold.nii',
<nilearn.input_data.nifti_maps_masker._ExtractionFunctor object at 0x7f1f30427f70>,
{ 'allow_overlap': True,
'detrend': True,
'dtype': None,
'high_pass': 0.01,
'high_variance_confounds': True,
'low_pass': None,
'maps_img': '/home/jt/nilearn_data/msdl_atlas/MSDL_rois/msdl_rois.nii',
'mask_img': None,
'smoothing_fwhm': None,
'standardize': True,
'standardize_confounds': True,
't_r': 2,
'target_affine': array([[ 4., 0., 0., -78.],
[ 0., 4., 0., -111.],
[ 0., 0., 4., -51.],
[ 0., 0., 0., 1.]]),
'target_shape': (40, 48, 35)}, confounds=[ array([[-0.09913 , ..., 0.10154 ],
...,
[ 0.05749 , ..., -0.089969]])], sample_mask=None, dtype=None, memory=Memory(location=nilearn_cache/joblib), memory_level=1, verbose=2)
[NiftiMapsMasker.transform_single_imgs] Loading data from /media/jt/Daten1/preproc/datasink/smooth/sub-08/task-restingstatewithclosedeyes/fwhm-8_swarsub-08_task-rest_bold.nii
[NiftiMapsMasker.transform_single_imgs] Resampling images
[NiftiMapsMasker.transform_single_imgs] Extracting region signals
[NiftiMapsMasker.transform_single_imgs] Cleaning extracted signals
_______________________________________________filter_and_extract - 6.9s, 0.1min
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-09/task-restingstatewithclosedeyes/fwhm-8_swarsub-09_task-rest_bold.nii
[Memory]7.4s, 0.1min : Loading high_variance_confounds...
[Memory]7.5s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-10/task-restingstatewithclosedeyes/fwhm-8_swarsub-10_task-rest_bold.nii
[Memory]7.5s, 0.1min : Loading high_variance_confounds...
[Memory]7.6s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-11/task-restingstatewithclosedeyes/fwhm-8_swarsub-11_task-rest_bold.nii
[Memory]7.6s, 0.1min : Loading high_variance_confounds...
[Memory]7.7s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-12/task-restingstatewithclosedeyes/fwhm-8_swarsub-12_task-rest_bold.nii
[Memory]7.7s, 0.1min : Loading high_variance_confounds...
[Memory]7.7s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-13/task-restingstatewithclosedeyes/fwhm-8_swarsub-13_task-rest_bold.nii
[Memory]7.7s, 0.1min : Loading high_variance_confounds...
[Memory]7.8s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-14/task-restingstatewithclosedeyes/fwhm-8_swarsub-14_task-rest_bold.nii
[Memory]7.8s, 0.1min : Loading high_variance_confounds...
[Memory]7.9s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-15/task-restingstatewithclosedeyes/fwhm-8_swarsub-15_task-rest_bold.nii
[Memory]7.9s, 0.1min : Loading high_variance_confounds...
[Memory]8.0s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-16/task-restingstatewithclosedeyes/fwhm-8_swarsub-16_task-rest_bold.nii
[Memory]8.0s, 0.1min : Loading high_variance_confounds...
[Memory]8.0s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-18/task-restingstatewithclosedeyes/fwhm-8_swarsub-18_task-rest_bold.nii
[Memory]8.0s, 0.1min : Loading high_variance_confounds...
[Memory]8.1s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-19/task-restingstatewithclosedeyes/fwhm-8_swarsub-19_task-rest_bold.nii
[Memory]8.1s, 0.1min : Loading high_variance_confounds...
[Memory]8.2s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-20/task-restingstatewithclosedeyes/fwhm-8_swarsub-20_task-rest_bold.nii
[Memory]8.2s, 0.1min : Loading high_variance_confounds...
[Memory]8.3s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-21/task-restingstatewithclosedeyes/fwhm-8_swarsub-21_task-rest_bold.nii
[Memory]8.3s, 0.1min : Loading high_variance_confounds...
[Memory]8.4s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-22/task-restingstatewithclosedeyes/fwhm-8_swarsub-22_task-rest_bold.nii
[Memory]8.4s, 0.1min : Loading high_variance_confounds...
[Memory]8.4s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-23/task-restingstatewithclosedeyes/fwhm-8_swarsub-23_task-rest_bold.nii
[Memory]8.4s, 0.1min : Loading high_variance_confounds...
[Memory]8.5s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-24/task-restingstatewithclosedeyes/fwhm-8_swarsub-24_task-rest_bold.nii
[Memory]8.5s, 0.1min : Loading high_variance_confounds...
[Memory]8.6s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-25/task-restingstatewithclosedeyes/fwhm-8_swarsub-25_task-rest_bold.nii
[Memory]8.6s, 0.1min : Loading high_variance_confounds...
[Memory]8.7s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-26/task-restingstatewithclosedeyes/fwhm-8_swarsub-26_task-rest_bold.nii
[Memory]8.7s, 0.1min : Loading high_variance_confounds...
[Memory]8.7s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-27/task-restingstatewithclosedeyes/fwhm-8_swarsub-27_task-rest_bold.nii
[Memory]8.7s, 0.1min : Loading high_variance_confounds...
[Memory]8.8s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-28/task-restingstatewithclosedeyes/fwhm-8_swarsub-28_task-rest_bold.nii
[Memory]8.8s, 0.1min : Loading high_variance_confounds...
[Memory]8.9s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-29/task-restingstatewithclosedeyes/fwhm-8_swarsub-29_task-rest_bold.nii
[Memory]8.9s, 0.1min : Loading high_variance_confounds...
[Memory]9.0s, 0.1min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-30/task-restingstatewithclosedeyes/fwhm-8_swarsub-30_task-rest_bold.nii
[Memory]9.0s, 0.1min : Loading high_variance_confounds...
[Memory]9.0s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-31/task-restingstatewithclosedeyes/fwhm-8_swarsub-31_task-rest_bold.nii
[Memory]9.0s, 0.2min : Loading high_variance_confounds...
[Memory]9.1s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-32/task-restingstatewithclosedeyes/fwhm-8_swarsub-32_task-rest_bold.nii
[Memory]9.1s, 0.2min : Loading high_variance_confounds...
[Memory]9.2s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-33/task-restingstatewithclosedeyes/fwhm-8_swarsub-33_task-rest_bold.nii
[Memory]9.2s, 0.2min : Loading high_variance_confounds...
[Memory]9.3s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-34/task-restingstatewithclosedeyes/fwhm-8_swarsub-34_task-rest_bold.nii
[Memory]9.3s, 0.2min : Loading high_variance_confounds...
[Memory]9.3s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-35/task-restingstatewithclosedeyes/fwhm-8_swarsub-35_task-rest_bold.nii
[Memory]9.3s, 0.2min : Loading high_variance_confounds...
[Memory]9.4s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-36/task-restingstatewithclosedeyes/fwhm-8_swarsub-36_task-rest_bold.nii
[Memory]9.4s, 0.2min : Loading high_variance_confounds...
[Memory]9.5s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-37/task-restingstatewithclosedeyes/fwhm-8_swarsub-37_task-rest_bold.nii
[Memory]9.5s, 0.2min : Loading high_variance_confounds...
[Memory]9.6s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-38/task-restingstatewithclosedeyes/fwhm-8_swarsub-38_task-rest_bold.nii
[Memory]9.6s, 0.2min : Loading high_variance_confounds...
[Memory]9.6s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-40/task-restingstatewithclosedeyes/fwhm-8_swarsub-40_task-rest_bold.nii
[Memory]9.6s, 0.2min : Loading high_variance_confounds...
[Memory]9.7s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-41/task-restingstatewithclosedeyes/fwhm-8_swarsub-41_task-rest_bold.nii
[Memory]9.7s, 0.2min : Loading high_variance_confounds...
[Memory]9.8s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-42/task-restingstatewithclosedeyes/fwhm-8_swarsub-42_task-rest_bold.nii
[Memory]9.8s, 0.2min : Loading high_variance_confounds...
[Memory]9.9s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-43/task-restingstatewithclosedeyes/fwhm-8_swarsub-43_task-rest_bold.nii
[Memory]9.9s, 0.2min : Loading high_variance_confounds...
[Memory]9.9s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-44/task-restingstatewithclosedeyes/fwhm-8_swarsub-44_task-rest_bold.nii
[Memory]9.9s, 0.2min : Loading high_variance_confounds...
[Memory]10.0s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-45/task-restingstatewithclosedeyes/fwhm-8_swarsub-45_task-rest_bold.nii
[Memory]10.0s, 0.2min : Loading high_variance_confounds...
[Memory]10.1s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-46/task-restingstatewithclosedeyes/fwhm-8_swarsub-46_task-rest_bold.nii
[Memory]10.1s, 0.2min : Loading high_variance_confounds...
[Memory]10.2s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-47/task-restingstatewithclosedeyes/fwhm-8_swarsub-47_task-rest_bold.nii
[Memory]10.2s, 0.2min : Loading high_variance_confounds...
[Memory]10.2s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-49/task-restingstatewithclosedeyes/fwhm-8_swarsub-49_task-rest_bold.nii
[Memory]10.2s, 0.2min : Loading high_variance_confounds...
[Memory]10.3s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-50/task-restingstatewithclosedeyes/fwhm-8_swarsub-50_task-rest_bold.nii
[Memory]10.3s, 0.2min : Loading high_variance_confounds...
[Memory]10.4s, 0.2min : Loading filter_and_extract...
Processing file /media/jt/Daten1/preproc/datasink/smooth/sub-51/task-restingstatewithclosedeyes/fwhm-8_swarsub-51_task-rest_bold.nii
[Memory]10.4s, 0.2min : Loading high_variance_confounds...
[Memory]10.5s, 0.2min : Loading filter_and_extract...
Correlation matrices and connectomes¶
We use two different ways to compute the precision and correlation, GraphicalLassoCV and GroupSparseCovarianceCV.
from nilearn.connectome import GroupSparseCovarianceCV
gsc = GroupSparseCovarianceCV(verbose=2)
gsc.fit(subject_time_series)
try:
from sklearn.covariance import GraphicalLassoCV
except ImportError:
# for Scitkit-Learn < v0.20.0
from sklearn.covariance import GraphLassoCV as GraphicalLassoCV
gl = GraphicalLassoCV(verbose=2)
gl.fit(np.concatenate(subject_time_series))
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 5
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 9.1s remaining: 0.0s
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 1
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 5
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 5
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 11
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 5
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 16
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] [GroupSparseCovarianceCV] Done refinement 1 out of 4
[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 49.7s finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 9
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 16.9s remaining: 0.0s
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 7
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 8
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 8
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 0
[GroupSparseCovarianceCV.fit] [GroupSparseCovarianceCV] Done refinement 2 out of 4
[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 1.4min finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 10
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 17.1s remaining: 0.0s
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 8
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 9
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 9
[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 1.3min finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GroupSparseCovarianceCV.fit] [GroupSparseCovarianceCV] Done refinement 3 out of 4
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 14
[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 16.2s remaining: 0.0s
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 12
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 6
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 6
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 7
[GroupSparseCovarianceCV.fit] Log-likelihood on test set is decreasing. Stopping at iteration 13
[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 1.2min finished
[GroupSparseCovarianceCV.fit] [GroupSparseCovarianceCV] Done refinement 4 out of 4
[GroupSparseCovarianceCV.fit] Final optimization
[GroupSparseCovarianceCV.fit] tolerance reached at iteration number 27: 8.554e-04
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
....[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.5s remaining: 0.0s
................[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 2.3s finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
.
[GraphicalLassoCV] Done refinement 1 out of 4: 2s
...[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.6s remaining: 0.0s
................[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 2.4s finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GraphicalLassoCV] Done refinement 2 out of 4: 4s
....[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.5s remaining: 0.0s
................[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 2.2s finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[GraphicalLassoCV] Done refinement 3 out of 4: 6s
....[Parallel(n_jobs=1)]: Done 1 out of 1 | elapsed: 0.6s remaining: 0.0s
................[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 2.4s finished
[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.
[Parallel(n_jobs=1)]: Done 5 out of 5 | elapsed: 0.0s finished
[GraphicalLassoCV] Done refinement 4 out of 4: 9s
[graphical_lasso] Iteration 0, cost 1.64e+02, dual gap 5.350e-02
[graphical_lasso] Iteration 1, cost 1.64e+02, dual gap -5.185e-03
[graphical_lasso] Iteration 2, cost 1.64e+02, dual gap -1.237e-04
[graphical_lasso] Iteration 3, cost 1.64e+02, dual gap -2.600e-04
[graphical_lasso] Iteration 4, cost 1.64e+02, dual gap -6.945e-04
[graphical_lasso] Iteration 5, cost 1.64e+02, dual gap -1.485e-04
[graphical_lasso] Iteration 6, cost 1.64e+02, dual gap -1.237e-04
[graphical_lasso] Iteration 7, cost 1.64e+02, dual gap -4.181e-05
GraphicalLassoCV(verbose=2)
Define a function to plot the matrices easier.
import numpy as np
from nilearn import plotting
def plot_matrices(cov, prec, title, labels):
"""Plot covariance and precision matrices, for a given processing. """
prec = prec.copy() # avoid side effects
# Put zeros on the diagonal, for graph clarity.
size = prec.shape[0]
prec[list(range(size)), list(range(size))] = 0
span = max(abs(prec.min()), abs(prec.max()))
# Display covariance matrix
plotting.plot_matrix(cov, cmap=plotting.cm.bwr,
vmin=-1, vmax=1, title="%s / covariance" % title,
labels=labels)
# Display precision matrix
plotting.plot_matrix(prec, cmap=plotting.cm.bwr,
vmin=-span, vmax=span, title="%s / precision" % title,
labels=labels)
Plotting the connectomes and matrices.
atlas_img = msdl_atlas_dataset.maps
atlas_region_coords = plotting.find_probabilistic_atlas_cut_coords(atlas_img)
labels = msdl_atlas_dataset.labels
plotting.plot_connectome(gl.covariance_,
atlas_region_coords, edge_threshold='90%',
title="Covariance",
display_mode="lzr")
plotting.plot_connectome(-gl.precision_, atlas_region_coords,
edge_threshold='90%',
title="Sparse inverse covariance (GraphicalLasso)",
display_mode="lzr",
edge_vmax=.5, edge_vmin=-.5)
plot_matrices(gl.covariance_, gl.precision_, "GraphicalLasso", labels)
title = "GroupSparseCovariance"
plotting.plot_connectome(-gsc.precisions_[..., 0],
atlas_region_coords, edge_threshold='90%',
title=title,
display_mode="lzr",
edge_vmax=.5, edge_vmin=-.5)
plot_matrices(gsc.covariances_[..., 0],
gsc.precisions_[..., 0], title, labels)
import numpy as np
import matplotlib.pyplot as plt
plotting.show()
Saving the matrices.
from nilearn import plotting
#1st matrix
cov=gsc.covariances_[..., 0]
title='GroupSparseCovariance'
display=plotting.plot_matrix(cov, cmap=plotting.cm.bwr,
vmin=-1, vmax=1, title="%s / covariance" % title,
labels=labels)
display.figure.savefig('GSC_covariance_dep.png', dpi=300)
plotting.show()
# 2nd matrix
cov=gl.covariance_
title='GraphicLassoCV'
# Display covariance matrix
display=plotting.plot_matrix(cov, cmap=plotting.cm.bwr,
vmin=-1, vmax=1, title="%s / covariance" % title,
labels=labels)
display.figure.savefig('GL_covariances_dep.png', dpi=300)
Saving the precision matrix.
prec = gsc.precisions_[..., 0]
# Put zeros on the diagonal, for graph clarity.
size = prec.shape[0]
prec[list(range(size)), list(range(size))] = 0
span = max(abs(prec.min()), abs(prec.max()))
title='GSC'
# Display precision matrix
display=plotting.plot_matrix(prec, cmap=plotting.cm.bwr,
vmin=-span, vmax=span, title="%s / precision" % title,
labels=labels)
display.figure.savefig('Precision_dep.png', dpi=300)
plotting.show()
Matrices are nice to see but we look also for the exactly figures and saving the as .csv file.
import pandas as pd
import openpyxl
df=pd.DataFrame(data=gl.covariance_, index=labels, columns=labels)
df.to_csv('GL_covariances_dep.csv')
df.to_excel('GL_covariances_depx.xlsx')
df
L Aud | R Aud | Striate | L DMN | Med DMN | Front DMN | R DMN | Occ post | Motor | R DLPFC | ... | Sup Front S | R TPJ | R Pars Op | Cereb | Dors PCC | L Ins | Cing | R Ins | L Ant IPS | R Ant IPS | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
L Aud | 1.000000 | 0.798597 | 0.311369 | 0.020126 | 0.028022 | 0.080498 | 0.014081 | -0.008403 | 0.481041 | 0.129070 | ... | 0.131533 | 0.118058 | 0.033434 | 0.058716 | 0.141267 | 0.205152 | 0.328673 | 0.176284 | 0.377998 | 0.408313 |
R Aud | 0.798597 | 1.000000 | 0.318436 | 0.035964 | 0.036390 | 0.105700 | 0.024445 | -0.006301 | 0.487947 | 0.119610 | ... | 0.139515 | 0.109687 | 0.033385 | 0.061050 | 0.115625 | 0.218479 | 0.338444 | 0.190555 | 0.317715 | 0.373012 |
Striate | 0.311369 | 0.318436 | 1.000000 | 0.074828 | 0.172708 | 0.096119 | 0.094376 | -0.152740 | 0.343312 | 0.080067 | ... | 0.102034 | 0.132433 | 0.050808 | 0.122955 | 0.152385 | 0.119196 | 0.145038 | 0.105493 | 0.162783 | 0.202406 |
L DMN | 0.020126 | 0.035964 | 0.074828 | 1.000000 | 0.525256 | 0.360829 | 0.562377 | 0.040643 | 0.026517 | 0.172771 | ... | 0.194160 | 0.018377 | -0.009607 | -0.054098 | 0.024442 | -0.176804 | -0.119470 | -0.210249 | -0.121566 | -0.130641 |
Med DMN | 0.028022 | 0.036390 | 0.172708 | 0.525256 | 1.000000 | 0.372645 | 0.507807 | -0.024333 | 0.046650 | 0.261306 | ... | 0.140689 | 0.090776 | 0.002580 | -0.017239 | 0.247423 | -0.071507 | -0.055468 | -0.082465 | -0.070908 | -0.079136 |
Front DMN | 0.080498 | 0.105700 | 0.096119 | 0.360829 | 0.372645 | 1.000000 | 0.357647 | 0.079602 | 0.125842 | 0.212227 | ... | 0.280557 | 0.149762 | 0.163063 | 0.006443 | 0.038734 | 0.028853 | -0.020334 | 0.014629 | -0.053709 | -0.042095 |
R DMN | 0.014081 | 0.024445 | 0.094376 | 0.562377 | 0.507807 | 0.357647 | 1.000000 | 0.032644 | 0.031379 | 0.313588 | ... | 0.164104 | 0.089041 | 0.084598 | -0.030214 | 0.148575 | -0.126284 | -0.088196 | -0.148346 | -0.087649 | -0.143642 |
Occ post | -0.008403 | -0.006301 | -0.152740 | 0.040643 | -0.024333 | 0.079602 | 0.032644 | 1.000000 | -0.030538 | 0.114311 | ... | 0.080393 | -0.004935 | 0.071089 | 0.059607 | -0.082976 | -0.019324 | 0.005654 | -0.011347 | -0.018482 | -0.017379 |
Motor | 0.481041 | 0.487947 | 0.343312 | 0.026517 | 0.046650 | 0.125842 | 0.031379 | -0.030538 | 1.000000 | 0.149832 | ... | 0.216382 | 0.179939 | 0.093055 | 0.109373 | 0.268521 | 0.182224 | 0.293455 | 0.147676 | 0.353831 | 0.432115 |
R DLPFC | 0.129070 | 0.119610 | 0.080067 | 0.172771 | 0.261306 | 0.212227 | 0.313588 | 0.114311 | 0.149832 | 1.000000 | ... | 0.318859 | 0.245616 | 0.365569 | 0.091681 | 0.302731 | 0.163989 | 0.135900 | 0.245253 | 0.209637 | 0.173442 |
R Front pol | -0.002424 | -0.013875 | -0.011285 | -0.008662 | 0.035550 | 0.063108 | 0.044793 | 0.096669 | 0.016613 | 0.437322 | ... | 0.133519 | 0.143582 | 0.305217 | 0.191062 | 0.168530 | 0.101328 | 0.018442 | 0.217209 | 0.121655 | 0.103794 |
R Par | 0.009873 | -0.018478 | -0.033008 | 0.131301 | 0.262080 | 0.106186 | 0.190255 | 0.059839 | 0.034402 | 0.635029 | ... | 0.173915 | 0.144199 | 0.243112 | 0.056155 | 0.305637 | 0.101919 | 0.083725 | 0.192449 | 0.204593 | 0.173509 |
R Post Temp | 0.000963 | -0.011012 | -0.032770 | 0.067480 | 0.112701 | 0.108624 | 0.113081 | 0.032464 | 0.055431 | 0.310932 | ... | 0.140507 | 0.237229 | 0.193380 | 0.034220 | 0.127421 | 0.007685 | -0.041414 | 0.041618 | 0.090684 | 0.043872 |
Basal | 0.188347 | 0.204100 | 0.128524 | 0.000983 | 0.089468 | 0.175734 | 0.040768 | 0.130811 | 0.206887 | 0.247885 | ... | 0.250573 | 0.246880 | 0.269575 | 0.278554 | 0.202774 | 0.387134 | 0.366277 | 0.403311 | 0.229568 | 0.213024 |
L Par | 0.021386 | 0.009374 | -0.030529 | 0.212918 | 0.280419 | 0.111897 | 0.169365 | 0.053906 | 0.063949 | 0.450854 | ... | 0.248934 | 0.146254 | 0.165645 | 0.047072 | 0.258408 | 0.060465 | 0.032503 | 0.067583 | 0.162748 | 0.092639 |
L DLPFC | 0.201506 | 0.203841 | 0.111175 | 0.360256 | 0.283243 | 0.231972 | 0.273361 | 0.124475 | 0.210471 | 0.550828 | ... | 0.450700 | 0.217148 | 0.201206 | 0.057364 | 0.208246 | 0.128819 | 0.116437 | 0.074251 | 0.188292 | 0.143131 |
L Front pol | 0.031527 | 0.022260 | -0.035416 | 0.084417 | 0.030373 | 0.051433 | 0.030772 | 0.092785 | 0.055483 | 0.312285 | ... | 0.188243 | 0.083025 | 0.171938 | 0.158504 | 0.110406 | 0.035140 | -0.020470 | 0.042398 | 0.119325 | 0.097118 |
L IPS | 0.185165 | 0.164383 | 0.180191 | 0.005084 | 0.086607 | -0.074723 | -0.029153 | 0.001486 | 0.240558 | 0.178378 | ... | 0.019506 | 0.037326 | -0.002639 | 0.066958 | 0.217480 | 0.082361 | 0.107520 | 0.056572 | 0.229100 | 0.207472 |
R IPS | 0.165305 | 0.135577 | 0.161794 | -0.067367 | 0.063958 | -0.091728 | -0.027232 | -0.003194 | 0.220118 | 0.196049 | ... | -0.026182 | 0.029117 | -0.001290 | 0.079512 | 0.234178 | 0.062807 | 0.103469 | 0.061519 | 0.216528 | 0.202647 |
L LOC | 0.277597 | 0.260829 | 0.380594 | 0.001764 | 0.007388 | 0.040340 | -0.002785 | 0.018587 | 0.340349 | 0.039068 | ... | 0.084785 | 0.093479 | 0.031734 | 0.111617 | 0.128475 | 0.087088 | 0.146833 | 0.100015 | 0.188375 | 0.269810 |
Vis | 0.163318 | 0.158736 | 0.354828 | -0.080237 | -0.033009 | -0.010577 | -0.079339 | 0.054932 | 0.206028 | 0.013075 | ... | 0.055520 | 0.118190 | 0.101887 | 0.272238 | 0.088673 | 0.117360 | 0.091374 | 0.135195 | 0.123866 | 0.168889 |
R LOC | 0.269922 | 0.259668 | 0.394939 | -0.017008 | -0.012484 | 0.048469 | -0.025506 | 0.069904 | 0.343112 | 0.007009 | ... | 0.118305 | 0.118389 | 0.040194 | 0.173486 | 0.115345 | 0.115233 | 0.130180 | 0.103598 | 0.188575 | 0.269044 |
D ACC | 0.162435 | 0.167618 | 0.125581 | 0.030385 | 0.121978 | 0.210403 | 0.073211 | 0.050891 | 0.167489 | 0.343111 | ... | 0.323766 | 0.251532 | 0.225271 | 0.182462 | 0.346686 | 0.465754 | 0.311057 | 0.426074 | 0.253865 | 0.223102 |
V ACC | 0.095895 | 0.119517 | 0.106695 | 0.038231 | 0.176077 | 0.392223 | 0.092831 | 0.048847 | 0.127050 | 0.297167 | ... | 0.293455 | 0.233539 | 0.254504 | 0.082891 | 0.217772 | 0.422076 | 0.251553 | 0.433750 | 0.152330 | 0.128868 |
R A Ins | 0.116683 | 0.118783 | 0.105140 | -0.023760 | 0.120815 | 0.217761 | 0.096615 | 0.051390 | 0.112283 | 0.479629 | ... | 0.224791 | 0.257888 | 0.298713 | 0.180664 | 0.332027 | 0.412633 | 0.273798 | 0.490279 | 0.220605 | 0.201504 |
L STS | 0.420940 | 0.425008 | 0.278273 | -0.118531 | -0.006755 | 0.048251 | -0.062866 | -0.016457 | 0.386312 | 0.158103 | ... | 0.144132 | 0.275751 | 0.244301 | 0.176389 | 0.218191 | 0.455217 | 0.520989 | 0.466484 | 0.399777 | 0.408984 |
R STS | 0.331373 | 0.343093 | 0.235100 | -0.102695 | 0.014773 | 0.049121 | -0.071512 | -0.016333 | 0.334791 | 0.124987 | ... | 0.134600 | 0.281871 | 0.226321 | 0.182855 | 0.217154 | 0.463480 | 0.522587 | 0.451753 | 0.362609 | 0.379181 |
L TPJ | 0.178542 | 0.179749 | 0.162304 | 0.181114 | 0.207464 | 0.211637 | 0.214557 | 0.046078 | 0.229466 | 0.338435 | ... | 0.443766 | 0.520544 | 0.399545 | 0.112344 | 0.177745 | 0.248260 | 0.200198 | 0.234874 | 0.146262 | 0.148283 |
Broca | 0.114794 | 0.131615 | 0.074836 | 0.070911 | -0.020645 | 0.153865 | 0.038102 | 0.087843 | 0.150929 | 0.201588 | ... | 0.465485 | 0.355914 | 0.563253 | 0.200372 | -0.009713 | 0.321113 | 0.151274 | 0.264425 | 0.099886 | 0.101953 |
Sup Front S | 0.131533 | 0.139515 | 0.102034 | 0.194160 | 0.140689 | 0.280557 | 0.164104 | 0.080393 | 0.216382 | 0.318859 | ... | 1.000000 | 0.305614 | 0.348074 | 0.110502 | 0.122262 | 0.245523 | 0.236595 | 0.178675 | 0.084309 | 0.099080 |
R TPJ | 0.118058 | 0.109687 | 0.132433 | 0.018377 | 0.090776 | 0.149762 | 0.089041 | -0.004935 | 0.179939 | 0.245616 | ... | 0.305614 | 1.000000 | 0.422545 | 0.119391 | 0.139124 | 0.257767 | 0.141448 | 0.271278 | 0.101372 | 0.117345 |
R Pars Op | 0.033434 | 0.033385 | 0.050808 | -0.009607 | 0.002580 | 0.163063 | 0.084598 | 0.071089 | 0.093055 | 0.365569 | ... | 0.348074 | 0.422545 | 1.000000 | 0.186401 | 0.104934 | 0.357218 | 0.181936 | 0.464022 | 0.117982 | 0.117426 |
Cereb | 0.058716 | 0.061050 | 0.122955 | -0.054098 | -0.017239 | 0.006443 | -0.030214 | 0.059607 | 0.109373 | 0.091681 | ... | 0.110502 | 0.119391 | 0.186401 | 1.000000 | 0.119970 | 0.165217 | 0.149422 | 0.168855 | 0.110476 | 0.117274 |
Dors PCC | 0.141267 | 0.115625 | 0.152385 | 0.024442 | 0.247423 | 0.038734 | 0.148575 | -0.082976 | 0.268521 | 0.302731 | ... | 0.122262 | 0.139124 | 0.104934 | 0.119970 | 1.000000 | 0.199116 | 0.239472 | 0.205233 | 0.317325 | 0.271135 |
L Ins | 0.205152 | 0.218479 | 0.119196 | -0.176804 | -0.071507 | 0.028853 | -0.126284 | -0.019324 | 0.182224 | 0.163989 | ... | 0.245523 | 0.257767 | 0.357218 | 0.165217 | 0.199116 | 1.000000 | 0.512821 | 0.735890 | 0.318274 | 0.295043 |
Cing | 0.328673 | 0.338444 | 0.145038 | -0.119470 | -0.055468 | -0.020334 | -0.088196 | 0.005654 | 0.293455 | 0.135900 | ... | 0.236595 | 0.141448 | 0.181936 | 0.149422 | 0.239472 | 0.512821 | 1.000000 | 0.489152 | 0.368348 | 0.373027 |
R Ins | 0.176284 | 0.190555 | 0.105493 | -0.210249 | -0.082465 | 0.014629 | -0.148346 | -0.011347 | 0.147676 | 0.245253 | ... | 0.178675 | 0.271278 | 0.464022 | 0.168855 | 0.205233 | 0.735890 | 0.489152 | 1.000000 | 0.308422 | 0.313891 |
L Ant IPS | 0.377998 | 0.317715 | 0.162783 | -0.121566 | -0.070908 | -0.053709 | -0.087649 | -0.018482 | 0.353831 | 0.209637 | ... | 0.084309 | 0.101372 | 0.117982 | 0.110476 | 0.317325 | 0.318274 | 0.368348 | 0.308422 | 1.000000 | 0.691629 |
R Ant IPS | 0.408313 | 0.373012 | 0.202406 | -0.130641 | -0.079136 | -0.042095 | -0.143642 | -0.017379 | 0.432115 | 0.173442 | ... | 0.099080 | 0.117345 | 0.117426 | 0.117274 | 0.271135 | 0.295043 | 0.373027 | 0.313891 | 0.691629 | 1.000000 |
39 rows × 39 columns
import pandas as pd
df=pd.DataFrame(data=gsc.covariances_[..., 0], index=labels, columns=labels)
df.to_csv('GSC_covariances_dep.csv')
df.to_excel('GSC_covariances_depx.xlsx')
df
L Aud | R Aud | Striate | L DMN | Med DMN | Front DMN | R DMN | Occ post | Motor | R DLPFC | ... | Sup Front S | R TPJ | R Pars Op | Cereb | Dors PCC | L Ins | Cing | R Ins | L Ant IPS | R Ant IPS | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
L Aud | 1.000000 | 0.723993 | 0.335534 | -0.391873 | -0.266693 | 0.159144 | -0.161126 | 0.318132 | 0.615321 | 0.316602 | ... | 0.362924 | 0.242860 | 0.203172 | 0.239224 | 0.389446 | 0.330741 | 0.726887 | 0.473729 | 0.582107 | 0.597644 |
R Aud | 0.723993 | 1.000000 | 0.258816 | -0.124548 | -0.152426 | 0.158846 | -0.184140 | 0.270117 | 0.470894 | 0.390148 | ... | 0.364295 | 0.081725 | 0.128765 | 0.285067 | 0.252798 | 0.274887 | 0.689287 | 0.383565 | 0.446432 | 0.555875 |
Striate | 0.335534 | 0.258816 | 1.000000 | -0.100689 | 0.179182 | 0.370991 | -0.207750 | 0.460856 | 0.534865 | 0.127694 | ... | 0.348141 | 0.071062 | -0.002886 | 0.347878 | -0.002718 | 0.257796 | 0.372401 | 0.368429 | 0.331933 | 0.376441 |
L DMN | -0.391873 | -0.124548 | -0.100689 | 1.000000 | 0.402709 | -0.054991 | 0.164837 | -0.274704 | -0.346026 | -0.002294 | ... | 0.039678 | -0.130282 | -0.077344 | 0.128919 | -0.312697 | -0.056373 | -0.403098 | -0.291883 | -0.335421 | -0.230883 |
Med DMN | -0.266693 | -0.152426 | 0.179182 | 0.402709 | 1.000000 | 0.108623 | 0.287465 | -0.155881 | -0.039888 | 0.003539 | ... | -0.034046 | -0.250336 | -0.047933 | 0.065559 | -0.141205 | 0.125765 | -0.191081 | 0.109152 | -0.010307 | 0.003584 |
Front DMN | 0.159144 | 0.158846 | 0.370991 | -0.054991 | 0.108623 | 1.000000 | 0.029732 | 0.292180 | 0.270184 | 0.324467 | ... | 0.149203 | -0.016972 | -0.093003 | 0.022880 | -0.092625 | -0.041219 | 0.190689 | 0.127897 | 0.021036 | 0.068663 |
R DMN | -0.161126 | -0.184140 | -0.207750 | 0.164837 | 0.287465 | 0.029732 | 1.000000 | -0.237601 | -0.039638 | 0.302177 | ... | -0.144307 | 0.216180 | 0.441628 | -0.269782 | 0.241958 | 0.068973 | -0.089262 | 0.097530 | 0.036577 | -0.232277 |
Occ post | 0.318132 | 0.270117 | 0.460856 | -0.274704 | -0.155881 | 0.292180 | -0.237601 | 1.000000 | 0.373314 | 0.246340 | ... | 0.344706 | 0.289952 | 0.167907 | 0.094994 | 0.017284 | 0.112110 | 0.350210 | 0.167072 | 0.058340 | 0.176738 |
Motor | 0.615321 | 0.470894 | 0.534865 | -0.346026 | -0.039888 | 0.270184 | -0.039638 | 0.373314 | 1.000000 | 0.436821 | ... | 0.499459 | 0.230056 | 0.119525 | 0.131572 | 0.531655 | 0.277823 | 0.776233 | 0.570483 | 0.737922 | 0.745511 |
R DLPFC | 0.316602 | 0.390148 | 0.127694 | -0.002294 | 0.003539 | 0.324467 | 0.302177 | 0.246340 | 0.436821 | 1.000000 | ... | 0.276209 | 0.216335 | 0.530285 | 0.257033 | 0.369421 | 0.124911 | 0.480172 | 0.421895 | 0.349252 | 0.292561 |
R Front pol | 0.049523 | 0.245537 | 0.158334 | -0.015173 | 0.306456 | 0.240384 | 0.023282 | 0.238644 | 0.116828 | 0.459396 | ... | 0.125913 | 0.065059 | 0.393506 | 0.089676 | 0.068352 | 0.049663 | 0.140735 | 0.337759 | 0.152963 | 0.121012 |
R Par | 0.365313 | 0.366905 | -0.016710 | -0.097160 | -0.015364 | -0.060162 | 0.285397 | -0.003306 | 0.458180 | 0.684621 | ... | 0.310920 | 0.230587 | 0.557294 | 0.083893 | 0.567973 | 0.222191 | 0.525569 | 0.600843 | 0.594764 | 0.397167 |
R Post Temp | 0.190881 | 0.215962 | 0.123250 | -0.007307 | 0.251898 | 0.167606 | 0.032700 | 0.023695 | 0.347939 | 0.255635 | ... | 0.150743 | -0.203962 | -0.061742 | -0.086129 | 0.276157 | 0.054878 | 0.383349 | 0.308049 | 0.431973 | 0.354424 |
Basal | 0.429863 | 0.423924 | 0.269270 | -0.123745 | 0.022378 | 0.077745 | 0.167056 | 0.194049 | 0.583348 | 0.441410 | ... | 0.411660 | 0.257569 | 0.241231 | 0.003288 | 0.537567 | 0.322775 | 0.535961 | 0.545196 | 0.603621 | 0.558929 |
L Par | 0.242221 | 0.399379 | -0.104040 | 0.193146 | 0.003272 | -0.087693 | 0.095830 | -0.128530 | 0.300385 | 0.449526 | ... | 0.472471 | 0.177203 | 0.288867 | 0.254584 | 0.361929 | 0.186514 | 0.354433 | 0.353458 | 0.431679 | 0.348734 |
L DLPFC | 0.120428 | 0.366274 | 0.151783 | 0.478160 | 0.016785 | 0.164619 | -0.182490 | 0.103437 | 0.184286 | 0.340764 | ... | 0.371768 | 0.136453 | -0.047105 | 0.395028 | 0.010888 | 0.043558 | 0.167629 | -0.029470 | 0.055445 | 0.257381 |
L Front pol | 0.029674 | 0.234701 | -0.080965 | 0.402028 | -0.173958 | 0.180350 | -0.065546 | -0.008426 | -0.053654 | 0.266003 | ... | 0.084001 | 0.072517 | -0.050543 | 0.195151 | -0.151275 | -0.179974 | 0.013291 | -0.315742 | -0.172008 | -0.000594 |
L IPS | 0.169463 | 0.199122 | 0.299818 | -0.013719 | 0.066391 | 0.134882 | -0.152996 | -0.021528 | 0.382591 | -0.062871 | ... | 0.306387 | 0.016734 | -0.336912 | 0.118395 | 0.040044 | 0.046451 | 0.239145 | 0.046899 | 0.297401 | 0.361101 |
R IPS | 0.117088 | 0.053976 | 0.162174 | -0.337169 | 0.155028 | 0.255857 | 0.036620 | 0.039049 | 0.335083 | 0.075213 | ... | 0.217105 | -0.139381 | -0.156527 | -0.069323 | 0.108961 | 0.044987 | 0.275137 | 0.226908 | 0.289309 | 0.149221 |
L LOC | 0.402565 | 0.320117 | 0.524747 | -0.307442 | -0.012128 | 0.076149 | -0.117833 | 0.172029 | 0.672230 | 0.283406 | ... | 0.403131 | 0.157649 | 0.063273 | 0.289763 | 0.465206 | 0.298806 | 0.510661 | 0.487936 | 0.667014 | 0.605372 |
Vis | 0.175704 | 0.236847 | 0.403510 | 0.039363 | 0.039708 | -0.088472 | -0.198282 | 0.113618 | 0.285367 | 0.159819 | ... | 0.321978 | -0.016503 | 0.185184 | 0.507036 | -0.031222 | 0.335715 | 0.249954 | 0.396053 | 0.266258 | 0.198232 |
R LOC | 0.465298 | 0.364454 | 0.655239 | -0.304061 | 0.118796 | 0.206834 | -0.274094 | 0.386503 | 0.633773 | 0.080604 | ... | 0.521493 | 0.031064 | -0.018842 | 0.236396 | 0.094266 | 0.346045 | 0.502329 | 0.499864 | 0.541262 | 0.515212 |
D ACC | 0.384025 | 0.397976 | 0.334343 | -0.113546 | -0.042585 | 0.229807 | -0.081055 | 0.264923 | 0.607251 | 0.249474 | ... | 0.538891 | 0.308454 | 0.080315 | 0.050565 | 0.368542 | 0.382381 | 0.415222 | 0.489495 | 0.513567 | 0.552184 |
V ACC | 0.334477 | 0.182155 | 0.445593 | -0.318788 | 0.133247 | 0.347258 | 0.038941 | 0.368969 | 0.605187 | 0.227399 | ... | 0.556707 | 0.243350 | 0.128447 | -0.081586 | 0.331741 | 0.350323 | 0.417691 | 0.595412 | 0.516982 | 0.480074 |
R A Ins | 0.482529 | 0.445116 | 0.326881 | -0.291555 | -0.000792 | 0.352516 | 0.101550 | 0.373531 | 0.551085 | 0.546800 | ... | 0.491504 | 0.329609 | 0.439311 | 0.006843 | 0.357359 | 0.264846 | 0.522388 | 0.661731 | 0.507428 | 0.453865 |
L STS | 0.593067 | 0.439415 | 0.520597 | -0.427618 | -0.122077 | 0.205870 | -0.102779 | 0.365405 | 0.717865 | 0.421519 | ... | 0.246182 | 0.218819 | 0.249295 | 0.349661 | 0.469413 | 0.303933 | 0.614418 | 0.525779 | 0.631493 | 0.580915 |
R STS | 0.530024 | 0.408987 | 0.556244 | -0.427232 | -0.075839 | 0.197978 | -0.154733 | 0.413129 | 0.754534 | 0.370551 | ... | 0.326620 | 0.250453 | 0.229706 | 0.319156 | 0.429435 | 0.301279 | 0.656655 | 0.589782 | 0.626649 | 0.647171 |
L TPJ | 0.318434 | 0.295216 | 0.190809 | -0.013349 | -0.025061 | 0.002641 | 0.148720 | 0.265409 | 0.446373 | 0.399649 | ... | 0.566440 | 0.693813 | 0.453716 | 0.097893 | 0.404807 | 0.145749 | 0.312676 | 0.299736 | 0.370368 | 0.271565 |
Broca | -0.192379 | -0.073537 | 0.049097 | 0.412684 | 0.003704 | -0.044705 | -0.094523 | 0.190289 | -0.264723 | -0.095010 | ... | 0.291984 | 0.373802 | 0.155824 | 0.166062 | -0.293201 | 0.059135 | -0.338791 | -0.270176 | -0.375172 | -0.302726 |
Sup Front S | 0.362924 | 0.364295 | 0.348141 | 0.039678 | -0.034046 | 0.149203 | -0.144307 | 0.344706 | 0.499459 | 0.276209 | ... | 1.000000 | 0.395983 | 0.167171 | 0.184154 | 0.158178 | 0.210378 | 0.360390 | 0.308485 | 0.327649 | 0.454188 |
R TPJ | 0.242860 | 0.081725 | 0.071062 | -0.130282 | -0.250336 | -0.016972 | 0.216180 | 0.289952 | 0.230056 | 0.216335 | ... | 0.395983 | 1.000000 | 0.492338 | -0.016286 | 0.346553 | 0.095345 | 0.084928 | 0.169089 | 0.156912 | 0.081668 |
R Pars Op | 0.203172 | 0.128765 | -0.002886 | -0.077344 | -0.047933 | -0.093003 | 0.441628 | 0.167907 | 0.119525 | 0.530285 | ... | 0.167171 | 0.492338 | 1.000000 | 0.056583 | 0.282230 | 0.210745 | 0.160045 | 0.417641 | 0.163992 | -0.036347 |
Cereb | 0.239224 | 0.285067 | 0.347878 | 0.128919 | 0.065559 | 0.022880 | -0.269782 | 0.094994 | 0.131572 | 0.257033 | ... | 0.184154 | -0.016286 | 0.056583 | 1.000000 | -0.079858 | 0.177932 | 0.150955 | 0.121277 | 0.079782 | 0.239999 |
Dors PCC | 0.389446 | 0.252798 | -0.002718 | -0.312697 | -0.141205 | -0.092625 | 0.241958 | 0.017284 | 0.531655 | 0.369421 | ... | 0.158178 | 0.346553 | 0.282230 | -0.079858 | 1.000000 | 0.326032 | 0.481217 | 0.505795 | 0.659255 | 0.516132 |
L Ins | 0.330741 | 0.274887 | 0.257796 | -0.056373 | 0.125765 | -0.041219 | 0.068973 | 0.112110 | 0.277823 | 0.124911 | ... | 0.210378 | 0.095345 | 0.210745 | 0.177932 | 0.326032 | 1.000000 | 0.288572 | 0.608210 | 0.425118 | 0.299260 |
Cing | 0.726887 | 0.689287 | 0.372401 | -0.403098 | -0.191081 | 0.190689 | -0.089262 | 0.350210 | 0.776233 | 0.480172 | ... | 0.360390 | 0.084928 | 0.160045 | 0.150955 | 0.481217 | 0.288572 | 1.000000 | 0.578067 | 0.678811 | 0.722117 |
R Ins | 0.473729 | 0.383565 | 0.368429 | -0.291883 | 0.109152 | 0.127897 | 0.097530 | 0.167072 | 0.570483 | 0.421895 | ... | 0.308485 | 0.169089 | 0.417641 | 0.121277 | 0.505795 | 0.608210 | 0.578067 | 1.000000 | 0.706094 | 0.545425 |
L Ant IPS | 0.582107 | 0.446432 | 0.331933 | -0.335421 | -0.010307 | 0.021036 | 0.036577 | 0.058340 | 0.737922 | 0.349252 | ... | 0.327649 | 0.156912 | 0.163992 | 0.079782 | 0.659255 | 0.425118 | 0.678811 | 0.706094 | 1.000000 | 0.774519 |
R Ant IPS | 0.597644 | 0.555875 | 0.376441 | -0.230883 | 0.003584 | 0.068663 | -0.232277 | 0.176738 | 0.745511 | 0.292561 | ... | 0.454188 | 0.081668 | -0.036347 | 0.239999 | 0.516132 | 0.299260 | 0.722117 | 0.545425 | 0.774519 | 1.000000 |
39 rows × 39 columns
from PIL import Image
import urllib.request
URL = 'https://st.depositphotos.com/1431107/1631/i/950/depositphotos_16317151-stock-photo-well-done-illustration.jpg'
with urllib.request.urlopen(URL) as url:
with open('temp.jpg', 'wb') as f:
f.write(url.read())
img = Image.open('temp.jpg')
img.show()