CLI & Script Reference
This page is the detailed reference for PRISM’s command-line tools and scripts.
For a first-time, step-by-step narrative: see QUICK_START.md.
For specification / schema details: see SPECIFICATIONS.md.
For derivative scoring recipes: see RECIPES.md.
Run-first daily checks (repo root):
# fast sanity
bash scripts/ci/run_local_smoke.sh
# full required gate
bash scripts/ci/run_runtime_gate.sh
0) Environment requirement (.venv)
Both prism.py and prism_tools.py enforce running from the repo-local virtual environment at ./.venv.
macOS / Linux:
source .venv/bin/activate
Windows:
.venv\Scripts\activate
If you see:
❌ Error: You are not running inside the prism virtual environment!
activate the environment and retry.
1) prism.py — the dataset validator
Purpose
Validate a dataset against BIDS rules (optional) and PRISM schemas.
Produce machine-readable reports (JSON, SARIF, JUnit, Markdown, CSV).
Optionally apply safe auto-fixes (
--fix).
Usage
python prism-validator /path/to/dataset
Options (complete)
Option |
Meaning |
|---|---|
|
Print detailed progress / scanning info. |
|
Choose schema version (e.g. |
|
Show schema details for a modality (currently a minimal stub). |
|
List schema versions available in |
|
Run the standard BIDS validator in addition to PRISM validation. |
|
Include warnings from BIDS validator output (default hidden). |
|
Skip PRISM-specific checks (only BIDS if |
|
Validate all survey/biometrics JSON templates in a library directory. See Template Validation for details. |
|
Build a privacy-safe |
|
Input scans table containing |
|
Output path for generated |
|
Site latitude used by environment providers (required with |
|
Site longitude used by environment providers (required with |
|
Provider list for enrichment (default: |
|
Cache file for provider responses (default: |
|
Output a JSON report to stdout (compact). |
|
Output a JSON report to stdout (pretty). |
|
Set an explicit output format. |
|
Write report to a file. |
|
Apply auto-fixes for common issues (e.g., missing sidecars, |
|
Show what |
|
List which issue types are auto-fixable. |
|
Create a validator plugin template at |
|
List plugins loaded for a dataset. |
|
Disable plugin loading. |
|
Print PRISM version and exit. |
Common examples
# Validate
python prism-validator /data/study-01
# Validate with BIDS validator too
python prism-validator /data/study-01 --bids
# Produce SARIF for GitHub Code Scanning
python prism-validator /data/study-01 --format sarif -o prism.sarif
# Validate survey templates in your project library
python prism-validator --validate-templates /code/library/survey
# Build privacy-safe environment table from scans anchors
python prism-validator \
--build-environment \
--scans-tsv /data/study-01/sub-01/ses-01/sub-01_ses-01_scans.tsv \
--environment-tsv /data/study-01/sub-01/ses-01/environment/sub-01_ses-01_environment.tsv \
--lat 47.07 \
--lon 15.44
# Auto-fix (preview)
python prism-validator /data/study-01 --fix --dry-run
# Auto-fix (apply)
python prism-validator /data/study-01 --fix
Environment build mode (--build-environment)
Uses privacy-safe temporal anchors (
prism_time_anchor) fromscans.tsv.Rejects raw time keys like
date,datetime,timestamp,acquisition_timein input rows.Runs independently from normal dataset validation (you can call it without positional
dataset).Current bundled providers:
weather,pollen,air_quality.
2) prism_tools.py — conversions, libraries, and helpers
Purpose
prism_tools.py is the “Swiss Army Knife” for creating and managing PRISM-compatible content:
Import Survey and Biometrics libraries from Excel
Convert wide survey exports into a PRISM/BIDS-like dataset
Create survey derivatives (scores, reverse-coding) using Recipes
Convert Varioport
.rawphysio data into BIDS-like outputGenerate manuscript-ready Methods boilerplate from your libraries
Manage and synchronize library templates
Usage
python prism_tools.py --help
python prism_tools.py <command> --help
Command overview
recipes (Derivatives)
Compute scores and subscales based on JSON recipe files.
# Compute survey scores
python prism_tools.py recipes surveys --prism /path/to/dataset
# Compute biometrics scores
python prism_tools.py recipes biometrics --prism /path/to/dataset
library (Management)
Tools for maintaining the PRISM library.
# Generate methods boilerplate
python prism_tools.py library generate-methods-text --output methods.md --lang en
# Fill missing schema keys in library files
python prism_tools.py library fill --modality survey --path library/survey/
# Synchronize keys across library files
python prism_tools.py library sync --modality biometrics --path library/biometrics/
# Generate a CSV catalog of the library
python prism_tools.py library catalog --input library/survey --output catalog.csv
The generated Methods boilerplate now summarizes the richer PRISM schema metadata (DOIs, licenses, age ranges, administration/scoring times, item counts, and access levels) alongside the existing citations.
survey / biometrics (Conversions)
Import data from external formats.
# Import from LimeSurvey (LSA)
python prism_tools.py survey import-limesurvey --input survey.lsa --output library/survey/
# Import from Excel
python prism_tools.py survey import-excel --input data.xlsx --output library/survey/
convert physio
Convert Varioport physiological recordings (.raw, .vpd) into outputs from either a sourcedata directory or a single file.
python prism_tools.py convert physio \
--input ./sourcedata \
--output ./rawdata \
--task rest \
--suffix ecg \
--sampling-rate 256
wide-to-long
Convert a wide survey-style table into a long table by matching exact session indicators in column names.
# Inspect matches and rename preview without writing output
python prism.py wide-to-long \
--input build/Limesurvey_gesamt.xlsx \
--session-indicators T1_,T2_,T3_ \
--inspect-only
# Convert and write a CSV
python prism.py wide-to-long \
--input survey_export.xlsx \
--output survey_export_long.csv \
--session-indicators T1_,T2_,T3_
Key options:
--session-indicators: comma-separated exact tokens to match anywhere in the column name, for exampleT1_,T2_,T3_or_pre,_post--session-map: optional indicator-to-session mapping such asT1_:pre,T2_:post--inspect-only: print indicator counts, rename preview, and ambiguity warnings without writing a file--preview-limit: limit how many preview lines are printed--force: overwrite an existing output file
Notes:
If the same indicator appears multiple times in a column name, the backend treats that as ambiguous and refuses conversion until the indicator is made more specific.
Output format is inferred from the output file extension:
.csv,.tsv, or.xlsx.
participants
Participants helper commands used by the web converter backend and terminal workflows.
Important:
Use absolute file paths for
--input.--projectcan point to either a project root directory or aproject.jsonfile path.participants convertwritesparticipants.tsvinto the resolved project root.
# Detect participant ID column
python prism_tools.py participants detect-id \
--input /absolute/path/to/T1.xlsx \
--sheet 0 \
--separator auto \
--json
# Preview participant extraction columns/rows
python prism_tools.py participants preview \
--input /absolute/path/to/T1.xlsx \
--sheet 0 \
--id-column ID \
--separator auto \
--project /absolute/path/to/my-project/project.json \
--preview-limit 20 \
--json
# Convert to participants.tsv under project root
python prism_tools.py participants convert \
--input /absolute/path/to/T1.xlsx \
--sheet 0 \
--id-column ID \
--separator auto \
--project /absolute/path/to/my-project/project.json \
--force \
--json
demo create
Create a demo dataset for testing.
python prism_tools.py demo create --output archive/prism_demo_copy
survey import-excel
Import survey templates from an Excel codebook into a JSON library.
python prism_tools.py survey import-excel --excel surveys.xlsx --library-root library
survey validate
Validate survey library JSONs and enforce uniqueness constraints.
python prism_tools.py survey validate --library library/survey
survey convert
Convert a wide survey export (.xlsx or LimeSurvey .lsa) into a PRISM/BIDS-like dataset.
python prism_tools.py survey convert \
--input survey_export.xlsx \
--output /tmp/my_prism_dataset
Key options:
--library: select template folder--lang: language selection for i18n templates (dedefault;autofor.lsa)--unknown {error,warn,ignore}: how to handle unmapped columns--dry-run: print mapping only--force: allow writing into non-empty output directory
survey import-limesurvey / survey import-limesurvey-batch
Import LimeSurvey instruments into PRISM templates/datasets.
python prism_tools.py survey import-limesurvey --input instrument.lsa --output survey-ads.json
python prism_tools.py survey import-limesurvey-batch \
--input-dir ./limesurvey_exports \
--output-dir ./my_dataset \
--session-map t1:ses-1,t2:ses-2,t3:ses-3
survey i18n-migrate / survey i18n-build
Create and compile i18n-capable survey templates.
# Create i18n source templates (no translation added automatically)
python prism_tools.py survey i18n-migrate --src library/survey --dst library/survey_i18n --languages de,en
# Compile i18n templates for one target language
python prism_tools.py survey i18n-build --src library/survey_i18n --out library/survey_de --lang de --fallback de
biometrics import-excel
Import biometrics templates from an Excel codebook.
python prism_tools.py biometrics import-excel \
--excel biometrics_codebook.xlsx \
--sheet 0 \
--library-root library
Key options:
--equipment: defaultTechnical.Equipment--supervisor: defaultTechnical.Supervisor
dataset build-biometrics-smoketest
Generate a small biometrics dataset (templates + dummy data) for testing.
python prism_tools.py dataset build-biometrics-smoketest --output /tmp/prism_biometrics_smoketest
derivatives surveys / derivatives biometrics
Compute derived scores from TSVs in an already valid PRISM dataset.
# Survey derivatives
python prism_tools.py derivatives surveys --prism /path/to/dataset --format prism
# Biometric derivatives (supports xlsx, csv, save, r)
python prism_tools.py derivatives biometrics --prism /path/to/dataset --format xlsx
See RECIPES.md for details on how to write scoring recipes.
library generate-methods-text
Generate manuscript-ready methods text from libraries.
python prism_tools.py library generate-methods-text --output methods_en.md --lang en
python prism_tools.py library generate-methods-text --output methods_de.md --lang de
3) “Scripts” in scripts/
Environment enrichment scripts
Note: These utilities are currently parked under scripts/future_feature/.
They are planned work and not part of the active web/CLI backend runtime path yet.
For regular use, prefer prism_tools.py / backend modules.
PRISM now provides two separate scripts for environmental enrichment:
Scanner / DICOM workflow (site-fixed, scanner-related):
python scripts/future_feature/build_environment_from_dicom.py \
--dicom /path/to/file.dcm \
--dataset-root /path/to/dataset \
--subject-id sub-01 \
--session-id ses-01
Extracts acquisition timestamp from DICOM.
Uses hardcoded scanner site coordinates.
Writes directly to
sub-*/ses-*/environment/*_environment.tsv.Updates
.bidsignorein dataset root.
Survey / international workflow (location provided per run):
python scripts/future_feature/build_environment_from_survey.py \
--timestamp 2026-02-26T14:30:00 \
--lat 47.0707 \
--lon 15.4395 \
--location-label survey-site \
--output /path/to/sub-01_ses-01_environment.tsv \
--subject-id sub-01 \
--session-id ses-01
Uses provided timestamp + coordinates.
Designed for multi-country survey studies.
Writes one-row environment TSV for the specified context.
Both scripts query Open-Meteo hourly weather/air-quality/pollen APIs and include moon and sun context variables.
Most files under scripts/ are implementation details called by the CLIs.
If you’re a new user, prefer:
python prism-validator ...(validation)python prism_tools.py ...(imports/conversion/derivatives)python prism-studio.py(web interface)
If you are developing PRISM, refer to the repository changelog file (CHANGELOG.md).