Skip to content

Commit

Permalink
Merge pull request #5 from jdickerson95/pydantic_input
Browse files Browse the repository at this point in the history
feat: Add pydantic model for input
  • Loading branch information
jdickerson95 authored Dec 13, 2024
2 parents d404629 + a9cc4ff commit 6321541
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies = [
"starfile",
"scipy",
"mrcfile",
"pydantic",
"mmdf",
"requests",
"torch-fourier-filter"
Expand Down
24 changes: 24 additions & 0 deletions src/ttsim3d/input_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Pydantic models for input parameters."""

from pydantic import BaseModel


class SimulationParams(BaseModel):
"""Parameters for the simulation."""

pdb_filename: str
output_filename: str
sim_volume_shape: tuple[int, int, int] = (400, 400, 400)
sim_pixel_spacing: float = 0.95
num_frames: int = 50
fluence_per_frame: float = 1
beam_energy_kev: int = 300
dose_weighting: bool = True
dose_B: float = -1
apply_dqe: bool = True
mtf_filename: str
b_scaling: float = 0.5
added_B: float = 0.0
upsampling: int = -1
gpu_id: int = -999
modify_signal: int = 1
9 changes: 6 additions & 3 deletions src/ttsim3d/run_ttsim3d.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Simple run script."""

from ttsim3d.input_models import SimulationParams
from ttsim3d.simulate3d import simulate3d


def main() -> None:
"""A test function to run the simulate3d function from the ttsim3d package."""
simulate3d(
params = SimulationParams(
pdb_filename="/Users/josh/git/2dtm_tests/simulator/parsed_6Q8Y_whole_LSU_match3.pdb",
output_filename="/Users/josh/git/2dtm_tests/simulator/simulated_6Q8Y_whole_LSU_match3.mrc",
mtf_filename="/Users/josh/git/2dtm_tests/simulator/mtf_k2_300kV.star",
sim_volume_shape=(400, 400, 400),
sim_pixel_spacing=0.95,
num_frames=50,
Expand All @@ -16,14 +18,15 @@ def main() -> None:
dose_weighting=True,
dose_B=-1,
apply_dqe=True,
mtf_filename="/Users/josh/git/2dtm_tests/simulator/mtf_k2_300kV.star",
b_scaling=0.5,
added_B=0.0,
upsampling=-1,
gpu_id=-999,
modify_signal=1, # This is how to apply the dose weighting.
modify_signal=1,
)

simulate3d(**params.model_dump())


if __name__ == "__main__":
main()

0 comments on commit 6321541

Please sign in to comment.