interpolation='nearest', cmap=pl.cm.gray) # Third subplot: axial view pl.subplot(1, 3, 3) pl.axis('off') pl.title('Axial') pl.imshow(np.rot90(mean_img[:, :, 32]), interpolation='nearest', cmap=pl.cm.gray) # Extracting a brain mask ################################################### # Simple computation of a mask from the fMRI data from nisl.masking import compute_epi_mask mask = compute_epi_mask(mean_img) # We create a new figure pl.figure() # A plot the axial view of the mask to compare with the axial # view of the raw data displayed previously pl.imshow(np.rot90(mask[:, :, 32]), interpolation='nearest') # Applying the mask ######################################################### # Applying the mask is just a simple array manipulation masked_data = fmri_data[mask] # masked_data is now a voxel x time matrix. We can plot the first 10 # lines: they correspond to time-series of 10 voxels on the side of the # brain
pl.title('Sagittal') pl.imshow(np.rot90(mean_img[15, :, :]), interpolation='nearest', cmap=pl.cm.gray) # Third subplot: axial view pl.subplot(1, 3, 3) pl.axis('off') pl.title('Axial') pl.imshow(np.rot90(mean_img[:, :, 32]), interpolation='nearest', cmap=pl.cm.gray) # Extracting a brain mask ################################################### # Simple computation of a mask from the fMRI data from nisl.masking import compute_epi_mask mask = compute_epi_mask(mean_img) # We create a new figure pl.figure() # A plot the axial view of the mask to compare with the axial # view of the raw data displayed previously pl.imshow(np.rot90(mask[:, :, 32]), interpolation='nearest') # Applying the mask ######################################################### # Applying the mask is just a simple array manipulation masked_data = fmri_data[mask] # masked_data is now a voxel x time matrix. We can plot the first 10 # lines: they correspond to time-series of 10 voxels on the side of the # brain
interpolation='nearest', cmap=pl.cm.gray) # Third subplot: axial view pl.subplot(1, 3, 3) pl.axis('off') pl.title('Axial') pl.imshow(np.rot90(mean_img[:, :, 32]), interpolation='nearest', cmap=pl.cm.gray) # Extracting a brain mask ################################################### # Simple computation of a mask from the fMRI data from nisl.masking import compute_epi_mask mask_img = compute_epi_mask(nifti_img) mask_data = mask_img.get_data().astype(bool) # We create a new figure pl.figure() # A plot the axial view of the mask to compare with the axial # view of the raw data displayed previously pl.imshow(np.rot90(mask_data[:, :, 32]), interpolation='nearest') # Applying the mask ######################################################### from nisl.masking import apply_mask masked_data = apply_mask(nifti_img, mask_img) # masked_data shape is (instant number, voxel number). We can plot the first 10 # lines: they correspond to timeseries of 10 voxels on the side of the