////// Preprocess data //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Change axis in order to have X under n_samples * x * y * z
X = np.rollaxis(fmri_data, 3)
// X.shape is (1452, 40, 64, 64)
// Mean image: used as background in visualisation
mean_img = np.mean(X, axis=0)
After Change
////// Restrict to faces and houses ////////////////////////////////////////////////////////////////////////////////////////////
condition_mask = np.logical_or(conditions == "face", conditions == "house")
X = fmri_data[..., condition_mask]
y = y[condition_mask]
session = session[condition_mask]
conditions = conditions[condition_mask]
////// Loading step ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
from nisl import mri_transformer
from nisl.utils import Niimg
// Detrending is disabled as we are not yet able to do it by session
mri_loader = mri_transformer.MRITransformer(mask=mask, detrend=True,
copy=False, sessions=session)
niimg = Niimg(X, affine)
X_masked = mri_loader.fit(niimg).transform(niimg)
X_detrended = mri_loader.inverse_transform(X_masked).get_data()
////// Prepare the masks //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Here we will use several masks :