Skip to content

Commit

Permalink
Merge branch 'dev' into 8267-fix-normalize-intensity
Browse files Browse the repository at this point in the history
  • Loading branch information
advcu987 authored Jan 15, 2025
2 parents 3c58135 + 56d1f62 commit cda1209
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions monai/networks/nets/swin_unetr.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ def forward(self, x):
x1 = x[:, 1::2, 0::2, 0::2, :]
x2 = x[:, 0::2, 1::2, 0::2, :]
x3 = x[:, 0::2, 0::2, 1::2, :]
x4 = x[:, 1::2, 0::2, 1::2, :]
x5 = x[:, 0::2, 1::2, 0::2, :]
x6 = x[:, 0::2, 0::2, 1::2, :]
x4 = x[:, 1::2, 1::2, 0::2, :]
x5 = x[:, 1::2, 0::2, 1::2, :]
x6 = x[:, 0::2, 1::2, 1::2, :]
x7 = x[:, 1::2, 1::2, 1::2, :]
x = torch.cat([x0, x1, x2, x3, x4, x5, x6, x7], -1)
x = self.norm(x)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_load_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ def test_nibabel_reader(self, input_param, filenames, expected_shape):
@SkipIfNoModule("kvikio")
@parameterized.expand([TEST_CASE_GPU_1, TEST_CASE_GPU_2, TEST_CASE_GPU_3, TEST_CASE_GPU_4])
def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape):
test_image = np.random.rand(128, 128, 128)
if torch.__version__.endswith("nv24.8"):
# related issue: https://github.com/Project-MONAI/MONAI/issues/8274
# for this version, use randint test case to avoid the issue
test_image = torch.randint(0, 256, (128, 128, 128), dtype=torch.uint8).numpy()
else:
test_image = np.random.rand(128, 128, 128)
with tempfile.TemporaryDirectory() as tempdir:
for i, name in enumerate(filenames):
filenames[i] = os.path.join(tempdir, name)
Expand Down
11 changes: 9 additions & 2 deletions tests/test_zarr_avg_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
from torch.nn.functional import pad

from monai.inferers import ZarrAvgMerger
from monai.utils import optional_import
from monai.utils import get_package_version, optional_import, version_geq
from tests.utils import assert_allclose

np.seterr(divide="ignore", invalid="ignore")
zarr, has_zarr = optional_import("zarr")
if has_zarr:
if version_geq(get_package_version("zarr"), "3.0.0"):
directory_store = zarr.storage.LocalStore("test.zarr")
else:
directory_store = zarr.storage.DirectoryStore("test.zarr")
else:
directory_store = None
numcodecs, has_numcodecs = optional_import("numcodecs")

TENSOR_4x4 = torch.randint(low=0, high=255, size=(2, 3, 4, 4), dtype=torch.float32)
Expand Down Expand Up @@ -154,7 +161,7 @@

# explicit directory store
TEST_CASE_10_DIRECTORY_STORE = [
dict(merged_shape=TENSOR_4x4.shape, store=zarr.storage.DirectoryStore("test.zarr")),
dict(merged_shape=TENSOR_4x4.shape, store=directory_store),
[
(TENSOR_4x4[..., :2, :2], (0, 0)),
(TENSOR_4x4[..., :2, 2:], (0, 2)),
Expand Down

0 comments on commit cda1209

Please sign in to comment.