d3d91cb4d27ff6826d755f0377b54ea999105490,plot_ica_resting_state.py,,,#,14

Before Change


// 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


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: 5

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: scikit-optimize/scikit-optimize
Commit Name: ab34a307714c29f891382586224074d1f4ba7f9a
Time: 2020-02-01
Author: holgernahrstaedt@gmx.de
File Name: skopt/tests/test_space.py
Class Name:
Method Name: test_normalize


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: