Skip to content

Commit 7bfa428

Browse files
authored
[DLMED] enhance image reader doc-string for multi-files (#2876)
Signed-off-by: Nic Ma <[email protected]>
1 parent 9990179 commit 7bfa428

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

monai/data/image_reader.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def verify_suffix(self, filename: Union[Sequence[str], str]) -> bool:
178178

179179
def read(self, data: Union[Sequence[str], str], **kwargs):
180180
"""
181-
Read image data from specified file or files.
181+
Read image data from specified file or files, it can read a list of `no-channel` images
182+
and stack them together as multi-channels data in `get_data()`.
183+
If passing directory path instead of file path, will treat it as DICOM images series and read.
182184
Note that the returned object is ITK image object or list of ITK image objects.
183185
184186
Args:
@@ -218,7 +220,7 @@ def get_data(self, img):
218220
Extract data array and meta data from loaded image and return them.
219221
This function returns two objects, first is numpy array of image data, second is dict of meta data.
220222
It constructs `affine`, `original_affine`, and `spatial_shape` and stores them in meta dict.
221-
When loading a list of files, they are concatenated together at a new dimension as the first dimension,
223+
When loading a list of files, they are stacked together at a new dimension as the first dimension,
222224
and the meta data of the first image is used to represent the output meta data.
223225
224226
Args:
@@ -350,7 +352,8 @@ def verify_suffix(self, filename: Union[Sequence[str], str]) -> bool:
350352

351353
def read(self, data: Union[Sequence[str], str], **kwargs):
352354
"""
353-
Read image data from specified file or files.
355+
Read image data from specified file or files, it can read a list of `no-channel` images
356+
and stack them together as multi-channels data in `get_data()`.
354357
Note that the returned object is Nibabel image object or list of Nibabel image objects.
355358
356359
Args:
@@ -376,7 +379,7 @@ def get_data(self, img):
376379
Extract data array and meta data from loaded image and return them.
377380
This function returns two objects, first is numpy array of image data, second is dict of meta data.
378381
It constructs `affine`, `original_affine`, and `spatial_shape` and stores them in meta dict.
379-
When loading a list of files, they are concatenated together at a new dimension as the first dimension,
382+
When loading a list of files, they are stacked together at a new dimension as the first dimension,
380383
and the meta data of the first image is used to present the output meta data.
381384
382385
Args:
@@ -497,7 +500,8 @@ def verify_suffix(self, filename: Union[Sequence[str], str]) -> bool:
497500

498501
def read(self, data: Union[Sequence[str], str], **kwargs):
499502
"""
500-
Read image data from specified file or files.
503+
Read image data from specified file or files, it can read a list of `no-channel` data files
504+
and stack them together as multi-channels data in `get_data()`.
501505
Note that the returned object is Numpy array or list of Numpy arrays.
502506
503507
Args:
@@ -529,7 +533,7 @@ def get_data(self, img):
529533
Extract data array and meta data from loaded image and return them.
530534
This function returns two objects, first is numpy array of image data, second is dict of meta data.
531535
It constructs `affine`, `original_affine`, and `spatial_shape` and stores them in meta dict.
532-
When loading a list of files, they are concatenated together at a new dimension as the first dimension,
536+
When loading a list of files, they are stacked together at a new dimension as the first dimension,
533537
and the meta data of the first image is used to represent the output meta data.
534538
535539
Args:
@@ -581,7 +585,8 @@ def verify_suffix(self, filename: Union[Sequence[str], str]) -> bool:
581585

582586
def read(self, data: Union[Sequence[str], str, np.ndarray], **kwargs):
583587
"""
584-
Read image data from specified file or files.
588+
Read image data from specified file or files, it can read a list of `no-channel` images
589+
and stack them together as multi-channels data in `get_data()`.
585590
Note that the returned object is PIL image or list of PIL image.
586591
587592
Args:
@@ -609,7 +614,7 @@ def get_data(self, img):
609614
Extract data array and meta data from loaded image and return them.
610615
This function returns two objects, first is numpy array of image data, second is dict of meta data.
611616
It computes `spatial_shape` and stores it in meta dict.
612-
When loading a list of files, they are concatenated together at a new dimension as the first dimension,
617+
When loading a list of files, they are stacked together at a new dimension as the first dimension,
613618
and the meta data of the first image is used to represent the output meta data.
614619
615620
Args:

monai/transforms/io/array.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ def __call__(self, filename: Union[Sequence[str], str, Path, Sequence[Path]], re
169169
Args:
170170
filename: path file or file-like object or a list of files.
171171
will save the filename to meta_data with key `filename_or_obj`.
172-
if provided a list of files, use the filename of first file.
172+
if provided a list of files, use the filename of first file to save,
173+
and will stack them together as multi-channels data.
174+
if provided directory path instead of file path, will treat it as
175+
DICOM images series and read.
173176
reader: runtime reader to load image file and meta data.
174177
175178
"""

0 commit comments

Comments
 (0)