d3d91cb4d27ff6826d755f0377b54ea999105490,plot_ica_resting_state.py,,,#,14

Before Change


////// Preprocess ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Concatenate all the subjects
fmri_data = np.concatenate(dataset.func, axis=3)

// Apply a small amount of Gaussian smoothing: in the case of ICA it is
// important as it introduces a spatial model that ICA lacks and greatly
// reduces the high-frequency signal
from scipy import ndimage
for image in fmri_data.T:
    // This works efficiently because image is a view on fmri_data
    image[...] = ndimage.gaussian_filter(image, 1.5)

// Take the mean along axis 3: the direction of time
mean_img = np.mean(fmri_data, axis=3)

// Mask non brain areas
from nisl import masking

After Change


////// Preprocess ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
from nisl import io

masker = io.NiftiMasker(smooth=1.5)
data_masked = masker.fit_transform(dataset.func[0])

// Concatenate all the subjects
//fmri_data = np.concatenate(data_masked, axis=1)
fmri_data = data_masked

// Take the mean along axis 3: the direction of time
mean_img = masker.inverse_transform(fmri_data.mean(axis=-1))


////// Apply ICA //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

from sklearn.decomposition import FastICA
n_components = 20
ica = FastICA(n_components=n_components, random_state=42)
components_masked = ica.fit_transform(data_masked)

// We normalize the estimated components, for thresholding to make sens
components_masked -= components_masked.mean(axis=0)
components_masked /= components_masked.std(axis=0)
// Threshold
components_masked[np.abs(components_masked) < .5] = 0

// Now we inverting the masking operation, to go back to a full 3D
// representation
component_img = masker.inverse_transform(components_masked)
components = component_img.get_data()

// Using a masked array is important to have transparency in the figures
components = np.ma.masked_equal(components, 0, copy=False)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: nilearn/nilearn
Commit Name: d3d91cb4d27ff6826d755f0377b54ea999105490
Time: 2012-09-18
Author: gael.varoquaux@normalesup.org
File Name: plot_ica_resting_state.py
Class Name:
Method Name:


Project Name: IndicoDataSolutions/finetune
Commit Name: dd6d8307b494b349805095653298b89100412fb9
Time: 2019-01-14
Author: benlt@hotmail.co.uk
File Name: finetune/datasets/treebank_association.py
Class Name:
Method Name:


Project Name: nilearn/nilearn
Commit Name: 13482b28622840a153162b4c070bffdf05d51d38
Time: 2012-08-21
Author: alexandre.abraham@cea.fr
File Name: plot_haxby_searchlight.py
Class Name:
Method Name: