Group analysis of resting-state fMRI with ICA: CanICAΒΆ

An example applying CanICA to resting-state data. This example applies it to 40 subjects of the ADHD200 datasets. Then it plots a map with all the components together and an axial cut for each of the components separately.

CanICA is an ICA method for group-level analysis of fMRI data. Compared to other strategies, it brings a well-controlled group model, as well as a thresholding algorithm controlling for specificity and sensitivity with an explicit model of the signal. The reference papers are:

  • G. Varoquaux et al. “A group model for stable multi-subject ICA on fMRI datasets”, NeuroImage Vol 51 (2010), p. 288-299
  • G. Varoquaux et al. “ICA-based sparse features recovery from fMRI datasets”, IEEE ISBI 2010, p. 1177

Pre-prints for both papers are available on hal (http://hal.archives-ouvertes.fr)

  • ../../_images/plot_canica_resting_state_001.png
  • ../../_images/plot_canica_resting_state_002.png
  • ../../_images/plot_canica_resting_state_003.png
  • ../../_images/plot_canica_resting_state_004.png
  • ../../_images/plot_canica_resting_state_005.png
  • ../../_images/plot_canica_resting_state_006.png
  • ../../_images/plot_canica_resting_state_007.png
  • ../../_images/plot_canica_resting_state_008.png
  • ../../_images/plot_canica_resting_state_009.png
  • ../../_images/plot_canica_resting_state_010.png
  • ../../_images/plot_canica_resting_state_011.png
  • ../../_images/plot_canica_resting_state_012.png
  • ../../_images/plot_canica_resting_state_013.png
  • ../../_images/plot_canica_resting_state_014.png
  • ../../_images/plot_canica_resting_state_015.png
  • ../../_images/plot_canica_resting_state_016.png
  • ../../_images/plot_canica_resting_state_017.png
  • ../../_images/plot_canica_resting_state_018.png
  • ../../_images/plot_canica_resting_state_019.png
  • ../../_images/plot_canica_resting_state_020.png
  • ../../_images/plot_canica_resting_state_021.png

Script output:

First functional nifti image (4D) is at: /home/ubuntu/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz
[MultiNiftiMasker.fit] Loading data from [/home/ubuntu/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz, /home/ubuntu/nilearn_data/adhd/data/0010064/0010064_rest_tshift_RPI_voreg_mni.nii.gz, /home/ubuntu/nilearn_data/a
[MultiNiftiMasker.fit] Computing mask
________________________________________________________________________________
[Memory] Calling nilearn.masking.compute_multi_epi_mask...
compute_multi_epi_mask([ '/home/ubuntu/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0010064/0010064_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0010128/0010128_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0021019/0021019_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0023008/0023008_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0023012/0023012_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0027011/0027011_rest_tshift_RPI_voreg_mni.nii.gz',
  '/home/ubuntu/nilearn_data/adhd/data/0027018/0027018_rest_tshift_RPI..., target_shape=None, target_affine=None, n_jobs=1, verbose=8, memory=Memory(cachedir='nilearn_cache/joblib'))
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08488cc50>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b20d0>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2a90>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2b50>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2290>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2390>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2510>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.6s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2050>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.6s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2f10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.7s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2a50>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.7s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2350>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.9s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2950>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2190>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad0848b2310>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5fa90>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f590>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f110>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f210>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.8s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5fe10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5fe90>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f090>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.7s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f810>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.8s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f550>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f310>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5fdd0>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5fb10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.9s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f710>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.8s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5ff10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.0s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f390>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad68d0>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6ad0>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6d10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.6s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6510>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6a10>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.8s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6b90>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.6s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6590>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 0.9s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6d50>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.6s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6e50>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad66d0>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.4s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.image.image._compute_mean...
_compute_mean(<nibabel.nifti1.Nifti1Image object at 0x2ad08cad6210>, target_shape=None, target_affine=None, smooth=1)
_____________________________________________________compute_mean - 1.1s, 0.0min
__________________________________________compute_multi_epi_mask - 46.1s, 0.8min
[MultiNiftiMasker.transform] Resampling mask
________________________________________________________________________________
[Memory] Calling nilearn.image.resampling.resample_img...
resample_img(<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f910>, target_shape=None, target_affine=None, copy=False, interpolation='nearest')
_____________________________________________________resample_img - 0.0s, 0.0min
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0010064/0010064_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0010128/0010128_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0021019/0021019_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0023008/0023008_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0023012/0023012_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0027011/0027011_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0027018/0027018_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0027034/0027034_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/0027037/0027037_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1019436/1019436_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1206380/1206380_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1418396/1418396_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1517058/1517058_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1552181/1552181_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1562298/1562298_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/1679142/1679142_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/2014113/2014113_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/2497695/2497695_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/2950754/2950754_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3007585/3007585_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3154996/3154996_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3205761/3205761_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3520880/3520880_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3624598/3624598_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3699991/3699991_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3884955/3884955_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3902469/3902469_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/3994098/3994098_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/4016887/4016887_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/4046678/4046678_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/4134561/4134561_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/4164316/4164316_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/4275075/4275075_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/6115230/6115230_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/7774305/7774305_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/8409791/8409791_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/8697774/8697774_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/9744150/9744150_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
[CanICA.fit] Resampling
[CanICA.fit] Loading data from Nifti1Image('/home/ubuntu/nilearn_data/adhd/data/9750701/9750701_rest_tshift_RPI_voreg_mni.nii.gz')
[CanICA.fit] Masking and smoothing
[CanICA.fit] Cleaning signal
________________________________________________________________________________
[Memory] Calling sklearn.utils.extmath.randomized_svd...
randomized_svd(array([[-0.002884, ..., -0.002066],
       ...,
       [-0.00276 , ..., -0.007555]]), n_components=20)
___________________________________________________randomized_svd - 2.5s, 0.0min
________________________________________________________________________________
[Memory] Calling nilearn.masking.unmask...
unmask(array([[-0.008509, ...,  0.      ],
       ...,
       [-0.      , ..., -0.      ]]),
<nibabel.nifti1.Nifti1Image object at 0x2ad08ca5f910>)
___________________________________________________________unmask - 0.1s, 0.0min

Python source code: plot_canica_resting_state.py

### Load ADHD rest dataset ####################################################
from nilearn import datasets

adhd_dataset = datasets.fetch_adhd()
func_filenames = adhd_dataset.func  # list of 4D nifti files for each subject

# print basic information on the dataset
print('First functional nifti image (4D) is at: %s' %
      adhd_dataset.func[0])  # 4D data

### Apply CanICA ##############################################################
from nilearn.decomposition.canica import CanICA

n_components = 20
canica = CanICA(n_components=n_components, smoothing_fwhm=6.,
                memory="nilearn_cache", memory_level=5,
                threshold=3., verbose=10, random_state=0)
canica.fit(func_filenames)

# Retrieve the independent components in brain space
components_img = canica.masker_.inverse_transform(canica.components_)
# components_img is a Nifti Image object, and can be saved to a file with
# the following line:
components_img.to_filename('canica_resting_state.nii.gz')

### Visualize the results #####################################################

import matplotlib.pyplot as plt
from nilearn.plotting import plot_prob_atlas
from nilearn.plotting import plot_stat_map
from nilearn.image import iter_img

# Plot all ICA components together
plot_prob_atlas(components_img, title='All ICA components')

# Plot the map for each ICA component separately
for i, cur_img in enumerate(iter_img(components_img)):
    plot_stat_map(cur_img, display_mode="z", title="IC %d" % i, cut_coords=1,
                  colorbar=False)

plt.show()

Total running time of the example: 330.47 seconds ( 5 minutes 30.47 seconds)