A lightweight Flask backend that exposes functional dissociation endpoints on top of a Neurosynth-backed PostgreSQL database.
The service provides two APIs that return studies mentioning one concept/coordinate but not the other (A \ B). You can also query the opposite direction (B \ A).
GET /dissociate/terms/<term_a>/<term_b>
Returns studies that mention term_a but not term_b.
Examples
/dissociate/terms/posterior cingulate/ventromedial prefrontal
/dissociate/terms/ventromedial prefrontal/posterior cingulate
GET /dissociate/locations/<x1_y1_z1>/<x2_y2_z2>
Coordinates are passed as x_y_z (underscores, not commas).
Returns studies that mention [x1, y1, z1] but not [x2, y2, z2].
Default Mode Network test case
/dissociate/locations/0_-52_26/-2_50_-6
/dissociate/locations/-2_50_-6/0_-52_26
Tip: You may design a single endpoint that returns both directions in one response (A–B and B–A) if that better suits your client.
Create a PostgreSQL database (e.g., on Render).
python check_db.py --url "postgresql://<USER>:<PASSWORD>@<HOST>:5432/<DBNAME>"python create_db.py --url "postgresql://<USER>:<PASSWORD>@<HOST>:5432/<DBNAME>"Deploy app.py as a Web Service (e.g., on Render) and set the environment variable:
DB_URL=postgresql://<USER>:<PASSWORD>@<HOST>:5432/<DBNAME>
Use a production server such as Gunicorn as your start command:
gunicorn app:app --bind 0.0.0.0:$PORTAfter deployment, check the basic endpoints:
- Images:
https://<your-app>.onrender.com/img - DB connectivity:
https://<your-app>.onrender.com/test_db
DB_URL– Full PostgreSQL connection string used by the app.
Example:postgresql://<USER>:<PASSWORD>@<HOST>:5432/<DBNAME>
Security note: Never commit real credentials to version control. Use environment variables or your hosting provider’s secret manager.
By terms
curl https://<your-app>.onrender.com/dissociate/terms/posterior cingulate/ventromedial prefrontal
curl https://<your-app>.onrender.com/dissociate/terms/ventromedial prefrontal/posterior cingulateBy coordinates
curl https://<your-app>.onrender.com/dissociate/locations/0_-52_26/-2_50_-6
curl https://<your-app>.onrender.com/dissociate/locations/-2_50_-6/0_-52_26- Python 3.10+
- PostgreSQL 12+
- Python dependencies (typical):
FlaskSQLAlchemy- PostgreSQL driver (e.g.,
psycopg2-binary) - Production WSGI server (e.g.,
gunicorn)
- Path parameters use underscores (
_) between coordinates:x_y_z. - Term strings should be URL-safe (e.g.,
posterior cingulate,ventromedial prefrontal). Replace spaces with underscores on the client if needed. - The term/coordinate pairs above illustrate a Default Mode Network dissociation example. Adjust for your analysis.
This project is licensed under the MIT License. See LICENSE for details.