Skip to content

merge master#458

Merged
Nic-Ma merged 49 commits intoNic-Ma:fix-parser-missingfrom
Project-MONAI:dev
Feb 2, 2023
Merged

merge master#458
Nic-Ma merged 49 commits intoNic-Ma:fix-parser-missingfrom
Project-MONAI:dev

Conversation

@Nic-Ma
Copy link
Copy Markdown
Owner

@Nic-Ma Nic-Ma commented Feb 2, 2023

Fixes # .

Description

A few sentences describing the changes proposed in this pull request.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

wyli and others added 30 commits December 19, 2022 21:29
  - update citation.cff
  - update weekly-preview version number
  - closes #5626

Signed-off-by: Wenqi Li <[email protected]>
Fixes #5776 


### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Fixes #5793 .

### Description

This PR provides a workaround for the incompatible sphinx 6.0.0

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wenqi Li <[email protected]>
VarAutoEncoder.__init__() got an unexpected keyword argument
'dimensions' because now it is called spatial_dims.
Signed-off-by: Yiheng Wang <[email protected]>

Fixes #5775 .

### Description

This PR fixes the issue of `_get_latest_bundle_version` on Windows
(`os.path.join` will produce backslash which will create a wrong url)
Thanks @SachidanandAlle for finding this issue.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Yiheng Wang <[email protected]>
<!--pre-commit.ci start-->
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 →
v4.4.0](pre-commit/pre-commit-hooks@v4.3.0...v4.4.0)
- [github.com/asottile/pyupgrade: v2.38.2 →
v3.3.1](asottile/pyupgrade@v2.38.2...v3.3.1)
- [github.com/hadialqattan/pycln: v2.1.1 →
v2.1.2](hadialqattan/pycln@v2.1.1...v2.1.2)
<!--pre-commit.ci end-->

fixes #5805

Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: kbressem <[email protected]>

Fixes #3178

### Description
As discussed in #3178, this PR adds a more general interface to apply
simple convolutions to images. This PR (re-)implements 2D and 3D
versions for mean filtering, edge detection, outline detection, mask
dilatation and image sharpening.

### Detailed description
The main transform is `ImageFilter`. It comes with some preset filters
that can be initialized using a string. Available presets are `["mean",
"laplace", "elliptical", "sobel", "sharpen", "median", "gauss",
"savitzky_golay"]`. For example, a transformation for mean filtering can
be created with:

```python
mean_filter = ImageFilter("mean", 3)
```
`ImageFilter` automatically detects whether the input is 2D or 3D and
creates the appropriate filter on the first call. This filter will then
be used in future calls of the transformation, so switching between 2D
and 3D images is not supported.

