{"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.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install -U nilearn"],"cli":null},"imports":["from nilearn import datasets","from nilearn import plotting","from nilearn.maskers import NiftiMasker","from nilearn import image","from nilearn.decoding import Decoder"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.12.1","pypi_latest":"0.13.1","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":15.7,"avg_import_s":5.45,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"-U","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"-U","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":14.9,"import_time_s":3.63,"mem_mb":80.1,"disk_size":"379M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"-U","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"-U","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":14.9,"import_time_s":6.13,"mem_mb":98.1,"disk_size":"406M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"-U","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"-U","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":15.4,"import_time_s":6.88,"mem_mb":96,"disk_size":"385M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"-U","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"-U","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":15.5,"import_time_s":6.41,"mem_mb":97.1,"disk_size":"383M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"-U","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"-U","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":17.9,"import_time_s":4.18,"mem_mb":78,"disk_size":"407M"}]}}