<jupyter_start><jupyter_text>Basic nilearn example: manipulating and looking at data=======================================================A simple example showing how to load an existing Nifti file and usebasic nilearn functionalities.<jupyter_code># Let us use a Nifti file that is shipped with nilearn
from nilearn.datasets import MNI152_FILE_PATH

# Note that the variable MNI152_FILE_PATH is just a path to a Nifti file
print('Path to MNI152 template: %r' % MNI152_FILE_PATH)<jupyter_output>/home/mh/.local/lib/python3.5/site-packages/nilearn/__init__.py:68: FutureWarning: Python 3.5 support is deprecated and will be removed in a future release. Consider switching to Python 3.6 or 3.7
  _python_deprecation_warnings()<jupyter_text>A first step: looking at our data----------------------------------Let's quickly plot this file:<jupyter_code>from nilearn import plotting
plotting.plot_img(MNI152_FILE_PATH)<jupyter_output><empty_output><jupyter_text>This is not a very pretty plot. We just used the simplest possiblecode. There is a whole `section of the documentation `on making prettier code.**Exercise**: Try plotting one of your own files. In the above,MNI152_FILE_PATH is nothing more than a string with a path pointing toa nifti image. You can replace it with a string pointing to a file onyour disk. Note that it should be a 3D volume, and not a 4D volume. Simple image manipulation: smoothing-------------------------------------Let's use an image-smoothing function from nilearn::func:`nilearn.image.smooth_img`Functions containing 'img' can take either a filename or an image as input.Here we give as inputs the image filename and the smoothing value in mm<jupyter_code>from nilearn import image
smooth_anat_img = image.smooth_img(MNI152_FILE_PATH, fwhm=3)

# While we are giving a file name as input, the function returns
# an in-memory object:
smooth_anat_img<jupyter_output><empty_output><jupyter_text>This is an in-memory object. We can pass it to nilearn function, forinstance to look at it<jupyter_code>plotting.plot_img(smooth_anat_img)<jupyter_output><empty_output><jupyter_text>We could also pass it to the smoothing function<jupyter_code>more_smooth_anat_img = image.smooth_img(smooth_anat_img, fwhm=3)
plotting.plot_img(more_smooth_anat_img)<jupyter_output><empty_output><jupyter_text>Saving results to a file-------------------------We can save any in-memory object as follows:<jupyter_code>more_smooth_anat_img.to_filename('more_smooth_anat_img.nii.gz')<jupyter_output><empty_output><jupyter_text>Finally, calling plotting.show() is necessary to display the figurewhen running as a script outside IPython<jupyter_code>plotting.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11771258819160788, 'fraction_numerical': 0.012996658002227999, 'mean_word_length': 5.368794326241135, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '13472', 'license': 'MIT', 'n_tokens_mistral': 862, 'n_tokens_neox': 805, 'n_words': 274, 'path': 'Files/plot_nilearn_101.ipynb', 'repo_name': 'KARTHIKEYANJM/Automatic-Covid-19-Classification-and-Segmentation', 'size': '2693'}