29 from __future__
import print_function
32 import SimpleITK
as sitk
38 print (
"\nUsage: %s [-s series_name] input_directory [output_image]\n" % (sys.argv[0]) )
42 opts, args = getopt.getopt(sys.argv[1:],
"s:", [
"series" ] )
43 except getopt.GetoptError
as err:
48 if o
in (
"-s",
"--series"):
51 assert False,
"unhandled options"
60 input_directory = args[0]
62 output_image = args[1]
68 series_found = reader.GetGDCMSeriesIDs(input_directory)
73 for serie
in series_found:
75 print(
"\nSeries:", serie )
78 dicom_names = reader.GetGDCMSeriesFileNames(input_directory, serie)
80 print(
"\nFiles in series: ", dicom_names )
83 reader.SetFileNames(dicom_names)
84 image = reader.Execute()
85 print(
"\nImage size: ", image.GetSize() )
87 if (output_image !=
"")
and not written:
88 if (target_series ==
"" or target_series == serie):
90 print(
"\nWriting", output_image )