NeuroLang

Probabilistic Logic Programming for Neuroimaging Analysis

NeuroLang is a probabilistic logic programming system for the analysis of neuroimaging data. It lets you express complex queries over brain images, ontologies, and tabular databases in a declarative style — and reason about them probabilistically.


🧠 Language

A declarative language built on Datalog — a logic rule-based query language for relational data. Write what you want, not how to compute it.

🎲 Probabilistic Solver

Supports discrete, probabilistic, and open-world reasoning. Query over uncertain data with sound probabilistic semantics.

🐍 Python Integration

Embed logic programs directly in Python. Load images, dataframes, and ontologies as relations with NeurolangDL.


Quick Start#

pip install neurolang
from neurolang.frontend import NeurolangDL

nl = NeurolangDL()
nl.add_tuple_set([(0, 1), (1, 2), (2, 3)], name="connected")

with nl.environment as e:
    e.reachable[e.x, e.y] = e.connected[e.x, e.y]
    e.reachable[e.x, e.y] = e.reachable[e.x, e.z] & e.connected[e.z, e.y]
    result = nl.query((e.x, e.y), e.reachable(e.x, e.y))

print(result)

See Installing NeuroLang for full installation instructions and Get Started with NeuroLang for a guided walkthrough.