Skip to content

Commit

Permalink
add argparser
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Schramm authored and Georg Schramm committed Nov 3, 2024
1 parent 48276fd commit 248782e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions python/petsird_plot_scanner_and_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from pathlib import Path

import argparse


def transform_to_mat44(
transform: petsird.RigidTransformation,
Expand Down Expand Up @@ -90,9 +92,17 @@ def draw_BoxShape(ax, box: petsird.BoxShape) -> None:

if __name__ == "__main__":

if not Path("test.bin").exists():
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--fname", default="test.bin")

args = parser.parse_args()
fname = args.fname

if not Path(args.fname).exists():
raise FileNotFoundError(
"test.bin not found. Create it first using the generator."
f"{args.fname} not found. Create it first using the generator."
)

# Create a new figure
Expand Down Expand Up @@ -137,7 +147,7 @@ def draw_BoxShape(ax, box: petsird.BoxShape) -> None:
float(transformed_boxshape_vertices[0][0]),
float(transformed_boxshape_vertices[0][1]),
float(transformed_boxshape_vertices[0][2]),
f"{i_mod}/{i_el}",
f"{i_el:02}/{i_mod:02}",
fontsize=7,
)

Expand Down Expand Up @@ -182,6 +192,7 @@ def draw_BoxShape(ax, box: petsird.BoxShape) -> None:

ax.set_xlim(-400, 400)
ax.set_ylim(-400, 400)
ax.set_zlim(-25, 50)
ax.set_zlim(-20, 50)
ax.set_title("figure not in scale (z axis is streched)")

plt.show()

0 comments on commit 248782e

Please sign in to comment.