Skip to content

Commit

Permalink
Merge pull request #65 from dave3d/PylintFixes
Browse files Browse the repository at this point in the history
add stuff for pylint
  • Loading branch information
dave3d authored Jul 24, 2024
2 parents aae427d + 5265890 commit cf975cb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions dicom2stl/Dicom2STL.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,35 @@
import tempfile
import time
import zipfile
import vtk
import re
from glob import glob
import vtk
import SimpleITK as sitk

from SimpleITK.utilities.vtk import sitk2vtk

import dicom2stl

from glob import glob

from dicom2stl.utils import dicomutils
from dicom2stl.utils import vtkutils


def roundThousand(x):
"""Round to the nearest thousandth"""
y = int(1000.0 * x + 0.5)
return str(float(y) * 0.001)


def elapsedTime(start_time):
"""Print the elapsed time"""
dt = time.perf_counter() - start_time
print(" %4.3f seconds" % dt)
print(f" {dt:4.3f} seconds")


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."""
modality = None
zipFlag = False
dirFlag = False
Expand Down Expand Up @@ -141,7 +145,8 @@ def extract_int(file_path):


def writeMetadataFile(img, metaName):
FP = open(metaName, "w")
"""Write out the metadata to a text file"""
FP = open(metaName, "wb")
size = img.GetSize()
spacing = img.GetSpacing()
FP.write("xdimension " + str(size[0]) + "\n")
Expand All @@ -157,6 +162,7 @@ def volumeProcessingPipeline(
img, shrinkFlag=True, anisotropicSmoothing=False, thresholds=[],
medianFilter=False
):
"""Apply a series of filters to the volume image"""
#
# shrink the volume to 256 cubed
if shrinkFlag:
Expand Down Expand Up @@ -239,6 +245,7 @@ def meshProcessingPipeline(
rotation=["X", 0.0],
debug=False,
):
"""Apply a series of filters to the mesh"""
if debug:
print("Cleaning mesh")
mesh2 = vtkutils.cleanMesh(mesh, connectivityFilter)
Expand Down Expand Up @@ -280,6 +287,7 @@ def meshProcessingPipeline(


def getTissueThresholds(tissueType):
"""Get the double threshold values for a given tissue type."""
thresholds = []
medianFilter = False

Expand All @@ -300,14 +308,14 @@ def getTissueThresholds(tissueType):


def Dicom2STL(args):
""" The primary dicom2stl function """
# Global variables
#
thresholds = []
shrinkFlag = True
connectivityFilter = False
anisotropicSmoothing = False
medianFilter = False
rotFlag = False

# Handle enable/disable filters

Expand All @@ -326,8 +334,6 @@ def Dicom2STL(args):
medianFilter = val
if y.startswith("large"):
connectivityFilter = val
if y.startswith("rotat"):
rotFlag = val

print("")
if args.temp is None:
Expand Down Expand Up @@ -430,6 +436,7 @@ def Dicom2STL(args):


def main():
""" Main function """
args = dicom2stl.utils.parseargs.parseargs()
Dicom2STL(args)

Expand Down

0 comments on commit cf975cb

Please sign in to comment.