Skip to content

Commit

Permalink
Fixes for flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
dave3d committed Feb 29, 2024
1 parent 6107d16 commit bbe2da3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 12 additions & 9 deletions dicom2stl/Dicom2STL.py
Expand Up @@ -21,7 +21,6 @@
import os
import sys
import tempfile
import shutil
import time
import zipfile
import vtk
Expand Down Expand Up @@ -89,7 +88,8 @@ 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)

Expand Down Expand Up @@ -154,7 +154,8 @@ def writeMetadataFile(img, metaName):


def volumeProcessingPipeline(
img, shrinkFlag=True, anisotropicSmoothing=False, thresholds=[], medianFilter=False
img, shrinkFlag=True, anisotropicSmoothing=False, thresholds=[],
medianFilter=False
):
#
# shrink the volume to 256 cubed
Expand All @@ -178,8 +179,8 @@ def volumeProcessingPipeline(

gc.collect()

# Apply anisotropic smoothing to the volume image. That's a smoothing filter
# that preserves edges.
# Apply anisotropic smoothing to the volume image. That's a smoothing
# filter that preserves edges.
#
if anisotropicSmoothing:
print("Anisotropic Smoothing")
Expand All @@ -197,13 +198,14 @@ 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()

# Apply a 3x3x1 median filter. I only use 1 in the Z direction so it's not so
# slow.
# Apply a 3x3x1 median filter. I only use 1 in the Z direction so it's
# not so slow.
#
if medianFilter:
print("Median filter")
Expand Down Expand Up @@ -328,7 +330,7 @@ def Dicom2STL(args):
rotFlag = val

print("")
if args.temp == None:
if args.temp is None:
args.temp = tempfile.mkdtemp()
print("Temp dir: ", args.temp)

Expand Down Expand Up @@ -431,5 +433,6 @@ def main():
args = dicom2stl.utils.parseargs.parseargs()
Dicom2STL(args)


if __name__ == "__main__":
main()
4 changes: 1 addition & 3 deletions dicom2stl/__init__.py
@@ -1,7 +1,5 @@
import dicom2stl.utils.parseargs
import dicom2stl.Dicom2STL
def main():
"""Entry point for the application script"""
print("Call your main application code here")
args = parseargs.parseargs()
args = dicom2stl.utils.parseargs.parseargs()
dicom2stl_func.Dicom2STL(args)

0 comments on commit bbe2da3

Please sign in to comment.