Skip to content

Commit 4bfc8e9

Browse files
Auto3DSeg ensemble tests images depend on #GPUs + docstring improvement (#6457)
Fixes #6456. ### Description - Make the test images also depend on GPUs - Improve docstring for infer ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com>
1 parent 0a00115 commit 4bfc8e9

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

docs/source/apps.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ FastMRIReader
252252
-----------
253253
.. automodule:: monai.apps.auto3dseg
254254
:members:
255+
:special-members: __call__
255256
:imported-members:
256257

257258
`nnUNet`

monai/apps/auto3dseg/ensemble_builder.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,22 @@ def __call__(self, pred_param: dict | None = None) -> list:
136136
in this function, and the second group will be passed to the `InferClass` to override the
137137
parameters of the class functions.
138138
The first group contains:
139-
'files_slices': a value type of `slice`. The files_slices will slice the infer_files and only
140-
make prediction on the infer_files[file_slices].
141-
'mode': ensemble mode. Currently "mean" and "vote" (majority voting) schemes are supported.
142-
'sigmoid': use the sigmoid function (e.g. x>0.5) to convert the prediction probability map to
143-
the label class prediction, otherwise argmax(x) is used.
139+
140+
- ``"infer_files"``: file paths to the images to read in a list.
141+
- ``"files_slices"``: a value type of `slice`. The files_slices will slice the ``"infer_files"`` and
142+
only make prediction on the infer_files[file_slices].
143+
- ``"mode"``: ensemble mode. Currently "mean" and "vote" (majority voting) schemes are supported.
144+
- ``"image_save_func"``: a dictionary used to instantiate the ``SaveImage`` transform. When specified,
145+
the ensemble prediction will save the prediciton files, instead of keeping the files in the memory.
146+
Example: `{"_target_": "SaveImage", "output_dir": "./"}`
147+
- ``"sigmoid"``: use the sigmoid function (e.g. x > 0.5) to convert the prediction probability map
148+
to the label class prediction, otherwise argmax(x) is used.
149+
150+
The parameters in the second group is defined in the ``config`` of each Algo templates. Please check:
151+
https://github.com/Project-MONAI/research-contributions/tree/main/auto3dseg/algorithm_templates
144152
145153
Returns:
146-
A list of tensors.
154+
A list of tensors or file paths, depending on whether ``"image_save_func"`` is set.
147155
"""
148156
param = {} if pred_param is None else deepcopy(pred_param)
149157
files = self.infer_files

tests/test_auto3dseg_ensemble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
num_images_per_batch = 2
4747

4848
fake_datalist: dict[str, list[dict]] = {
49-
"testing": [{"image": "val_001.fake.nii.gz"}, {"image": "val_002.fake.nii.gz"}],
49+
"testing": [{"image": f"ts_image_{idx:03d}.nii.gz"} for idx in range(num_images_perfold)],
5050
"training": [
5151
{
5252
"fold": f,

tests/test_integration_autorunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
num_images_per_batch = 2
3939

4040
sim_datalist: dict[str, list[dict]] = {
41-
"testing": [{"image": "val_001.fake.nii.gz"}, {"image": "val_002.fake.nii.gz"}],
41+
"testing": [{"image": f"ts_image__{idx:03d}.nii.gz"} for idx in range(num_images_perfold)],
4242
"training": [
4343
{
4444
"fold": f,

0 commit comments

Comments
 (0)