// fmri_data is copied to break the reference to the original data
bold_img = nibabel.load(dataset_files.func)
fmri_data = np.asarray(bold_img.get_data()).copy()
affine = bold_img.get_affine().copy()
del bold_img
y, session = np.loadtxt(dataset_files.session_target).astype("int").T
conditions = np.recfromtxt(dataset_files.conditions_target)["f0"]
////// Preprocess data //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Build the mean image because we have no anatomical data
mean_img = fmri_data.mean(axis=-1)
////// Restrict to faces and houses ////////////////////////////////////////////////////////////////////////////////////////////
from nibabel import Nifti1Image
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]
niimg = Nifti1Image(X, affine)
////// Loading step ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
from nisl.io import NiftiMasker
After Change
// should be processed (we only keep the slice z = 26 and the back of the
// brain to speed up computation)
mask_img = nibabel.load(dataset_files.mask)
// .astype() makes a copy.
process_mask = mask_img.get_data().astype(np.int)
process_mask[..., 38:] = 0