Skip to content

Commit

Permalink
Black re-format
Browse files Browse the repository at this point in the history
  • Loading branch information
dave3d committed Aug 7, 2024
1 parent daad4fe commit 6ee3452
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
15 changes: 6 additions & 9 deletions dicom2stl/Dicom2STL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"""
#
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -308,7 +305,7 @@ def getTissueThresholds(tissueType):


def Dicom2STL(args):
""" The primary dicom2stl function """
"""The primary dicom2stl function"""
# Global variables
#
thresholds = []
Expand Down Expand Up @@ -436,7 +433,7 @@ def Dicom2STL(args):


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

Expand Down
2 changes: 1 addition & 1 deletion dicom2stl/utils/dicomutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions dicom2stl/utils/parseargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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="*")
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions dicom2stl/utils/regularize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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("")
Expand Down
8 changes: 4 additions & 4 deletions dicom2stl/utils/vtkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def elapsedTime(start_time):
""" time elapsed """
"""time elapsed"""
dt = time.perf_counter() - start_time
print(f" {dt:4.3f} hseconds")

Expand Down Expand Up @@ -466,23 +466,23 @@ def writeVTIVolume(vtkimg, name):


def memquery1():
""" memory query 1 """
"""memory query 1"""
print("Hiya 1")


# @profile


def memquery2():
""" memory query 2 """
"""memory query 2"""
print("Hiya 2")


# @profile


def memquery3():
""" memory query 3 """
"""memory query 3"""
print("Hiya 3")


Expand Down

0 comments on commit 6ee3452

Please sign in to comment.