Skip to main content

mstrial

Trial design and endpoints for MS, on top of msclinical: endpoints from plain tables, sample size for lesion counts, MRI schedules, power for PIRA endpoints through the whole pipeline, and what registered trials actually measure.

pip install mstrial
mstrial <tool> --help
Tool Command What it does
endpoints mstrial endpoints ARR, time to confirmed worsening, NEDA-3 and new-lesion rate in one call
lesionpower mstrial lesionpower negative binomial sample size for lesion-count endpoints
scanplan mstrial scanplan MRI schedule under a scan budget, with transient enhancement modelled
pirapower mstrial pirapower power for PIRA endpoints through rating noise, confirmation and attribution
registry mstrial registry endpoint landscape of registered MS trials, live from ClinicalTrials.gov

Research software, not a medical device. MIT licence. Each section below keeps the tool's own results and the corrections that three independent reviews made to them.

endpoints

formerly msendpoints

The standard MS trial endpoints from four plain tables, in one call: annualised relapse rate with a negative binomial rate ratio and 95 % CI, time to confirmed disability worsening (EDSS-plus or EDSS, via edssplus) with Kaplan-Meier and log-rank, NEDA-3 over year one (via neda, assessable patients only) and new T2 lesions per patient-year.

pip install mstrial
mstrial endpoints patients.tsv visits.tsv relapses.tsv --mri mri.tsv --horizon 2

patients.tsv: patient, arm, start, end. The output is one JSON a statistician can check line by line. An arm with no events gets rates and a stated reason, never a rate ratio of zero with a made-up interval.

lesionpower

Sample size and power for multiple sclerosis trials whose endpoint is a count of new lesions. Counts per patient are overdispersed, so a Poisson calculation promises too few patients. lesionpower fits a negative binomial to pilot counts and gives the closed-form sample size (Keene et al. 2007; Zhu and Lakkis 2014), with a simulation check for small counts.

pip install mstrial
mstrial lesionpower fit pilot.tsv --column new --exposure years      # mean, dispersion, n per arm for 30/50/70 %
mstrial lesionpower n --mu 4.2 --k 1.3 --reduction 0.5 --simulate

What the pilot data does to the answer

On the 24 longitudinal MSLesSeg patients (expert masks, new lesions from mscard, per patient-year of follow-up): mean 4.2 new lesions per year, dispersion k = 1.33, and not one patient with zero. A 50 % reduction then needs 37 patients per arm for 80 % power at one year.

The same data carries a warning. gtdrift finds that about half the lesion sites in MSLesSeg's multi-visit ground truth appear and disappear in ways a chronic lesion does not, so part of the "new lesion" count is annotation, not disease. A mean inflated by annotation noise makes the sample size look smaller than it is. Fit on counts from the reading protocol the trial will use.

scanplan

Monthly scans or more patients? For a gadolinium-enhancing lesion endpoint the answer is not obvious: enhancement lasts about three weeks, so a sparse schedule misses most enhancing lesions, while a dense one spends the scan budget on few patients. scanplan models that trade-off (negative binomial lesion counts, exponential enhancement duration, Keene et al. 2007 power) and returns the schedule with the highest power for a fixed number of scans. For new T2 lesions, which persist, fewer scans and more patients always win.

pip install mstrial
mstrial scanplan --budget 600 --years 1 --lam 4.2 --k 1.33 --reduction 0.3            # enhancing lesions
mstrial scanplan --budget 600 --years 1 --lam 4.2 --k 1.33 --reduction 0.3 --endpoint t2

With 600 scans, 4.2 new lesions per patient-year and dispersion 1.33 (the MSLesSeg pilot fit from lesionpower), for a 30 % reduction on enhancing lesions:

interval_days  scans_per_patient  years_covered  patients_per_arm  detect_p  control_mean_count  power
            30                 13          0.986                23     0.532               2.203  0.184
            60                  7          0.986                42     0.330               1.366  0.247
            91                  5          0.997                60     0.228               0.953  0.278
           182                  3          0.997               100     0.115               0.483  0.286
           365                  2          0.999               150     0.058               0.241  0.250
best: every 182 days, 100 per arm, power 0.29

Under this much between-patient overdispersion the 2/k term dominates the variance, so even for a transient endpoint more patients scanned twice beat fewer patients scanned monthly. With counts close to Poisson (--k 20) the optimum moves to quarterly scans with fewer patients.

The model and its assumptions (one enhancement duration for all lesions, no seasonal or treatment effect on duration) are in mstrial/scanplan/core.py. Research software. MIT.

pirapower

PIRA (progression independent of relapse activity) is becoming a trial endpoint. Its power is usually computed as if the true PIRA events were observed. They are not. Every event passes through EDSS rating noise, a confirmation window and relapse attribution before it is counted. pirapower simulates that whole pipeline: sim cohorts with a known PIRA reduction, edssplus for confirmed worsening, pirma for attribution, and a log-rank test on time to first PIRA.

