I am having issues when trying to apply the compute_brain_mask function to a NIFTI image in order to perform skull stripping. I will attach photos of the images being processed and the output mask given by the software. Clearly the mask of the brain has been calculated well but then the output images are cropped for a reason I can’t determine. My data is from MRI, which is a 3D acquisition with slices taken on the sagittal plane. I will also attach the code I am using.
import numpy as np
from nilearn import plotting, image
from nilearn.masking import compute_brain_mask
import os
import nibabel as nib
import matplotlib.pyplot as plt
nifti_img = image.load_img(r"path_to_image.nii.gz")
mask_img = compute_brain_mask(nifti_img, threshold = 0.3)
plotting.plot_anat(anat_img=nifti_img, display_mode='x', cut_coords=6, title="NIfTI Image Slices")
plotting.plot_anat(anat_img=mask_img, display_mode='x', cut_coords=6, title="NIfTI Image Slices")
plotting.show()