Skip to content

Commit ec2adb4

Browse files
authored
Merge pull request #12 from virtualcell/image-geometry
simulate vcml model with image-based goemetry
2 parents a46e446 + 585a864 commit ec2adb4

25 files changed

+2862
-212
lines changed

examples/geometry/bunny.tgz

22.2 KB
Binary file not shown.

examples/models/Bunny.vcml

Lines changed: 492 additions & 0 deletions
Large diffs are not rendered by default.

examples/models/Bunny_sbml.xml

Lines changed: 467 additions & 0 deletions
Large diffs are not rendered by default.

examples/notebooks/_internal_n5_download_demo.ipynb

Lines changed: 96 additions & 43 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import matplotlib.pyplot as plt
2+
from tensorstore._tensorstore import TensorStore # type: ignore[import-untyped]
3+
4+
from pyvcell._internal.simdata.n5_data import vcell_n5_datastore
5+
from pyvcell.sim_results.var_types import NDArray2D
6+
7+
url = "https://vcell-dev.cam.uchc.edu/n5Data/ACowan/4b5ac930c40d5ba.n5"
8+
dataset_name = "4248805214"
9+
data_store: TensorStore = vcell_n5_datastore(base_url=url, dataset_name=dataset_name)
10+
print(f"shape = {data_store.shape}")
11+
12+
np_data: NDArray2D = data_store[:, :, 0, 0, 0].read().result()
13+
print("slice shape:", np_data.shape)
14+
15+
plt.imshow(np_data)
16+
plt.show()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
from pathlib import Path
3+
4+
from pyvcell.sbml.sbml_simulation import SbmlSpatialSimulation
5+
from pyvcell.sbml.sbml_spatial_model import SbmlSpatialModel
6+
7+
model_fp = Path(os.getcwd()).parent / "models" / "Bunny_sbml.xml"
8+
9+
# define editable spatial model and simulation instances
10+
spatial_model = SbmlSpatialModel(filepath=model_fp)
11+
spatial_model.copy_parameters()
12+
simulation = SbmlSpatialSimulation(sbml_model=spatial_model)
13+
result = simulation.run()
14+
15+
print([(c.label, c.domain_name) for c in result.channel_data])
16+
result.plotter.plot_slice_2d(time_index=3, channel_name="s_in", z_index=result.zarr_dataset.shape[3] // 2)
17+
result.plotter.plot_slice_3d(time_index=3, channel_id="s_in")
18+
result.plotter.plot_concentrations()
19+
simulation.cleanup()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
from pathlib import Path
3+
4+
from pyvcell.vcml import VcmlReader
5+
from pyvcell.vcml.vcml_simulation import VcmlSpatialSimulation
6+
7+
model_fp = Path(os.getcwd()).parent / "models" / "Bunny.vcml"
8+
9+
bio_model = VcmlReader.biomodel_from_file(model_fp)
10+
sims = [sim for app in bio_model.applications for sim in app.simulations]
11+
12+
# define editable spatial model and simulation instances
13+
simulation = VcmlSpatialSimulation(bio_model=bio_model)
14+
result = simulation.run(sims[0].name)
15+
16+
print([c.label for c in result.channel_data])
17+
result.plotter.plot_slice_2d(time_index=3, channel_name="s_in", z_index=result.zarr_dataset.shape[3] // 2)
18+
result.plotter.plot_slice_3d(time_index=3, channel_id="s_in")
19+
result.plotter.plot_concentrations()
20+
simulation.cleanup()

poetry.lock

Lines changed: 390 additions & 114 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "pyvcell"
33
version = "0.1.4"
44
description = "This is the python wrapper for vcell modeling and simulation"
5-
authors = ["Jim Schaff <fschaff@uchc.edu>"]
5+
authors = ["Jim Schaff <schaff@uchc.edu>"]
66
repository = "https://github.com/virtualcell/pyvcell"
77
documentation = "https://virtualcell.github.io/pyvcell/"
88
readme = "README.md"
@@ -11,7 +11,7 @@ packages = [
1111
]
1212

1313
[tool.poetry.dependencies]
14-
python = ">=3.10,<4.0"
14+
python = ">=3.11,<4.0"
1515
numexpr = "^2.10.0"
1616
zarr = "^2.17.2"
1717
h5py = "^3.11.0"
@@ -31,6 +31,9 @@ pyvista = "^0.44.2"
3131
python-libsbml = "^5.20.4"
3232
matplotlib = "^3.10.0"
3333
lxml = "^5.3.1"
34+
imageio = "^2.37.0"
35+
tensorstore = "^0.1.72"
36+
libvcell = "^0.0.6"
3437

3538
[tool.poetry.group.dev.dependencies]
3639
pytest = "^7.2.0"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import tensorstore as ts # type: ignore[import-untyped]
2+
from tensorstore._tensorstore import TensorStore # type: ignore[import-untyped]
3+
4+
5+
def vcell_n5_datastore(base_url: str, dataset_name: str) -> TensorStore:
6+
spec = {"driver": "n5", "kvstore": {"driver": "http", "base_url": base_url}, "path": dataset_name}
7+
return ts.open(spec, read=True).result()

0 commit comments

Comments
 (0)