pip install mstrial
mstrial pirapower --n 250 500 1000 --effect 0.3 --years 2 --noise 0.15 --confirm-days 168 --reps 100

A 30 % true reduction, two years (results/pirapower/results/power.tsv, 60 simulated trials per cell; regenerated 2026-09-30)

EDSS misrating Confirmation 250 per arm 500 per arm 1000 per arm
15 % of visits 24 weeks 0.15 0.30 0.57
30 % of visits 24 weeks 0.22 0.22 0.62
30 % of visits 12 weeks 0.25 0.37 0.67

Even 1000 patients per arm reach only about 60 % of the conventional 80 % power. The ratio of first-PIRA event counts between arms is 0.72 to 0.76, against a true PIRA rate ratio of 0.70: events that are really rating noise or misattributed steps dilute the effect. Shorter confirmation adds noise events but adds real events faster, and gains power here. With 60 replicates per cell each power has a standard error of about 0.06, so neighbouring cells within about 0.1 of each other are not distinguishable.

The simulation model is simple and its parameters are in sim: PIRA 0.12 episodes per patient-year, EDSS every 3 months, and in the active arm a relapse and new-lesion rate ratio of 0.5 besides the PIRA effect (the default two-arm design). These numbers were regenerated after an independent review found that sim's noise levels had simulated different cohorts; the earlier table is superseded. Research software. MIT.

registry

formerly mstrials

Which endpoints do multiple sclerosis trials actually measure? registry asks ClinicalTrials.gov through its public API. It searches every registered MS study whose outcome measures mention an endpoint (PIRA, slowly expanding lesions, paramagnetic rim lesions, central vein sign, neurofilament light, GFAP, NEDA, EDSS-plus, SDMT, OCT, brain atrophy) and counts them by phase, status and start year. Every matched study is written out with its NCT number, so each count can be checked.

pip install mstrial
mstrial registry --out studies.tsv

Landscape on 2026-09-30 (results/registry/results/)

studies  interventional  phase 3  recruiting or not yet  started 2023 or later
endpoint                                                                                                
SDMT / cognition              441             342       62                    104                    150
brain atrophy                 236             201       77                     34                     39
neurofilament light           167             121       33                     60                     86
OCT retina                     85              53        4                     25                     20
NEDA                           63              35       16                     14                     23
GFAP                           47              26        4                     26                     27
paramagnetic rim lesions       25              19        3                     14                     15
PIRA                           23              12        8                     12                     16
EDSS-plus / composite          10               8        1                      2                      4
central vein sign              10               4        0                      4                      4
slowly expanding lesions        9               7        2                      5                      5

PIRA, the endpoint the progressive-MS field is converging on, appears in the outcomes of 23 registered MS studies, 8 of them phase 3. Slowly expanding lesions appear in 9, paramagnetic rim lesions in 25 and the central vein sign in 10. The tools that measure those endpoints (pirma, lesiontrack, mscard) matter for a few dozen trials now, and for many more soon.

Precision was checked by reading the outcome text of every hit for three endpoints. All 9 slowly expanding lesion hits and all 10 central vein sign hits contain the phrase; 22 of 25 paramagnetic rim lesion hits do (the other three mention rim lesions another way or not at all). The search terms are short quoted phrases ("slowly expanding", not "slowly expanding lesion", which the API matches exactly and which misses every "lesions"; unquoted terms match the words anywhere, so "slow-wave" plus "Expanded Disability" counted as a hit in an earlier version). The other counts are outcome-text matches, not a curated review. Research software. MIT.

Metadata

Release files for mstrial 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mstrial 0.1.0
File Size Uploaded Provenance Actions
mstrial-0.1.0.tar.gz 22.4 kB Without provenance Details for mstrial-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mstrial 0.1.0
File Interpreter ABI Platform Actions
mstrial-0.1.0-py3-none-any.whl Python 3 none any Details for mstrial-0.1.0-py3-none-any.whl

Total release size: 43.8 kB

Release files / mstrial-0.1.0.tar.gz

Download URL mstrial-0.1.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e31bfd61e1970a21e9e4c19558a92b2d2f4c391b38fd62539a90de1412dd023f
BLAKE2b-256 checksum
How to use checksums
f90f3e5bb0d5505f9592c5bbee0fc01c498fa9525803689670bd97b65f4d0a89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / mstrial-0.1.0-py3-none-any.whl

Download URL mstrial-0.1.0-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e03ef7c7585fb297badfc6c312f0aef0350f9e4473580425be7ee6a48a2c7c33
BLAKE2b-256 checksum
How to use checksums
98b1f9e9a38a9d55c0e787caee69563b55525652e508465c9e333db8576e4caf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for mstrial 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page