You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ENH: Add series_uid arg to imread() for dicom series selection
If filename is a directory of DICOM files, and series_uid is a string, it will read the DICOM series that matches this series_uid name. If series_uid is an integer, it will read the series_uid'th DICOM series in the directory (using python notation, e.g., -1 is the last DICOM series in the directory). If unspecified, it will read the first series in the directory.
This does represent a change in the default behavior in that it used to
raise an exception if a DICOM directory with more than one series was
passed to imread, and now it will read the first series in that
directory.
Copy file name to clipboardExpand all lines: Wrapping/Generators/Python/itk/support/extras.py
+28-11Lines changed: 28 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1182,6 +1182,7 @@ def imread(
1182
1182
pixel_type: Optional["itkt.PixelTypes"] =None,
1183
1183
fallback_only: bool=False,
1184
1184
imageio: Optional["itkt.ImageIOBase"] =None,
1185
+
series_uid: Optional[Union[int, str]] =None,
1185
1186
) ->"itkt.ImageBase":
1186
1187
"""Read an image from a file or series of files and return an itk.Image.
1187
1188
@@ -1202,6 +1203,9 @@ def imread(
1202
1203
imageio :
1203
1204
Use the provided itk.ImageIOBase derived instance to read the file.
1204
1205
1206
+
series_uid :
1207
+
If filename is a directory of DICOM files, and series_uid is a string, it will read the DICOM series that matches this series_uid name. If series_uid is an integer, it will read the series_uid'th DICOM series in the directory (using python notation, e.g., -1 is the last DICOM series in the directory). If unspecified, it will read the first series in the directory.
1208
+
1205
1209
Returns
1206
1210
-------
1207
1211
@@ -1212,10 +1216,11 @@ def imread(
1212
1216
`pixel_type` is not provided (default). The dimension of the image is
1213
1217
automatically deduced from the dimension stored on disk.
1214
1218
1215
-
If the filename provided is a directory then the directory is assumed to
1216
-
be for a DICOM series volume. If there is exactly one DICOM series
1217
-
volume in that directory, the reader will use an itk.ImageSeriesReader
1218
-
object to read the the DICOM filenames within that directory.
1219
+
If the filename provided is a directory then the directory is assumed
1220
+
to be for a DICOM series volume. If the argument series_uid is
1221
+
specified, it will read that series from that directory. If the
1222
+
specified series_uid doesn't exist, an error is thrown. If no
1223
+
series_uid is given, the first series in that directory is read.
1219
1224
1220
1225
If the given filename is a list or a tuple of file names, the reader
1221
1226
will use an itk.ImageSeriesReader object to read the files.
@@ -1247,14 +1252,26 @@ def imread(
1247
1252
names_generator.SetUseSeriesDetails(True)
1248
1253
names_generator.AddSeriesRestriction("0008|0021") # Series Date
0 commit comments