Skip to main content

yoshika

Yielding Open Simulation of Hybrid Inter-disciplinary Kinetic Absorption

A Python PKPD (pharmacokinetic/pharmacodynamic) package for local anesthetics with selectable initial compartment.

Motivation

Traditional 3-compartment PK models (Marsh, Schnider, Eleveld, etc.) assume intravenous administration where drug enters plasma (V1) first. However, in regional anesthesia:

  • Successful block → drug starts in vessel-poor tissue (bpt/V3)
  • Failed block → drug starts in vessel-rich tissue (brt/V2) or plasma

yoshika allows selecting the initial compartment to simulate these clinically distinct scenarios and compare their pharmacokinetic profiles.

Installation

pip install yoshika

Or install from source:

git clone https://github.com/bougtoir/wip.git
cd wip
pip install -e ".[dev]"

Quick Start

from yoshika import Simulator, Drug, Compartment

# Create a simulator for bupivacaine 150mg in a 70kg patient
sim = Simulator(drug=Drug.BUPIVACAINE, dose_mg=150, weight_kg=70)

# Simulate with drug starting in vessel-poor tissue (successful block)
result = sim.run(initial_compartment=Compartment.BPT)

print(f"Peak plasma concentration: {result.pk.peak_plasma_concentration:.2f} mg/L")
print(f"Time to peak: {result.pk.time_to_peak:.1f} min")

Compare Scenarios

Compare IV administration vs. successful vs. failed block:

from yoshika import Simulator, Drug
from yoshika.plotting import plot_comparison
from yoshika.drugs import DrugLibrary

sim = Simulator(drug=Drug.BUPIVACAINE, dose_mg=150, weight_kg=70)
results = sim.compare()  # Runs plasma, brt, bpt scenarios

# Summary table
table = Simulator.summary_table(results)
print(table)

# Plot plasma concentration comparison with toxicity thresholds
params = DrugLibrary.get(Drug.BUPIVACAINE)
fig, ax = plot_comparison(results, drug_params=params)
fig.savefig("comparison.png", dpi=150)

Supported Drugs

Drug V1 (L) V2 (L) V3 (L) CNS Toxicity (mg/L) CV Toxicity (mg/L)
Lidocaine 12.0 33.0 60.0 5.0 10.0
Bupivacaine 9.8 23.0 62.0 2.0 4.0
Ropivacaine 10.5 25.0 58.0 2.2 4.4
Levobupivacaine 10.0 24.0 60.0 2.5 5.0

Compartment Model

                    ┌──────────────┐
                    │   PLASMA     │
                    │   (V1)       │◄──── k10 (elimination)
                    └──────┬───────┘
                     ▲     │     ▲
                k12/k21    │   k13/k31
                     │     │     │
              ┌──────┴──┐  │  ┌──┴──────┐
              │  BRT     │  │  │  BPT    │
              │  (V2)    │  │  │  (V3)   │
              │ vessel-  │  │  │ vessel- │
              │ rich     │  │  │ poor    │
              └──────────┘  │  └─────────┘
                            │
                    ┌───────┴──────┐
                    │   DEPOT      │
                    │ (injection)  │───── ka (absorption)
                    └──────────────┘

Initial compartment options:

  • Compartment.PLASMA — IV administration (traditional model)
  • Compartment.BRT — Failed block / intravascular injection
  • Compartment.BPT — Successful peripheral block
  • Compartment.DEPOT — Depot absorption (fascial plane blocks, epidural administration)

Epidural Administration

Epidural administration can be approximated using the Depot compartment (Compartment.DEPOT). In epidural anesthesia, the drug is injected into the epidural space and is absorbed into the systemic circulation primarily through epidural venous plexus uptake, with concurrent diffusion across the dura into the CSF. This absorption process follows approximately first-order kinetics, which is modeled by the depot compartment's absorption rate constant (ka). While the actual epidural pharmacokinetics involves parallel pathways (vascular absorption, dural penetration, and epidural fat sequestration), the depot model provides a reasonable first-order approximation of the systemic absorption phase.

Users can adjust the ka parameter to match published epidural absorption rates for specific local anesthetics.

Spinal (Intrathecal) Administration

Spinal (subarachnoid) administration is not modeled in the current version. Intrathecal injection delivers drug directly into the cerebrospinal fluid (CSF), involving unique pharmacokinetics (CSF spread, direct spinal cord uptake, and subsequent systemic absorption) that differ fundamentally from the peripheral compartment model. Additionally, spinal anesthesia is predominantly a single-shot technique with relatively small doses (e.g., bupivacaine 10–15 mg), making systemic toxicity modeling less clinically relevant compared to larger-dose peripheral nerve blocks and epidural techniques.

Clinical Scenario Mapping

Clinical Scenario Initial Compartment Rationale
IV injection Compartment.PLASMA Drug enters central circulation directly
Failed nerve block (intravascular) Compartment.BRT Accidental injection into vessel-rich tissue
Successful peripheral nerve block Compartment.BPT Drug deposited in vessel-poor tissue around nerves
Fascial plane block Compartment.DEPOT Absorption from tissue plane via first-order kinetics
Epidural administration Compartment.DEPOT Approximate: absorption from epidural space via first-order kinetics
Spinal (intrathecal) Not supported Requires CSF compartment (not implemented)

API Reference

Core Classes

  • Simulator — High-level simulation engine
  • PKModel — 3-compartment PK ODE model
  • Drug — Drug enum (LIDOCAINE, BUPIVACAINE, ROPIVACAINE, LEVOBUPIVACAINE)
  • Compartment — Compartment enum (PLASMA, BRT, BPT, DEPOT)
  • DrugLibrary — Drug parameter database
  • EffectSiteModel — Effect-site equilibration (ke0)
  • SigmoidEmaxModel — Sigmoid Emax PD model

Plotting Functions

  • plot_concentration(result) — Concentration-time curves for all compartments
  • plot_comparison(results) — Multi-scenario plasma concentration comparison
  • plot_effect(results) — PD effect comparison

Utility Functions

  • auc_trapezoidal(time, conc) — AUC calculation
  • half_life_terminal(time, conc) — Terminal half-life estimation
  • time_above_threshold(time, conc, threshold) — Duration above toxic threshold
  • compartment_from_string(name) — String-to-Compartment conversion

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Lint
ruff check yoshika/ tests/

# Type check
mypy yoshika/

License

MIT License

Citation

If you use yoshika in your research, please cite:

@article{yoshika2025,
  title={yoshika: A Python Package for Pharmacokinetic-Pharmacodynamic Simulation of Local Anesthetics with Selectable Initial Compartment},
  author={Onishi, Tatsuki},
  year={2025},
  journal={Journal of Open Source Software}
}

Metadata

Release files for yoshika 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 yoshika 0.1.0
File Size Uploaded Provenance Actions
yoshika-0.1.0.tar.gz 26.5 kB Without provenance Details for yoshika-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 50.0 kB

Release files / yoshika-0.1.0.tar.gz

Download URL yoshika-0.1.0.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bb5deb1c6abc91b7c74648abb89164864292738941d02c1ab230b5ee13e422b5
BLAKE2b-256 checksum
How to use checksums
34b6049c1f54e14305e7837c19b402c93ec6f7d0acfaf084d7defaacff5426dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

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

Download URL yoshika-0.1.0-py3-none-any.whl
Size 23.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6eb8ceab3afa8cfd0a66f223d17b0a5f21ebced8c1b1460d80d5119418b8e15d
BLAKE2b-256 checksum
How to use checksums
65fbf9e04740b2ca80554618add4471f5b947a9f02161747f452452dcb014441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Security for yoshika 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