From 5556b285a47e7124cfbf4d2c9ba17d590e7c701f Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Thu, 22 Feb 2024 14:31:50 -0500 Subject: [PATCH 1/2] Packaging for PyPI --- dicom2stl.py | 5 ++++- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dicom2stl.py b/dicom2stl.py index fc50d72..5929da0 100755 --- a/dicom2stl.py +++ b/dicom2stl.py @@ -427,6 +427,9 @@ def dicom2stl(args): print("") -if __name__ == "__main__": +def main(): args = parseargs.parseargs() dicom2stl(args) + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 5a5bb17..6a09e3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "dicom2stl" authors = [ { name="David Chen", email="dchen@mail.nih.gov" }, ] -description = "A script to extract an STL surface mesh from a DICOM volume image." +description = "A script to extract an iso-surface from a DICOM series to produce an STL mesh." readme = "README.md" requires-python = ">=3.8" classifiers = [ From 46fde7745b62ab6684e3d83069c1c2dd1cbcc4f4 Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Thu, 22 Feb 2024 14:59:38 -0500 Subject: [PATCH 2/2] BUG: args not global --- dicom2stl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dicom2stl.py b/dicom2stl.py index 5929da0..6e9f5f4 100755 --- a/dicom2stl.py +++ b/dicom2stl.py @@ -48,7 +48,7 @@ def elapsedTime(start_time): print(" %4.3f seconds" % dt) -def loadVolume(fname, tempDir=None, verbose=False): +def loadVolume(fname, tempDir=None, verbose=0): modality = None zipFlag = False dirFlag = False @@ -85,7 +85,7 @@ def loadVolume(fname, tempDir=None, verbose=False): # if zipFlag: # Case for a zip file of images - if args.verbose: + if verbose: print("zip") if not tempDir: with tempfile.TemporaryDirectory() as defaultTempDir: @@ -120,8 +120,8 @@ def extract_int(file_path): fname = sorted(fname, key=extract_int) - if args.verbose: - if args.verbose > 1: + if verbose: + if verbose > 1: print("Reading images: ", fname) else: print(