diff --git a/dicom2stl/Dicom2STL.py b/dicom2stl/Dicom2STL.py index e4877f5..2db4898 100755 --- a/dicom2stl/Dicom2STL.py +++ b/dicom2stl/Dicom2STL.py @@ -51,7 +51,7 @@ def elapsedTime(start_time): def loadVolume(fname, tempDir=None, verbose=0): """Load the volume image from a zip file, a directory of Dicom files, - or a single volume image. Return the SimpleITK image and the modality.""" + or a single volume image. Return the SimpleITK image and the modality.""" modality = None zipFlag = False dirFlag = False @@ -92,8 +92,7 @@ def loadVolume(fname, tempDir=None, verbose=0): print("zip") if not tempDir: with tempfile.TemporaryDirectory() as defaultTempDir: - img, modality = dicomutils.loadZipDicom(fname[0], - defaultTempDir) + img, modality = dicomutils.loadZipDicom(fname[0], defaultTempDir) else: img, modality = dicomutils.loadZipDicom(fname[0], tempDir) @@ -159,8 +158,7 @@ def writeMetadataFile(img, metaName): def volumeProcessingPipeline( - img, shrinkFlag=True, anisotropicSmoothing=False, thresholds=[], - medianFilter=False + img, shrinkFlag=True, anisotropicSmoothing=False, thresholds=[], medianFilter=False ): """Apply a series of filters to the volume image""" # @@ -204,8 +202,7 @@ def volumeProcessingPipeline( print("Double Threshold: ", thresholds) t = time.perf_counter() img = sitk.DoubleThreshold( - img, thresholds[0], thresholds[1], thresholds[2], thresholds[3], - 255, 0 + img, thresholds[0], thresholds[1], thresholds[2], thresholds[3], 255, 0 ) elapsedTime(t) gc.collect() @@ -308,7 +305,7 @@ def getTissueThresholds(tissueType): def Dicom2STL(args): - """ The primary dicom2stl function """ + """The primary dicom2stl function""" # Global variables # thresholds = [] @@ -436,7 +433,7 @@ def Dicom2STL(args): def main(): - """ Main function """ + """Main function""" args = dicom2stl.utils.parseargs.parseargs() Dicom2STL(args) diff --git a/dicom2stl/utils/dicomutils.py b/dicom2stl/utils/dicomutils.py index 5c4f586..063c7d1 100755 --- a/dicom2stl/utils/dicomutils.py +++ b/dicom2stl/utils/dicomutils.py @@ -35,7 +35,7 @@ def testDicomFile(file_path): def scanDirForDicom(dicomdir): - """ Scan directory for dicom series.""" + """Scan directory for dicom series.""" matches = [] found_dirs = [] try: diff --git a/dicom2stl/utils/parseargs.py b/dicom2stl/utils/parseargs.py index 797fc14..b4fe247 100644 --- a/dicom2stl/utils/parseargs.py +++ b/dicom2stl/utils/parseargs.py @@ -16,6 +16,7 @@ class disableFilter(argparse.Action): """Disable a filter""" + def __call__(self, parser, args, values, option_string=None): # print("action, baby!", self.dest, values) # print(args, type(args)) @@ -27,7 +28,8 @@ def __call__(self, parser, args, values, option_string=None): class enableAnisotropic(argparse.Action): - """ Enable anisotropic filtering """ + """Enable anisotropic filtering""" + def __init__(self, nargs=0, **kw): super().__init__(nargs=nargs, **kw) @@ -39,7 +41,8 @@ def __call__(self, parser, args, values, option_string=None): class enableLargest(argparse.Action): - """ Enable filtering for large objects """ + """Enable filtering for large objects""" + def __init__(self, nargs=0, **kw): super().__init__(nargs=nargs, **kw) @@ -49,7 +52,7 @@ def __call__(self, parser, args, values, option_string=None): def createParser(): - """ Create the command line argument parser """ + """Create the command line argument parser""" parser = argparse.ArgumentParser() parser.add_argument("filenames", nargs="*") @@ -121,7 +124,6 @@ def createParser(): parser.add_argument("--version", action="version", version=f"{__version__}") - # Options that apply to the volumetric portion of the pipeline vol_group = parser.add_argument_group("Volume options") @@ -236,7 +238,7 @@ def createParser(): def parseargs(): - """ Parse the command line arguments """ + """Parse the command line arguments""" parser = createParser() args = parser.parse_args() return args diff --git a/dicom2stl/utils/regularize.py b/dicom2stl/utils/regularize.py index 4c1f588..d709303 100755 --- a/dicom2stl/utils/regularize.py +++ b/dicom2stl/utils/regularize.py @@ -10,8 +10,8 @@ def regularize(img, maxdim=-1, verbose=False): - """ Regularize a volume. I.e. resample it so that the voxels are cubic and the - orientation matrix is identity. """ + """Regularize a volume. I.e. resample it so that the voxels are cubic and the + orientation matrix is identity.""" dims = img.GetSize() if verbose: @@ -89,7 +89,7 @@ def regularize(img, maxdim=-1, verbose=False): def usage(): - """ Usage info for the command line script """ + """Usage info for the command line script""" print("") print("regularize.py [options] input_volume output_volume") print("") diff --git a/dicom2stl/utils/vtkutils.py b/dicom2stl/utils/vtkutils.py index 50f6f53..caa62f2 100755 --- a/dicom2stl/utils/vtkutils.py +++ b/dicom2stl/utils/vtkutils.py @@ -21,7 +21,7 @@ def elapsedTime(start_time): - """ time elapsed """ + """time elapsed""" dt = time.perf_counter() - start_time print(f" {dt:4.3f} hseconds") @@ -466,7 +466,7 @@ def writeVTIVolume(vtkimg, name): def memquery1(): - """ memory query 1 """ + """memory query 1""" print("Hiya 1") @@ -474,7 +474,7 @@ def memquery1(): def memquery2(): - """ memory query 2 """ + """memory query 2""" print("Hiya 2") @@ -482,7 +482,7 @@ def memquery2(): def memquery3(): - """ memory query 3 """ + """memory query 3""" print("Hiya 3")