23 print(
"Usage: " + sys.argv[0] +
24 " [DicomDirectory [outputFileName [seriesName]]]")
25 print(
"If DicomDirectory is not specified, current directory is used\n")
32 PixelType = itk.ctype(
'signed short')
35 ImageType =
itk.Image[PixelType, Dimension]
38 namesGenerator.SetUseSeriesDetails(
True)
39 namesGenerator.AddSeriesRestriction(
"0008|0021")
40 namesGenerator.SetGlobalWarningDisplay(
False)
41 namesGenerator.SetDirectory(dirName)
43 seriesUID = namesGenerator.GetSeriesUIDs()
45 if len(seriesUID) < 1:
46 print(
'No DICOMs in: ' + dirName)
49 print(
'The directory: ' + dirName)
50 print(
'Contains the following DICOM Series: ')
56 seriesIdentifier = uid
58 seriesIdentifier = sys.argv[3]
60 print(
'Reading: ' + seriesIdentifier)
61 fileNames = namesGenerator.GetFileNames(seriesIdentifier)
65 reader.SetImageIO(dicomIO)
66 reader.SetFileNames(fileNames)
67 reader.ForceOrthogonalDirectionOff()
70 outFileName = os.path.join(dirName, seriesIdentifier +
'.nrrd')
72 outFileName = sys.argv[2]
73 writer.SetFileName(outFileName)
74 writer.UseCompressionOn()
75 writer.SetInput(reader.GetOutput())
76 print(
'Writing: ' + outFileName)