The initialization form string is only a convenience function. All
preset filters are also available in
`monai.networks.layers.simplelayers` as `nn.Module` subclasses.
ImageFilter` can also be created directly from an `nn.Module`. For
example, to create a transformation for mean filtering, the following is
also possible:

```python
filter_3d = MeanFilter(spatial_dims=3, size=3)
mean_filter = ImageFilter(filter_3d)
```

In this example, however, the filter size is predefined and is not
automatically derived from the input.
In addition, it is also possible to use custom filters with
`ImageFilter` using a `torch.Tensor` or `numpy.ndarray`. For example:

```python
filter_3d = torch.ones(3,3,3)
mean_filter = ImageFilter(filter_3d)
```

`RandImageFilter` is a randomizable variant of `ImageFilter` that
executes with probability `p` on each call. Both `ImageFilter` and
`RandImageFilter` also have dictionary versions.



### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: kbressem <[email protected]>
Fixes #5653.

### Description

A new utility decorator that enables us to warn users of a changing
default argument.
Current implementation does the following:
- If version < since no warning will be printed.
- If the default argument is explicitly set by the caller no warning
will be printed.
- If since <= version < replaced a warning like this will be printed:
"Default of argument `{name}` has been deprecated since version
`{since}` from `{old_default}` to `{new_default}`. It will be changed in
version `{replaced}`."
- If replaced <= version a warning like this will be printed: "Default
of argument `{name}` was changed in version `{changed}` from
`{old_default}` to `{new_default}`."
- It doesn't validate the `old_default`, so you can even use this in
scenarios where the default is actually `None` but set later in the
function. This also enables us to set `old_default` to any string if the
default is e.g. not printable.
- The only validation that will throw an error is, if the `new_default`
== the actual default and version < replaced. Which means, that somebody
replaced the value already, before the version was incremented. Apart
from that also any value for `new_default` can be set, giving the same
advantages as for the `old_default`.

### 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).
- [x] New tests added to cover the changes.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5782

### Description
- adds 'mode' and 'align_corners' options to the blocks and nets
- fixes a few typos

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] 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: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5624 
Fixes #5816 

### Description

- undo the workaround
(29a34ad)
- smaller test case tests/test_auto3dseg_ensemble.py

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: KumoLiu <[email protected]>

Fixes #5609.

### Description
Update the docstring for `HoVerNet` and `UpSample`.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] 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: KumoLiu <[email protected]>
…5813)

part of #5804.

### Description

This adds a simple attribute access for ConfigParser so

```python
from monai.bundle import ConfigParser
parser = ConfigParser({"a":"b"})
a = parser.get_parsed_content("a")
```
can be rewritten to
```python
from monai.bundle import ConfigParser
parser = ConfigParser({"a":"b"})
a = parser.a
```
This only works for variables/methods that are not included in
ConfigParser so e.g. `parser.config` would still get the whole config.
This PR only supports shallow attribute accesses, since the returned
value will be a `dict` where you need to use `["key"]` to get the
content.

### 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).
- [x] New tests added to cover the changes.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.

Signed-off-by: Felix Schnabel <[email protected]>
running the test cases

### 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).
Fixes #5823.

### Description
This PR types following decorators:
- `deprecated`
- `deprecated_arg`
- `deprecated_arg_default`

Found
[here](https://github.com/Project-MONAI/MONAI/blob/dev/monai/utils/deprecate_utils.py).
It also fixes any typing issues that occurred because of the additional
typing.

Secondly, it fixes untyped decorator usage of the `ignite` library
(because of `optional_import`) for
[Workflow](https://github.com/Project-MONAI/MONAI/blob/34d713f9887a85f140630a75e9261b89f0005c84/monai/engines/workflow.py#L45)
and
[IgniteMetric](https://github.com/Project-MONAI/MONAI/blob/f9d472af05ceb56513771ea2faccebb79edc1a7a/monai/handlers/ignite_metric.py#L36).

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.

Signed-off-by: Felix Schnabel <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: monai-bot <[email protected]>

Signed-off-by: monai-bot <[email protected]>
Fixes #5833


### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Fixes #5835.

### Description
Use `from __future__ import annotations` in all source files using
annotations, so we have consistent usage (and not only in ~5 files).
The new annotations are also more readable e.g.
`Optional[Union[List[str], str]]` vs. `list[str] | str | None`.

Secondly, this issue includes changing `from typing import Callable,
Sequence, ...` to `from collections.abc import Callable, Sequence, ...`
since the ones in the `typing` module are deprecated. They are
interchangeable even for `isinstance` checks (see also [this
stackoverflow
thread](https://stackoverflow.com/questions/62547848/should-isinstance-check-against-typing-or-collections-abc)).

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.

Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: YanxuanLiu <[email protected]>

fixes #5779

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.


review torch 1.12 tests and upgrade to the latest (1.13+)

Signed-off-by: YanxuanLiu <[email protected]>
### Description

This PR exclude `CuCIM`, `CuCIMD`, `RandCuCIM`, and `RandCuCIMD` wrapper
transfrom from `get_transform_backends` as they are not supposed to
support torch or numpy necessarily.

### 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).

Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Mikael Brudfors
[[email protected]](mailto:[email protected])

part of #5740

### Description


Makes the binary and categorical metrics from MetricsReloaded available
in MONAI via a wrapper module (`monai/metrics/wrapper.py`).

This module allows to use the MetricsReloaded metrics as, e.g.:
```py
import torch
from monai.metrics import MetricsReloadedBinary

metric_name = "Cohens Kappa"
metric = MetricsReloadedBinary(metric_name=metric_name)

# first iteration
# shape [batch=1, channel=1, 2, 2]
y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 1.0]]]])
y = torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]])
print(metric(y_pred, y))

# second iteration
# shape [batch=1, channel=1, 2, 2]
y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 0.0]]]])
y = torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]])
print(metric(y_pred, y))

# aggregate
# shape ([batch=2, channel=1])
print(metric.aggregate(reduction="none"))  # tensor([[0.5], [0.2]])

