Skip to content

Commit

Permalink
Auto3DSeg ensemble tests images depend on #GPUs + docstring improveme…
Browse files Browse the repository at this point in the history
…nt (#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 <[email protected]>
  • Loading branch information
mingxin-zheng authored May 2, 2023
1 parent 0a00115 commit 4bfc8e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/source/apps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ FastMRIReader
-----------
.. automodule:: monai.apps.auto3dseg
:members:
:special-members: __call__
:imported-members:

`nnUNet`
Expand Down
20 changes: 14 additions & 6 deletions monai/apps/auto3dseg/ensemble_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,22 @@ def __call__(self, pred_param: dict | None = None) -> list:
in this function, and the second group will be passed to the `InferClass` to override the
parameters of the class functions.
The first group contains:
'files_slices': a value type of `slice`. The files_slices will slice the infer_files and only
make prediction on the infer_files[file_slices].
'mode': ensemble mode. Currently "mean" and "vote" (majority voting) schemes are supported.
'sigmoid': use the sigmoid function (e.g. x>0.5) to convert the prediction probability map to
the label class prediction, otherwise argmax(x) is used.
- ``"infer_files"``: file paths to the images to read in a list.
- ``"files_slices"``: a value type of `slice`. The files_slices will slice the ``"infer_files"`` and
only make prediction on the infer_files[file_slices].
- ``"mode"``: ensemble mode. Currently "mean" and "vote" (majority voting) schemes are supported.
- ``"image_save_func"``: a dictionary used to instantiate the ``SaveImage`` transform. When specified,
the ensemble prediction will save the prediciton files, instead of keeping the files in the memory.
Example: `{"_target_": "SaveImage", "output_dir": "./"}`
- ``"sigmoid"``: use the sigmoid function (e.g. x > 0.5) to convert the prediction probability map
to the label class prediction, otherwise argmax(x) is used.
The parameters in the second group is defined in the ``config`` of each Algo templates. Please check:
https://github.com/Project-MONAI/research-contributions/tree/main/auto3dseg/algorithm_templates
Returns:
A list of tensors.
A list of tensors or file paths, depending on whether ``"image_save_func"`` is set.
"""
param = {} if pred_param is None else deepcopy(pred_param)
files = self.infer_files
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auto3dseg_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
num_images_per_batch = 2

fake_datalist: dict[str, list[dict]] = {
"testing": [{"image": "val_001.fake.nii.gz"}, {"image": "val_002.fake.nii.gz"}],
"testing": [{"image": f"ts_image_{idx:03d}.nii.gz"} for idx in range(num_images_perfold)],
"training": [
{
"fold": f,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration_autorunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
num_images_per_batch = 2

sim_datalist: dict[str, list[dict]] = {
"testing": [{"image": "val_001.fake.nii.gz"}, {"image": "val_002.fake.nii.gz"}],
"testing": [{"image": f"ts_image__{idx:03d}.nii.gz"} for idx in range(num_images_perfold)],
"training": [
{
"fold": f,
Expand Down

0 comments on commit 4bfc8e9

Please sign in to comment.