@@ -39,9 +39,8 @@ def read_img(input_path, desired_ornt=None, header=False, channels_axis=None, gl
39
39
input_path = Path (input_path )
40
40
temp_channels_axis = - 1 # if there are channels, they must be in the last axis for the reorientation
41
41
if input_path .is_dir ():
42
- # TODO: add header support
43
- img , metadata , channeled = PdcmIO .read_dcm_dir (input_path , globber , channels_axis = temp_channels_axis ,
44
- series = series )
42
+ img , metadata , channeled = PdcmIO .read_dcm_dir (input_path , header , globber ,
43
+ channels_axis = temp_channels_axis , series = series )
45
44
else :
46
45
img , metadata , channeled = PdcmIO .read_dcm_file (
47
46
input_path , header , allow_default_affine = allow_default_affine , channels_axis = temp_channels_axis )
@@ -73,7 +72,7 @@ def read_dcm_file(filename, header=False, allow_default_affine=False, channels_a
73
72
return img , metadata , samples_per_pixel > 1
74
73
75
74
@staticmethod
76
- def read_dcm_dir (input_dir , globber = '*' , channels_axis = None , series = None ):
75
+ def read_dcm_dir (input_dir , header = False , globber = '*' , channels_axis = None , series = None ):
77
76
"""
78
77
Reads a 3D dicom image: input path can be a file or directory (DICOM series).
79
78
Return the image array, metadata, and whether it has channels
@@ -82,6 +81,10 @@ def read_dcm_dir(input_dir, globber='*', channels_axis=None, series=None):
82
81
slices = PdcmIO .extract_slices (input_dir , globber = globber , series = series )
83
82
img , affine = combine_slices (slices )
84
83
metadata = PdcmIO .aff2meta (affine )
84
+ if header :
85
+ # TODO: add header support, something like
86
+ # metdata.header = [{str(key): ds[key] for key in ds.keys()} for ds in slices]
87
+ raise NotImplementedError ("header=True is currently not supported for a series" )
85
88
samples_per_pixel = slices [0 ].SamplesPerPixel
86
89
img = PdcmIO .move_channels_axis (img , samples_per_pixel = samples_per_pixel , channels_axis = channels_axis ,
87
90
planar_configuration = slices [0 ].get ('PlanarConfiguration' , None ),
0 commit comments