{"id":8353,"library":"nilearn","title":"Nilearn","description":"Nilearn is a Python library for statistical learning with neuroimaging data. It provides tools for general linear model (GLM) based analysis and leverages the scikit-learn toolbox for multivariate statistics, including predictive modeling, classification, decoding, and connectivity analysis. The current stable version is 0.13.1, and releases occur regularly, often including new features, enhancements, and deprecations.","status":"active","version":"0.13.1","language":"python","source_language":"en","source_url":"https://github.com/nilearn/nilearn","tags":["neuroimaging","fMRI","machine-learning","brain-imaging","scientific-computing","data-analysis"],"install":[{"cmd":"pip install -U nilearn","lang":"bash","label":"Install latest stable version"},{"cmd":"conda create -n nilearn_env python=3.10\nconda activate nilearn_env\npip install -U nilearn","lang":"bash","label":"Install in a Conda environment"}],"dependencies":[{"reason":"Nilearn requires Python 3.10 or later.","package":"python","optional":false},{"reason":"Required for most plotting functionalities.","package":"matplotlib","optional":false},{"reason":"Core scientific computing dependency.","package":"scipy","optional":false},{"reason":"Used for fetching datasets.","package":"requests","optional":false},{"reason":"A new dependency added in 0.13.0.","package":"jinja2","optional":false},{"reason":"Optional plotting engine for some functions.","package":"plotly","optional":true},{"reason":"Required for static image export with Plotly.","package":"kaleido","optional":true}],"imports":[{"symbol":"datasets","correct":"from nilearn import datasets"},{"note":"Submodules of `nilearn.plotting` like `image` and `surface` were refactored and merged into the main `plotting` module for direct access (e.g., `plot_img` is directly under `nilearn.plotting`).","wrong":"from nilearn.plotting.image import plot_img","symbol":"plotting","correct":"from nilearn import plotting"},{"note":"Masker classes like `NiftiMasker` were moved from `nilearn.input_data` to `nilearn.maskers`.","wrong":"from nilearn.input_data import NiftiMasker","symbol":"NiftiMasker","correct":"from nilearn.maskers import NiftiMasker"},{"symbol":"image","correct":"from nilearn import image"},{"symbol":"Decoder","correct":"from nilearn.decoding import Decoder"}],"quickstart":{"code":"import warnings\nwarnings.filterwarnings(\"ignore\", message=\"The provided image has no sform in its header.\")\n\nfrom nilearn import datasets, plotting, maskers\n\n# 1. Fetch a sample fMRI dataset (Haxby dataset)\nhaxby_dataset = datasets.fetch_haxby(subjects=1, fetch_stimuli=False)\nfmri_filename = haxby_dataset.func[0]\nanat_filename = haxby_dataset.anat[0]\nmask_filename = haxby_dataset.mask_vt[0]\n\n# 2. Extract signals using NiftiMasker\n# The mask_strategy='epi' is often more robust for EPI images\nmasker = maskers.NiftiMasker(mask_img=mask_filename, smoothing_fwhm=6, standardize='zscore_sample')\nfmri_data_masked = masker.fit_transform(fmri_filename)\n\n# 3. Plot the anatomical image and overlay the mask\nprint(f\"Shape of masked fMRI data: {fmri_data_masked.shape}\")\n\n# Plotting the anatomical image with the mask overlay\nplotting.plot_anat(\n    anat_filename,\n    title=\"Anatomical image with mask overlay\",\n    display_mode='ortho',\n    cut_coords=(0, 0, 0),\n    output_file=None # Change to a filename like 'anat_with_mask.png' to save\n)\n\n# Plotting a single volume from the fMRI data\nfirst_fmri_volume = image.index_img(fmri_filename, 0)\nplotting.plot_img(\n    first_fmri_volume,\n    bg_img=anat_filename,\n    title=\"First fMRI volume\",\n    display_mode='ortho',\n    cut_coords=(0, 0, 0),\n    output_file=None # Change to a filename like 'first_fmri_volume.png' to save\n)\n\n# You can also show the plots (usually at the end of a script or in an interactive session)\n# plotting.show()","lang":"python","description":"This quickstart fetches the Haxby fMRI dataset, applies a ventral temporal mask, extracts time series data, and then visualizes the anatomical image with the mask overlay and a single fMRI volume. It demonstrates common steps of data loading, masking, and basic visualization."},"warnings":[{"fix":"Upgrade Python to 3.10 or higher. For example, using Conda: `conda create -n nilearn_env python=3.10; conda activate nilearn_env`.","message":"Nilearn 0.13.0 dropped support for Python 3.9. Users on Python 3.9 or older versions will encounter installation errors or unexpected behavior.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Update import statements: `from nilearn.input_data import NiftiMasker` should become `from nilearn.maskers import NiftiMasker`.","message":"The `nilearn.input_data` module has been refactored and masker classes (e.g., `NiftiMasker`, `NiftiLabelsMasker`) are now located in `nilearn.maskers`. Direct imports from `nilearn.input_data` will raise an `ImportError`.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Replace `standardize=True` with `standardize='zscore_sample'` and `standardize=False` with `standardize=None`. For example, `NiftiMasker(standardize=True)` should be `NiftiMasker(standardize='zscore_sample')`.","message":"The `standardize` parameter in various functions and maskers (e.g., `plot_carpet`, `NiftiMasker`) no longer accepts boolean `True`/`False`. Its default behavior changed, and specific string values like `'zscore_sample'` or `None` should be used.","severity":"deprecated","affected_versions":">=0.13.0"},{"fix":"Review calls to these dataset fetching functions and explicitly set parameters if you rely on the previous default behaviors.","message":"Default values for parameters in `fetch_atlas_yeo_2011`, `fetch_atlas_craddock_2012`, and `fetch_atlas_smith_2009` have changed in 0.13.0. For instance, `n_networks` and `thickness` in `fetch_atlas_yeo_2011` now default to `7` and `'thick'` respectively, instead of `None`.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"If you need to maintain the neurological orientation, ensure `radiological=False` is passed to plotting functions that support it.","message":"Plotting functions like `plot_img` now accept a `radiological` parameter (defaulting to `False`) which inverts the x-axis and L/R annotations for radiological convention. If you rely on the old orientation, ensure `radiological=False` is set explicitly.","severity":"gotcha","affected_versions":">=0.13.1"}],"env_vars":null,"search_vec":"'0.13.1':46 'analysi':22,40,71 'base':21 'brain':64 'brain-imag':63 'classif':36 'comput':68 'connect':39 'current':42 'data':12,70 'data-analysi':69 'decod':37 'deprec':57 'enhanc':55 'featur':54 'fmri':59 'general':17 'glm':20 'imag':65 'includ':33,52 'learn':9,28,62 'leverag':24 'librari':6 'linear':18 'machin':61 'machine-learn':60 'model':19,35 'multivari':31 'neuroimag':11,58 'new':53 'nilearn':1,2 'occur':49 'often':51 'predict':34 'provid':14 'python':5 'regular':50 'releas':48 'scientif':67 'scientific-comput':66 'scikit':27 'scikit-learn':26 'stabl':43 'statist':8,32 'tool':15 'toolbox':29 'version':44","created_at":"2026-04-16T17:01:45.663505+00:00","updated_at":"2026-04-16T17:01:45.663505+00:00","problems":{"verify_error":"error: unexpected argument '- ' found\n\n  tip: to pass '- ' as a value, use '-- - '\n\nUsage: uv pip install [OPTIONS] <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>|--group <GROUP>>\n\nFor more information, try '--help'."},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.13.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://nilearn.github.io","github":"https://github.com/nilearn/nilearn","docs":null,"changelog":"https://nilearn.github.io/stable/changes/whats_new.html","pypi":"https://pypi.org/project/nilearn/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}