Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into geometric #8026

Closed
wants to merge 148 commits into from
Closed

Merge dev into geometric #8026

wants to merge 148 commits into from

Conversation

KumoLiu
Copy link
Contributor

@KumoLiu KumoLiu commented Aug 19, 2024

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.

KumoLiu and others added 30 commits February 24, 2024 00:49
Use uint8 instead of int8 in `LabelStats`.

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Fixes issue #7425

### Description

Add a `sample_std` parameter to `RandGaussianNoise` and
`RandGaussianNoised`. When True, the Gaussian's standard deviation is
sampled uniformly from 0 to std (i.e., what is currently done). When
False, the noise's standard deviation is non-random and set to std. The
default for sample_std would be True for backwards compatibility.

Changes were based on RandRicianNoise which already has a `sample_std`
parameter and is similar to RandGaussianNoise in concept and
implementation.

### 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`.
- [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: Timothy Baker <bakertim@umich.edu>
### Description

When training a model using MONAI metrics for experiment tracking, I
tend to log which metrics I am using. Unfortunately, just sending the
metrics objects to Tensorboard will result in a list like
[CustomMetric1, CustomMetric2, <monai.metrics.Metric ...>, etc.]

Adding `__repr__` and `__str__` methods to the base class will solve
this small annoyance. The current implementation will only return the
class name, but if a certain metric would wish to report more data for
its `__repr__` string, this can be easily overridden in any subclass.

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Bumps
[al-cheb/configure-pagefile-action](https://github.com/al-cheb/configure-pagefile-action)
from 1.3 to 1.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/al-cheb/configure-pagefile-action/releases">al-cheb/configure-pagefile-action's
releases</a>.</em></p>
<blockquote>
<h2>v1.4: Update task node version to 20</h2>
<h1>configure-pagefile-action</h1>
<p>This action is intended to configure Pagefile size and location for
Windows images in GitHub Actions.</p>
<h1>Available parameters</h1>
<table>
<thead>
<tr>
<th>Argument</th>
<th>Description</th>
<th>Format</th>
<th>Default value</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>minimum-size</code></td>
<td>Set minimum size of Pagefile</td>
<td><code>2048MB</code>, <code>4GB</code>, <code>8GB</code> and etc</td>
<td><code>8GB</code></td>
</tr>
<tr>
<td><code>maximum-size</code></td>
<td>Set maximum size of Pagefile</td>
<td>The same like <code>minimum-size</code></td>
<td><code>minimum-size</code></td>
</tr>
<tr>
<td><code>disk-root</code></td>
<td>Set disk root where Pagefile will be located</td>
<td><code>C:</code> or <code>D:</code></td>
<td><code>D:</code></td>
</tr>
</tbody>
</table>
<h1>Usage</h1>
<pre><code>name: CI
on: [push]
jobs:
  build:
    runs-on: windows-latest
    steps:
    - name: configure Pagefile
      uses: al-cheb/configure-pagefile-action@v1.4
      with:
        minimum-size: 8
<pre><code>- name: configure Pagefile
  uses: al-cheb/configure-pagefile-action@v1.4
  with:
    minimum-size: 8
    maximum-size: 16
    disk-root: &amp;quot;D:&amp;quot;
</code></pre>
<p></code></pre></p>
<h1>License</h1>
<p>The scripts and documentation in this project are released under the
<a
href="https://github.com/al-cheb/configure-pagefile-action/blob/HEAD/LICENSE">MIT
License</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/al-cheb/configure-pagefile-action/commit/a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708"><code>a3b6ebd</code></a>
Merge pull request <a
href="https://redirect.github.com/al-cheb/configure-pagefile-action/issues/20">#20</a>
from mikehardy/mikehardy-patch-1</li>
<li><a
href="https://github.com/al-cheb/configure-pagefile-action/commit/850626ff7d6f5665848a60cdc3b0ace19fa0b094"><code>850626f</code></a>
build(deps): bump javascript dependencies / forward-port as needed</li>
<li><a
href="https://github.com/al-cheb/configure-pagefile-action/commit/e7aac1b891d29f440ea916231d51d085206f9106"><code>e7aac1b</code></a>
fix: use node 20</li>
<li><a
href="https://github.com/al-cheb/configure-pagefile-action/commit/d940d2434c38e1a228580edc8f9421aafca9800d"><code>d940d24</code></a>
build(deps): use v4 of setup-node action, use node 20</li>
<li><a
href="https://github.com/al-cheb/configure-pagefile-action/commit/dfdc038768fdb21f91ed75a5fa40890fb92f5919"><code>dfdc038</code></a>
build(deps): bump actions/checkout from 3 to 4</li>
<li>See full diff in <a
href="https://github.com/al-cheb/configure-pagefile-action/compare/v1.3...v1.4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=al-cheb/configure-pagefile-action&package-manager=github_actions&previous-version=1.3&new-version=1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fixes # .

### Description

Add arm support

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Fixes #7523


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7547 

### Description
Previously it was 'medical_resnet50_23datasets' for both identifier and
string, which doesn't correspond to the name in the hubconf.py of
Warvito's repo. Now it is the correct version (according to Warvitos
repo) 'medicalnet_resnet50_23datasets'.

The docs state it correctly already. 

### 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`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: Fabian Klopfer <fabian.klopfer@ieee.org>
Fixes #7533

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7550


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
### Description

Addition of the BarlowTwinsLoss class. This cost function is introduced
in the http://proceedings.mlr.press/v139/zbontar21a/zbontar21a.pdf paper
with the aim of disentangling the representations learned on two views
of the same sample, making it a powerful tool for multimodal and
unsupervised learning.
This cost function is similar to the InfoNCE Loss function already
implemented in MONAI
(https://docs.monai.io/en/latest/_modules/monai/losses/contrastive.html#ContrastiveLoss).
However, it differs in several respects: there is no l2-normalisation,
but rather a z-normalisation. In addition, rather than working between
pairs of embeddings, Barlow Twins seeks to decorrelate the components of
the representations.

```math
\mathcal{L}_{BT} := \sum_i (1 - \mathcal{C}_{ii})^2 + \lambda \sum_i \sum_{i\neq j} \mathcal{C}_{ij}^2
```
with $\lambda$ a positive hyperparameters and $\mathcal{C}$ the
cross-correlation matrix

### 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: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Signed-off-by: Lucas Robinet <67736918+Lucas-rbnt@users.noreply.github.com>
Co-authored-by: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…7308)

### Description

Based on the discussion topic
[here](#7161 (comment)),
we implemented the Conjugate-Gradient algorithm for linear operator
inversion, and Stein's Unbiased Risk Estimator (SURE) [1] loss for
ground-truth-date free diffusion process guidance that is proposed in
[2] and illustrated in the algorithm below:

<img width="650" alt="Screenshot 2023-12-10 at 10 19 25 PM"
src="https://github.com/Project-MONAI/MONAI/assets/8581162/97069466-cbaf-44e0-b7a7-ae9deb8fd7f2">

The Conjugate-Gradient (CG) algorithm is used to solve for the inversion
of the linear operator in Line-4 in the algorithm above, where the
linear operator is too large to store explicitly as a matrix (such as
FFT/IFFT of an image) and invert directly. Instead, we can solve for the
linear inversion iteratively as in CG.

The SURE loss is applied for Line-6 above. This is a differentiable loss
function that can be used to train/giude an operator (e.g. neural
network), where the pseudo ground truth is available but the reference
ground truth is not. For example, in the MRI reconstruction, the pseudo
ground truth is the zero-filled reconstruction and the reference ground
truth is the fully sampled reconstruction. The reference ground truth is
not available due to the lack of fully sampled.

**Reference**
[1] Stein, C.M.: Estimation of the mean of a multivariate normal
distribution. Annals of Statistics 1981 [[paper
link](https://projecteuclid.org/journals/annals-of-statistics/volume-9/issue-6/Estimation-of-the-Mean-of-a-Multivariate-Normal-Distribution/10.1214/aos/1176345632.full)]
[2] B. Ozturkler et al. SMRD: SURE-based Robust MRI Reconstruction with
Diffusion Models. MICCAI 2023
[[paper link](https://arxiv.org/pdf/2310.01799.pdf)]

### 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: chaoliu <chaoliu@nvidia.com>
Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Fixes #7451

### Description
Reduces the length of error messages and error messages being propagated
twice. This helps debug better when long `ConfigComponent`s are being
instantiated. Refer to issue #7451 for more details

### 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: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Fixes #2872 

### Description

Implementation of mixup, cutmix and cutout as described in the original
papers.
Current implementation support both, the dictionary-based batches and
tuples of tensors.

### 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.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Signed-off-by: elitap <elias.tappeiner@gmx.at>
Signed-off-by: Felix Schnabel <f.schnabel@tum.de>
Signed-off-by: YanxuanLiu <yanxuanl@nvidia.com>
Signed-off-by: ytl0623 <david89062388@gmail.com>
Signed-off-by: Dženan Zukić <dzenan.zukic@kitware.com>
Signed-off-by: KumoLiu <yunl@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Ishan Dutta <ishandutta0098@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: kaibo <ktang@unc.edu>
Signed-off-by: heyufan1995 <heyufan1995@gmail.com>
Signed-off-by: binliu <binliu@nvidia.com>
Signed-off-by: axel.vlaminck <axel.vlaminck@gmail.com>
Signed-off-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Timothy Baker <bakertim@umich.edu>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Fabian Klopfer <fabian.klopfer@ieee.org>
Signed-off-by: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Signed-off-by: Lucas Robinet <67736918+Lucas-rbnt@users.noreply.github.com>
Signed-off-by: chaoliu <chaoliu@nvidia.com>
Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: monai-bot <64792179+monai-bot@users.noreply.github.com>
Co-authored-by: elitap <elitap@users.noreply.github.com>
Co-authored-by: Felix Schnabel <f.schnabel@tum.de>
Co-authored-by: YanxuanLiu <104543031+YanxuanLiu@users.noreply.github.com>
Co-authored-by: ytl0623 <david89062388@gmail.com>
Co-authored-by: Dženan Zukić <dzenan.zukic@kitware.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Ishan Dutta <ishandutta0098@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kaibo Tang <ktang@unc.edu>
Co-authored-by: Yufan He <59374597+heyufan1995@users.noreply.github.com>
Co-authored-by: binliunls <107988372+binliunls@users.noreply.github.com>
Co-authored-by: Ben Murray <ben.murray@gmail.com>
Co-authored-by: axel.vlaminck <axel.vlaminck@gmail.com>
Co-authored-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com>
Co-authored-by: Ibrahim Hadzic <ibrahimhadzic45@gmail.com>
Co-authored-by: Dr. Behrooz Hashemian <3968947+drbeh@users.noreply.github.com>
Co-authored-by: Timothy J. Baker <62781117+tim-the-baker@users.noreply.github.com>
Co-authored-by: Mathijs de Boer <8137653+MathijsdeBoer@users.noreply.github.com>
Co-authored-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Co-authored-by: Fabian Klopfer <fabian.klopfer@ieee.org>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Co-authored-by: Lucas Robinet <67736918+Lucas-rbnt@users.noreply.github.com>
Co-authored-by: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Co-authored-by: cxlcl <chaoliucxl@gmail.com>
workaround for #7575


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
…s/patchembedding.py (#7564)

### Description

When you choose to put the argument `pos_embed_type='sincos'` in the
`PatchEmbeddingBlock` class, it still return a learnable positional
encoding

To reproduce:
```python
from monai.networks.blocks import PatchEmbeddingBlock
patcher = PatchEmbeddingBlock(
            in_channels=1,
            img_size=(32, 32, 32),
            patch_size=(8, 8, 8),
            hidden_size=96,
            num_heads=8,
            pos_embed_type="sincos",
            dropout_rate=0.5,
        )
print(patcher.position_embeddings.requires_grad) 
>>> True
```

In the literature, we sometimes use either positional encoding in sincos
which are fixed and non-trainable as in the original Attention Is All
You Need [paper](https://arxiv.org/abs/1706.03762) or a learnable
positional embedding as in the ViT
[paper](https://arxiv.org/abs/2010.11929).
If you choose to use a sincos, then it seems that is must be fixed which
is not the case here.
I'm not completely sure of the desired result in MONAI since there's
already a learnable possibility, so if we choose sincos we'd like
gradient-free parameters. However the documentation of
`build_sincos_position_embedding`in the `pos_embed_utils.py`files
stipulate: "The sin-cos position embedding as a learnable parameter"
which seems a bit confusing. Especially as the encoding construction
function seems to aim to set the require gradient to False (see below)

```python
pos_embed = nn.Parameter(pos_emb)
pos_embed.requires_grad = False

return pos_embed
```
But these changes are not maintained by torch's `copy_` function, which
does not copy gradient parameters (see the cpp code
https://github.com/pytorch/pytorch/blob/148a8de6397be6e4b4ca1508b03b82d117bfb03c/torch/csrc/lazy/ts_backend/tensor_aten_ops.cpp#L51).
This `copy_`is used in the `PatchEmbeddingBlock` class to instantiate
the positional embedding.

I propose a small fix to overcome this problem as well as test cases to
ensure that positional embedding behaves correctly.


### 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`.
- [ ] 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: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
…sed (#7584)

Fixes inconsistent alpha parameter/docs for
RandGibbsNoise/RandGibbsNoised

### 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.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: John Zielke <j.l.zielke@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7585  .

### Description

Because the NNI test takes too much time, the previous behavior did not
get caught with the dry-run mode of HPO Gen

### 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: Mingxin Zheng <mingxinz@nvidia.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Workaround for #7575 

### Description
- Due to the impact of #7575, the operation to set the device within
nnUNetV2Runner will become ineffective. This PR is intended to resolve
this issue.
- Add a version check for #7575, will revisit after the update from
pytorch team.

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes # 1.

### Description

Fixed typo.

### Types of changes
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [x] In-line docstrings updated.

Signed-off-by: Vladimir Chernyi <57420464+scalyvladimir@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Fixes #7540  .

### Description

This PR:
1. add logging file and meta file into BundleWorkflow
2. add the sequence form of meta files check for ConfigWorkflow

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] 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: Yiheng Wang <vennw@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7541


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
…ng class is not set to 0 (#7602)

Fixes #7594 

### Description

Only warn users that the ratio of a missing class is set to 0, when it
wasn't already set to 0 by the user, in
`generate_label_classes_crop_centers`, function being used by
`RandCropByLabelClasses` transform.

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

### Notes regarding tests
Some tests were failing, see details:
<details>
======================================================================
ERROR:
test_cuda_0_2_batches_1_dimensions_1_channels_2_classes_2_mixtures
(tests.test_gmm.GMMTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2096, in _run_ninja_build
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned
non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_gmm.py", line 288, in
test_cuda
gmm = GaussianMixtureModel(features_tensor.size(1), mixture_count,
class_count, verbose_build=True)
File "/home/szabolcslorincz/MONAI/monai/networks/layers/gmm.py", line
44, in __init__
    self.compiled_extension = load_module(
File "/home/szabolcslorincz/MONAI/monai/_extensions/loader.py", line 89,
in load_module
    module = load(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1306, in load
    return _jit_compile(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1823, in _write_ninja_file_and_build_library
    _run_ninja_build(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'gmm_1_2_1_Linux_3_10_12_22_12_1'

======================================================================
ERROR:
test_cuda_1_1_batches_1_dimensions_5_channels_2_classes_1_mixtures
(tests.test_gmm.GMMTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2096, in _run_ninja_build
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned
non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_gmm.py", line 288, in
test_cuda
gmm = GaussianMixtureModel(features_tensor.size(1), mixture_count,
class_count, verbose_build=True)
File "/home/szabolcslorincz/MONAI/monai/networks/layers/gmm.py", line
44, in __init__
    self.compiled_extension = load_module(
File "/home/szabolcslorincz/MONAI/monai/_extensions/loader.py", line 89,
in load_module
    module = load(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1306, in load
    return _jit_compile(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1823, in _write_ninja_file_and_build_library
    _run_ninja_build(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'gmm_5_2_1_Linux_3_10_12_22_12_1'

======================================================================
ERROR:
test_cuda_2_1_batches_2_dimensions_2_channels_4_classes_4_mixtures
(tests.test_gmm.GMMTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2096, in _run_ninja_build
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned
non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_gmm.py", line 288, in
test_cuda
gmm = GaussianMixtureModel(features_tensor.size(1), mixture_count,
class_count, verbose_build=True)
File "/home/szabolcslorincz/MONAI/monai/networks/layers/gmm.py", line
44, in __init__
    self.compiled_extension = load_module(
File "/home/szabolcslorincz/MONAI/monai/_extensions/loader.py", line 89,
in load_module
    module = load(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1306, in load
    return _jit_compile(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1823, in _write_ninja_file_and_build_library
    _run_ninja_build(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'gmm_2_4_1_Linux_3_10_12_22_12_1'

======================================================================
ERROR:
test_cuda_3_1_batches_3_dimensions_1_channels_2_classes_1_mixtures
(tests.test_gmm.GMMTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2096, in _run_ninja_build
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned
non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_gmm.py", line 288, in
test_cuda
gmm = GaussianMixtureModel(features_tensor.size(1), mixture_count,
class_count, verbose_build=True)
File "/home/szabolcslorincz/MONAI/monai/networks/layers/gmm.py", line
44, in __init__
    self.compiled_extension = load_module(
File "/home/szabolcslorincz/MONAI/monai/_extensions/loader.py", line 89,
in load_module
    module = load(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1306, in load
    return _jit_compile(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1823, in _write_ninja_file_and_build_library
    _run_ninja_build(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension
'gmm_1_2_1_Linux_3_10_12_22_12_1_v1'

======================================================================
ERROR: test_load (tests.test_gmm.GMMTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2096, in _run_ninja_build
    subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned
non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/szabolcslorincz/MONAI/tests/test_gmm.py", line 311, in
test_load
load_module("gmm", {"CHANNEL_COUNT": 2, "MIXTURE_COUNT": 2,
"MIXTURE_SIZE": 3}, verbose_build=True)
File "/home/szabolcslorincz/MONAI/monai/_extensions/loader.py", line 89,
in load_module
    module = load(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1306, in load
    return _jit_compile(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1710, in _jit_compile
    _write_ninja_file_and_build_library(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 1823, in _write_ninja_file_and_build_library
    _run_ninja_build(
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/utils/cpp_extension.py",
line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'gmm_2_2_3_Linux_3_10_12_22_12_1'

======================================================================
ERROR: test_spacing_35 (tests.test_spacing.TestSpacingCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_spacing.py", line 289, in
test_spacing
    res: MetaTensor = tr(**call_param)  # type: ignore
File "/home/szabolcslorincz/MONAI/monai/transforms/spatial/array.py",
line 525, in __call__
    data_array = self.sp_resample(
File "/home/szabolcslorincz/MONAI/monai/transforms/spatial/array.py",
line 223, in __call__
    return spatial_resample(
File
"/home/szabolcslorincz/MONAI/monai/transforms/spatial/functional.py",
line 178, in spatial_resample
img = affine_xform(img.unsqueeze(0), theta=xform.to(img),
spatial_size=spatial_size).squeeze(0) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/nn/modules/module.py",
line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/nn/modules/module.py",
line 1520, in _call_impl
    return forward_call(*args, **kwargs)
File
"/home/szabolcslorincz/MONAI/monai/networks/layers/spatial_transforms.py",
line 584, in forward
grid = nn.functional.affine_grid(theta=theta[:, :sr],
size=list(dst_size), align_corners=self.align_corners)
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/nn/functional.py",
line 4418, in affine_grid
    return torch.affine_grid_generator(theta, size, align_corners)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate
840.00 MiB. GPU 0 has a total capacity of 8.00 GiB of which 0 bytes is
free. Including non-PyTorch memory, this process has 17179869184.00 GiB
memory in use. Of the allocated memory 6.47 GiB is allocated by PyTorch,
and 156.63 MiB is reserved by PyTorch but unallocated. If reserved but
unallocated memory is large try setting
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.
See documentation for Memory Management
(https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

======================================================================
FAIL: test_seg_res_net_1_cuda
(tests.test_convert_to_onnx.TestConvertToOnnx)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_convert_to_onnx.py", line
108, in test_seg_res_net
    onnx_model = convert_to_onnx(
File "/home/szabolcslorincz/MONAI/monai/networks/utils.py", line 709, in
convert_to_onnx
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol,
atol=atol) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/testing/_comparison.py",
line 1520, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 233543 / 1451520 (16.1%)
Greatest absolute difference: 0.0014852285385131836 at index (0, 19, 12,
13, 22) (up to 0.0001 allowed)
Greatest relative difference: 589.0405883789062 at index (0, 32, 21, 16,
15) (up to 0.001 allowed)

======================================================================
FAIL: test_unet_4_cuda (tests.test_convert_to_onnx.TestConvertToOnnx)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_convert_to_onnx.py", line
57, in test_unet
    onnx_model = convert_to_onnx(
File "/home/szabolcslorincz/MONAI/monai/networks/utils.py", line 709, in
convert_to_onnx
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol,
atol=atol) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/testing/_comparison.py",
line 1520, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 6705 / 49152 (13.6%)
Greatest absolute difference: 0.0015408992767333984 at index (11, 0, 21,
27) (up to 0.0001 allowed)
Greatest relative difference: 51.80112838745117 at index (14, 0, 25, 19)
(up to 0.001 allowed)

======================================================================
FAIL: test_unet_5_cuda (tests.test_convert_to_onnx.TestConvertToOnnx)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_convert_to_onnx.py", line
57, in test_unet
    onnx_model = convert_to_onnx(
File "/home/szabolcslorincz/MONAI/monai/networks/utils.py", line 709, in
convert_to_onnx
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol,
atol=atol) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/testing/_comparison.py",
line 1520, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 6218 / 49152 (12.7%)
Greatest absolute difference: 0.0015670061111450195 at index (2, 0, 23,
14) (up to 0.0001 allowed)
Greatest relative difference: 7.987473964691162 at index (8, 0, 27, 8)
(up to 0.001 allowed)

======================================================================
FAIL: test_unet_6_cuda (tests.test_convert_to_onnx.TestConvertToOnnx)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_convert_to_onnx.py", line
57, in test_unet
    onnx_model = convert_to_onnx(
File "/home/szabolcslorincz/MONAI/monai/networks/utils.py", line 709, in
convert_to_onnx
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol,
atol=atol) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/testing/_comparison.py",
line 1520, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 6743 / 49152 (13.7%)
Greatest absolute difference: 0.0015552043914794922 at index (1, 1, 9,
11) (up to 0.0001 allowed)
Greatest relative difference: 2.0317020416259766 at index (11, 0, 19,
21) (up to 0.001 allowed)

======================================================================
FAIL: test_unet_7_cuda (tests.test_convert_to_onnx.TestConvertToOnnx)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_convert_to_onnx.py", line
57, in test_unet
    onnx_model = convert_to_onnx(
File "/home/szabolcslorincz/MONAI/monai/networks/utils.py", line 709, in
convert_to_onnx
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol,
atol=atol) # type: ignore
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/torch/testing/_comparison.py",
line 1520, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 6823 / 49152 (13.9%)
Greatest absolute difference: 0.0018431544303894043 at index (10, 0, 9,
19) (up to 0.0001 allowed)
Greatest relative difference: 4.297887325286865 at index (13, 0, 12, 13)
(up to 0.001 allowed)

======================================================================
FAIL: test_shape_2 (tests.test_multi_scale.TestMultiScale)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/parameterized/parameterized.py",
line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
File "/home/szabolcslorincz/MONAI/tests/test_multi_scale.py", line 59,
in test_shape
np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val,
rtol=1e-5)
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py",
line 1504, in assert_allclose
    assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
File
"/home/szabolcslorincz/MONAI/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py",
line 797, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-05, atol=0

Mismatched elements: 1 / 1 (100%)
Max absolute difference: 0.
Max relative difference: 0.
 x: array(0.715212, dtype=float32)
 y: array(0.715228)

----------------------------------------------------------------------
Ran 14392 tests in 2252.916s

FAILED (failures=6, errors=6, skipped=450)

---------

Signed-off-by: Szabolcs Botond Lorincz Molnar <szabolcs.lorincz@mvision.ai>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Nic Ma <nma@nvidia.com>
…#7605)

Fixes #7564 .

### Description

As discussed, a small simplification for the creation of sincos
positional encoding where we don't need to use the `torch.no_grad()`
context or copy the tensor with `copy_` from torch which doesn't
preserve the `requires_grad` attribute here.

The changes are simple and are linked to the corresponding comment
#7564, the output is already in float32 so it doesn't seem particularly
necessary to apply the conversion previously done.

### 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: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
…ciated tests (#7587)

### Description

This PR aims to clarify and harmonise the code for the DiceLoss variants
in the `monai/losses/dice.py` file. With the `to_onehot_y` `softmax` and
`sigmoid` arguments, I didn't necessarily understand the ValueError that
occurred when I passed a target of size NH[WD]. I had a bit of trouble
reading the documentation and understanding it. I thought that they had
to be the same shape as they are displayed, unlike the number of
dimensions in the input, so I added that.
Besides, in the documentation is written:
```python
"""
raises:
      ValueError: When number of channels for target is neither 1 nor the same as input.

"""
```
Trying to reproduce this, we give an input with a number of channels $N$
and target a number of channels of $M$, with $M \neq N$ and $M > 1$.
```python
loss = DiceCELoss()
input = torch.rand(1, 4, 3, 3)
target = torch.randn(1, 2, 3, 3)
loss(input, target)
>: AssertionError: ground truth has different shape (torch.Size([1, 2, 3, 3])) from input (torch.Size([1, 4, 3, 3]))
```
This error in the Dice is an `AssertionError` and not a `ValueError` as
expected and the explanation can be confusing and doesn't give a clear
idea of the error here. The classes concerned and harmonised are
`DiceFocalLoss`, `DiceCELoss` and `GeneralizedDiceFocalLoss` with the
addition of tests that behave correctly and handle this harmonisation.

Also, feel free to modify or make suggestions regarding the changes made
in the docstring to make them more understandable (in my opinion, but
other readers and users will probably have a different view).

### 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.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Lucas Robinet <robinet.lucas@iuct-oncopole.fr>
Signed-off-by: Lucas Robinet <luca.robinet@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
KumoLiu and others added 29 commits July 23, 2024 17:58
Fixes #7936

### Description
- Pre-define `self.causal_mask = torch.Tensor()` before register buffer
- Move norm_cross_attn and cross_attn out of if 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).
- [ ] 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…7938)

Fixes #7930 .

### Description

Check the monai version in metadata JSON and warn if the version is
newer than the package being used.


### Demonstration

Warning when the version is hardcoded to 1.2 from monaihosting
```
root@MS-7D31:/workspace/MONAI# python -m monai.bundle download spleen_ct_segmentation
2024-07-23 11:00:31,286 - INFO - --- input summary of monai.bundle.scripts.download ---
2024-07-23 11:00:31,286 - INFO - > name: 'spleen_ct_segmentation'
2024-07-23 11:00:31,286 - INFO - > source: 'monaihosting'
2024-07-23 11:00:31,286 - INFO - > remove_prefix: 'monai_'
2024-07-23 11:00:31,286 - INFO - > progress: True
2024-07-23 11:00:31,286 - INFO - ---


2024-07-23 11:00:31,985 - INFO - Expected md5 is None, skip md5 check for file /root/.cache/torch/hub/bundle/spleen_ct_segmentation_v0.5.8.zip.
2024-07-23 11:00:31,986 - INFO - File exists: /root/.cache/torch/hub/bundle/spleen_ct_segmentation_v0.5.8.zip, skipped downloading.
2024-07-23 11:00:31,986 - INFO - Writing into directory: /root/.cache/torch/hub/bundle.
2024-07-23 11:00:32,176 - WARNING - Your MONAI version is 1.2, but the bundle is built on MONAI version 1.3.2.
```

Auto select version if the download src is from NGC
```
root@MS-7D31:/workspace/MONAI# BUNDLE_DOWNLOAD_SRC=ngc python -m monai.bundle download spleen_ct_segmentation
2024-07-23 11:02:12,277 - INFO - --- input summary of monai.bundle.scripts.download ---
2024-07-23 11:02:12,277 - INFO - > name: 'spleen_ct_segmentation'
2024-07-23 11:02:12,277 - INFO - > source: 'ngc'
2024-07-23 11:02:12,277 - INFO - > remove_prefix: 'monai_'
2024-07-23 11:02:12,277 - INFO - > progress: True
2024-07-23 11:02:12,277 - INFO - ---


monai_spleen_ct_segmentation_v0.3.7.zip: 34.0MB [00:01, 24.1MB/s]                                                                                                                                                       
2024-07-23 11:02:17,953 - INFO - Downloaded: /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip
2024-07-23 11:02:17,954 - INFO - Expected md5 is None, skip md5 check for file /root/.cache/torch/hub/bundle/monai_spleen_ct_segmentation_v0.3.7.zip.
2024-07-23 11:02:17,954 - INFO - Writing into directory: /root/.cache/torch/hub/bundle/spleen_ct_segmentation.
```

### 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] 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: Mingxin Zheng <mingxinz@nvidia.com>
Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Minimize warning information so that important warnings and errors are
more easily accessible

warnings identified with
```bash
python3  -W ignore::DeprecationWarning -m pytest -k dummy
```

Fixing warnings like:
cannot collect test class 'TestTimeAugmentation' because it has a
__init__ constructor

Use `__test__ = False` to suppress attempted collection in those non
test-classes

### Description

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

### Types of changes
- [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: Hans Johnson <hans-johnson@uiowa.edu>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Fixes #7947

### Description
Add type ignore in several redefinitions 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).
- [ ] 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes #7303 #6959.

### Description

This adds the schema file into the code base (but this maybe should be
elsewhere). The changes implement a number of new things:

* Moved definitions into a `$defs` section per the JSON schema standard
* Permits multiple input arguments and return results from networks with
arbitrary names using the `patternProperties` mechanism
* Allows the types of inputs and outputs to be, additional to just
tensors, numbers, booleans, or strings
* Outputs after post processing can be specified with the
`post_processed_outputs` section if they are significantly changed with
the post-process transforms defined in scripts
* Multiple network IO formats can be specified in addition to
`network_data_format`, these must follow the pattern
`<name>_data_format`
* `required_packages_version` added in addition to
`optional_packages_version`

#7253 depends on this schema change.

### 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: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Fixes # .

### Description

Addition of norm_eps to spade_autoencoderkl.py as per
#7946.

### 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: Virginia Fernandez <vf19@lihe044-pc.isd.kcl.ac.uk>
Signed-off-by: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
Co-authored-by: Virginia Fernandez <vf19@lihe044-pc.isd.kcl.ac.uk>
Co-authored-by: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
)

Fixes #6959.

### 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: KumoLiu <yunl@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com>
Fixes #7968

### Description

Fix outdated link in the docs

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7982 

### 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: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7973 .

### 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: Yiheng Wang <vennw@nvidia.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Hi MONAI Team! 
Thank you very much for this super nice framework, really appreciate it!
Just found a small logic mistake in one of the transform classes. To
reproduce:
```python
import torch
from monai.transforms.post.array import AsDiscrete

transform = AsDiscrete(argmax=True)
prediction = torch.rand(2, 3, 3)

transform(prediction, argmax=False)
# will still apply argmax
```

### Description

Proposed fix: `argmax` is explicitly checked for `None` in the `__cal__`
method.

### 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: David Carreto Fidalgo <davidc.fidalgo@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7944.

### Description

In response to Issue #7944,
I added the new functionality scaled_dot_product_attention from PyTorch
to re-enable flash attention, present in the original MONAI Generative
Models repository. This is allowed for torch >= 2.0 and when argument
save_attn = False. Errors are raised otherwise. I ran quick tests and
added some checks on test_selfattention and test_crossattention scripts
to make sure the outputs are the same as not using flash attention.

### 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: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
Co-authored-by: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Fixes #7994  .

### Description
The current implementation does not support tuple input of "GEGLU" since
it only change the out features of the first linear layer when the input
is a string of "GEGLU".

This PR enhances it, and also enable "vista3d" mode to support #7987 
Tests are added to cover the changes.

### 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.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
…7819)

### Description

Model calibration has helped in developing reliable deep learning
models. In this pull request, I have added a new loss function NACL
(https://arxiv.org/abs/2303.06268, https://arxiv.org/abs/2401.14487)
which has shown promising results for both discriminative and
calibration in segmentation.

**Future Plans:** Currently, MONAI has some of the alternative loss
functions (Label Smoothing, and Focal Loss), but it doesn't have the
calibration specific loss functions (https://arxiv.org/abs/2111.15430,
https://arxiv.org/abs/2209.09641). Besides, these methods are better
evaluated with calibration metrics, Expected Calibration Error
(https://lightning.ai/docs/torchmetrics/stable/classification/calibration_error.html).

### 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: Balamurali <balamuralim.1993@gmail.com>
Signed-off-by: bala93 <balamuralim.1993@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #8006

### Description

Ensure location as tuple in wsireader

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7957 

### Description
In this modified version I made the following changes:
1. Added `label_smoothing: float = 0.0` parameter in `__init__` method,
default value is 0.0.
2. When creating the `self.cross_entropy` instance, pass the
`label_smoothing` parameter to `nn.CrossEntropyLoss`.
3. Added `self.label_smoothing = label_smoothing` in the `__init__`
method to save this parameter for access when needed.

For example:
```
from monai.losses import DiceCELoss

# Before
criterion = DiceCELoss()
criterion.cross_entropy.label_smoothing = 0.1

# Now
criterion = DiceCELoss(label_smoothing=0.1)
```

### 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: ytl0623 <david89062388@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
…7996)

Fixes #7991
Fixes #7992

### Description
Add `include_fc` and `use_combined_linear` argument in the `SABlock`.


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Fixes #7559 .

### Description  
Replaced "pkg_resources" references with "packaging" in
MONAI/monai/utils/module.py & setup.py
Changes were made in functions "pytorch_after", "version_leq",
"version_geq".

### Types of changes
- Non-breaking change (fix or new feature that would not break existing
functionality).

---------

Signed-off-by: dedeepyasai <dedeepyasai.sai@gmail.com>
Signed-off-by: saelra <rasaelee@gmail.com>
Signed-off-by: Kelvin R <kelvinrbNsc@gmail.com>
Signed-off-by: ken-ni <kennett.vera@gmail.com>
Signed-off-by: Dureti <98233210+DuretiShemsi@users.noreply.github.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: saelra <rasaelee@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: dedeepyasai <dedeepyasai.sai@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Ratanachat Saelee <146144408+Saelra@users.noreply.github.com>
Co-authored-by: ken-ni <kennett.vera@gmail.com>
Co-authored-by: Dureti <98233210+DuretiShemsi@users.noreply.github.com>
This PR is a part of #7987 

### 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).
- [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 <vennw@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Adding a network CellSamWrapper, a thin wrapper around SAM, which can be
used for 2D segmentation tasks.



### 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: am <am>
Signed-off-by: myron <amyronenko@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: am <am>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7988 .

### Description

Refactor DiffusionModelUNetMaisi to use monai core components. 

### 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: Pengfei Guo <pengfeig@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes #8009

### Description

Remove segment-anything in setup.cfg

### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes #7988 .

### Description

Refactor AutoencoderKlMaisi to use monai core components.


### 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: Pengfei Guo <pengfeig@nvidia.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Pengfei Guo <32000655+guopengf@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #7988 .

### Description

Refactor ControlNetMaisi to use monai core components.

### 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: Pengfei Guo <pengfeig@nvidia.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #8012


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes #8014


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…rt (#8019)

Part of #8017


### 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: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes # .

### Description

Add VISTA3D model architecture to MONAI core

### 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: heyufan1995 <heyufan1995@gmail.com>
Signed-off-by: Yufan He <heyufan1995@gmail.com>
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yiheng Wang <68361391+yiheng-wang-nv@users.noreply.github.com>
Co-authored-by: Yiheng Wang <vennw@nvidia.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Fixes # .

### Description

Calling contiguous after applying the permute option to work with view
operation in apply_filter
(https://github.com/Project-MONAI/MONAI/blob/59a7211070538586369afd4a01eca0a7fe2e742e/monai/networks/layers/simplelayers.py#L293).

### 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: Balamurali <balamuralim.1993@gmail.com>
Signed-off-by: bala93 <balamuralim.1993@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
@KumoLiu KumoLiu closed this Aug 19, 2024
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.