# reset
metric.reset()
```

Tests of all metrics are in `tests/test_metrics_reloaded.py`.

Note that MetricsReloaded is an optional dependency of MONAI; so in
order to use the wrapper, MONAI needs to be installed with:
```sh
pip install '.[metricsreloaded]'
```

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] 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: Mikael Brudfors <[email protected]>
Signed-off-by: monai-bot <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Mikael Brudfors <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
Co-authored-by: monai-bot <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5844

- improves the error message when slicing data with inconsistent
metadata
- fixes an indexing case:
```
x = MetaTensor(np.zeros((10, 3, 4)))
x[slice(1, 0)]  # should return zero length data
```

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] 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: Wenqi Li <[email protected]>
Fixes #5855

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.


Test pre-merge pipeline only!
### Description

We noted it was possible to instantiate classes derived from DenseNet
only if spatial_dims, in_channels, and out_channels parameters were
passed by keywords.
Passing them via positional scheme was not working.
This small bug should be fixed now.

### Example:
Before my fix:
```
import monai
net = monai.networks.nets.DenseNet(3,1,2) # Working
net = monai.networks.nets.DenseNet121(3,1,2) # NOT woking
net = monai.networks.nets.DenseNet121(spatial_dims=3, in_channels=1, out_channels=2) # Woking
```

After my fix:
```
import monai
net = monai.networks.nets.DenseNet121(3,1,2) # Woking
```

Thanks to @robsver for pointing this issue out.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5852

### Description
1. the following partial instantiate doesn't work
```py
config = {"import statements": "$import math", 
          "calc": {"_target_": "math.isclose", "a": 0.001, "b": 0.001}}
print(ConfigParser(config).calc())
```
with an error message:
```
Component to instantiate must represent a valid class or function, but got math.isclose.
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print(ConfigParser(config).calc())
TypeError: isclose() missing required argument 'a' (pos 1)
```

because `math.isclose` is a builtin type but not a function:

```py
import inspect
inspect.isfunction(math.isclose)  # False
inspect.isbuiltin(math.isclose)  # True
```

the `partial` should support `callable` including builtin functions


2. also this PR supports `_target_` of reference object's methods such
as partial init:
```py
"forward": {"_target_": "$@model().forward", "x": "$torch.rand(1, 3, 256, 256)"}
```

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] 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: Wenqi Li <[email protected]>
Add ITK to the list of optional dependencies.

### Types of changes
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Dženan Zukić <[email protected]>
Fixes #1840 .

### Description

I integrated the trainable bilateral filter layer (TBF) in the MONAI
repository as a new PyTorch filter layer. The TBF contains an analytical
gradient derivation toward its filter parameters and its noisy input
image which enables gradient-based optimization within the PyTorch
graph. See [here](https://doi.org/10.1002/mp.15718) for more details on
the gradient derivation. Unit tests were added that check the filter
output as well as the gradient computation.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Fabian Wagner <[email protected]>
Fixes #5862.

### Description

if `untyped_storage()` is present (pytorch 2) use it, else use
`storage()`.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Richard Brown <[email protected]>
Fixes #5865 

### Description

A few sentences describing the changes proposed in this pull request.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Suraj Pai <[email protected]>
Signed-off-by: KumoLiu <[email protected]>

Fixes #5875 .

### Description

Add warning in `RandHistogramShift` when the image's intensity is a
single value.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: KumoLiu <[email protected]>
f-schnabel and others added 19 commits January 19, 2023 22:06
Fixes #5853.

### Description

Add GEGLU activation function for the MLP Block.

### 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).
- [x] New tests added to cover the changes.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Felix Schnabel <[email protected]>
Fixes #5867.

### Description

I integrated the trainable joint bilateral filter layer (TJBF) in the
MONAI repository as a new PyTorch filter layer. The TJBF contains an
analytical gradient derivation toward its filter parameters, its
guidance image, and its noisy input image which enables gradient-based
optimization within the PyTorch graph. See
[here](https://doi.org/10.1038/s41598-022-22530-4) for more details on
the gradient derivation. Unit tests were added that check the filter
output as well as the gradient computations.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Fabian Wagner <[email protected]>
Part of #5884.

### Description

Fully type annotate any functions with at least one type annotation in
module `visualize`.

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.

Signed-off-by: Felix Schnabel <[email protected]>
part of #5882 

### Description
a workaround to not installing MetricsReloaded when packaging.
once `pip install MetricsReloaded` is made available we can undo the
workaround.

workflow tested
https://github.com/Project-MONAI/MONAI/actions/runs/3984778767/jobs/6831377542

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] 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: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5883 

- to run unit/integration tests, the developers should use `runtests.sh`
which implements

https://github.com/Project-MONAI/MONAI/blob/2d0e0214ac80d97e6585edf59ffc6eed96bcfcdb/runtests.sh#L130-L133

- for read-the-docs builds, it automatically runs `cd docs; make html`:
which installs `docs/requirements.txt`

https://github.com/Project-MONAI/MONAI/blob/2d0e0214ac80d97e6585edf59ffc6eed96bcfcdb/docs/Makefile#L22-L23

the `docs/requirements.txt` is only for building the docs, and should
work with a tiny workstation instance

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: Richard Brown <[email protected]>
### Description

Adds `RandIdentity` which can be placed in a sequence of transforms to
stop the caching of any results beyond this point.

### 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).

Signed-off-by: Richard Brown <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

Fixes #5869 

### Description
support an optional `_mode_` in `"default"`/`"partial"`/`"debug"` when
calling `component(**kwargs)`

example config:
```
{"xform": 
    {"_target_": "Compose", 
     "transforms": [], 
     "_mode_": "debug"}}
