forked from jeffduda/GetYourBrainPipelined
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoothSimpleITK.py
More file actions
43 lines (32 loc) · 1014 Bytes
/
smoothSimpleITK.py
File metadata and controls
43 lines (32 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import SimpleITK as sitk
import sys
import os
import logging
iDir = os.getenv("INPUT_DIR")
oDir = os.getenv("OUTPUT_DIR")
logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
if len(sys.argv) > 2:
log.info("Starting SimpleITK")
inFile = os.path.join(iDir, sys.argv[1])
sigma = float(sys.argv[2])
outFile = os.path.join(oDir, sys.argv[3])
log.info("Reading inputs")
reader = sitk.ImageFileReader()
reader.SetFileName(inFile)
image = reader.Execute()
#pixelID = image.GetPixelID()
log.info("Setup filter")
gaussian = sitk.SmoothingRecursiveGaussianImageFilter()
gaussian.SetSigma(float(sys.argv[2]))
log.info("Run filter")
image = gaussian.Execute(image)
#caster = sitk.CastImageFilter()
#caster.SetOutputPixelType(pixelID)
#image = caster.Execute(image)
log.info("Save output")
writer = sitk.ImageFileWriter()
writer.SetFileName(outFile)
writer.Execute(image)
log.info("Done SimpleITK")