```

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] 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.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Part of #5884.

### Description

Fully type annotate any functions with at least one type annotation in
module `visualize`

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.

Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: dongy <[email protected]>

Fixed a bug in dints network construction when num_depths is greater
than 4.

A few sentences describing the changes proposed in this pull request.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: dongy <[email protected]>
Co-authored-by: dongy <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
### Description

When using `LoadImage`, file paths get wrapped with `pathlib.Path` and
`.expanduser()` is called. This causes paths with a protocol prefix to
get corrupted (e.g. in my case paths starting with `s3://` are getting
one of the forward slashes removed)

This PR makes the wrapping with `Path` and call to `.expanduser()`
optional (but set to `True` by default, to preserve current behavior)

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Guilherme Pires <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>

### Description
clean up the APIs can help simplify the maintenance/refactoring effort.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
…adImage` (#5900)

Signed-off-by: Wenqi Li <[email protected]>

Fixes #5007

### Description
adds a warning message about changing the default value of
`image_only=False` to `image=True` in 1.3

example warnings:

```py
Python 3.8.13 (default, Mar 28 2022, 06:16:26) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from monai.transforms import LoadImage; LoadImage()
monai.transforms.io.array LoadImage.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since 1.1. It will be changed to `image_only=True` in version 1.3.
<monai.transforms.io.array.LoadImage object at 0x7fe9e807fe20>
>>> from monai.transforms import LoadImageD; LoadImageD('test')
monai.transforms.io.dictionary LoadImaged.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since 1.1. It will be changed to `image_only=True` in version 1.3.
<monai.transforms.io.dictionary.LoadImaged object at 0x7fe9c97062b0>
>>> 

```

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>
Signed-off-by: Jakob Weigand <[email protected]>

Fixes #5886.

### Description

When SSIMLoss is called with a tensor of batchsize > 1, SSIMMetric is
called for each batch item individually. The result of each call to
SSIMMetric is stored in ssim_val. Subsequently, ssim_val is concatenated
to ssim_value, which is a collection of all calls to SSIMMetric. Before
the concatenation both ssim_val and ssim_value are given a new view of
size 1. As ssim_value collects the results of all earlier calls to
SSIMMetric, .view(1) raises an error for the second call (as ssim_value
has a different absolute size). This commit changes the behavior of the
view call, to always use the current size of ssim_value, avoiding this
issue but keeping the behavior to concatenate in a single row vector.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Jakob Weigand <[email protected]>
Signed-off-by: monai-bot <[email protected]>

Signed-off-by: monai-bot <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>
Fixes #5849 .

### Description

This PR adds the missing handlers for `MetricsReloadedBinary` and
`MetricsReloadedCategorical`, it also modifies wrong places of their doc
strings.

### 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).
- [x] New tests added to cover the changes.
- [ ] 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.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Yiheng Wang <[email protected]>
Signed-off-by: monai-bot <[email protected]>

Signed-off-by: monai-bot <[email protected]>
one of the sub-PRs from #5860

also fixes #5509, by reviewing the metetensor copying in loadimage

### Description
This PR mainly to enhance the `apply_transforms`, `resample`,
`push_transform` APIs
to get prepared for lazy resampling.

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Yiheng Wang <[email protected]>

Fixes #5919 .

### Description

This PR is used to unify input output tensor devices for the following
metrics:
1. HausdorffDistanceMetric
2. SurfaceDiceMetric
3. SurfaceDistanceMetric

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Yiheng Wang <[email protected]>
Part of #5884.

### Description

Fully type annotate any functions with at least one type annotation in
module `optimizers`.

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.

Signed-off-by: Felix Schnabel <[email protected]>
@Nic-Ma Nic-Ma merged commit d1e1db6 into Nic-Ma:fix-parser-missing Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.