Skip to content

Commit a283c56

Browse files
authored
Merge branch 'dev' into dev
2 parents 426ed83 + af9e8f9 commit a283c56

File tree

883 files changed

+3525
-1606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

883 files changed

+3525
-1606
lines changed

.github/workflows/cron.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
if pgrep python; then pkill python; fi
7676
shell: bash
7777
- name: Upload coverage
78-
uses: codecov/codecov-action@v4
78+
uses: codecov/codecov-action@v5
7979
with:
8080
fail_ci_if_error: false
8181
files: ./coverage.xml
@@ -123,7 +123,7 @@ jobs:
123123
if pgrep python; then pkill python; fi
124124
shell: bash
125125
- name: Upload coverage
126-
uses: codecov/codecov-action@v4
126+
uses: codecov/codecov-action@v5
127127
with:
128128
fail_ci_if_error: false
129129
files: ./coverage.xml
@@ -228,7 +228,7 @@ jobs:
228228
if pgrep python; then pkill python; fi
229229
shell: bash
230230
- name: Upload coverage
231-
uses: codecov/codecov-action@v4
231+
uses: codecov/codecov-action@v5
232232
with:
233233
fail_ci_if_error: false
234234
files: ./coverage.xml

.github/workflows/pythonapp-gpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,6 @@ jobs:
137137
shell: bash
138138
- name: Upload coverage
139139
if: ${{ github.head_ref != 'dev' && github.event.pull_request.merged != true }}
140-
uses: codecov/codecov-action@v4
140+
uses: codecov/codecov-action@v5
141141
with:
142142
files: ./coverage.xml

.github/workflows/setupapp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
if pgrep python; then pkill python; fi
7373
shell: bash
7474
- name: Upload coverage
75-
uses: codecov/codecov-action@v4
75+
uses: codecov/codecov-action@v5
7676
with:
7777
fail_ci_if_error: false
7878
files: ./coverage.xml
@@ -119,7 +119,7 @@ jobs:
119119
BUILD_MONAI=1 ./runtests.sh --build --quick --min
120120
coverage xml --ignore-errors
121121
- name: Upload coverage
122-
uses: codecov/codecov-action@v4
122+
uses: codecov/codecov-action@v5
123123
with:
124124
fail_ci_if_error: false
125125
files: ./coverage.xml

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ tests/testing_data/nrrd_example.nrrd
149149
# clang format tool
150150
.clang-format-bin/
151151

152+
# ctags
153+
tags
154+
152155
# VSCode
153156
.vscode/
154157
*.zip

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ repos:
6666
)$
6767
6868
- repo: https://github.com/hadialqattan/pycln
69-
rev: v2.4.0
69+
rev: v2.5.0
7070
hooks:
7171
- id: pycln
7272
args: [--config=pyproject.toml]

docs/source/networks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ Nets
630630
.. autoclass:: ViTAutoEnc
631631
:members:
632632

633+
`MaskedAutoEncoderViT`
634+
~~~~~~~~~~~~~~~~~~~~~~
635+
.. autoclass:: MaskedAutoEncoderViT
636+
:members:
637+
633638
`FullyConnectedNet`
634639
~~~~~~~~~~~~~~~~~~~
635640
.. autoclass:: FullyConnectedNet

docs/source/transforms.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,18 @@ Utility
11801180
:members:
11811181
:special-members: __call__
11821182

1183+
`TorchIO`
1184+
"""""""""
1185+
.. autoclass:: TorchIO
1186+
:members:
1187+
:special-members: __call__
1188+
1189+
`RandTorchIO`
1190+
"""""""""""""
1191+
.. autoclass:: RandTorchIO
1192+
:members:
1193+
:special-members: __call__
1194+
11831195
`MapLabelValue`
11841196
"""""""""""""""
11851197
.. autoclass:: MapLabelValue
@@ -2253,6 +2265,18 @@ Utility (Dict)
22532265
:members:
22542266
:special-members: __call__
22552267

2268+
`TorchIOd`
2269+
""""""""""
2270+
.. autoclass:: TorchIOd
2271+
:members:
2272+
:special-members: __call__
2273+
2274+
`RandTorchIOd`
2275+
""""""""""""""
2276+
.. autoclass:: RandTorchIOd
2277+
:members:
2278+
:special-members: __call__
2279+
22562280
`MapLabelValued`
22572281
""""""""""""""""
22582282
.. autoclass:: MapLabelValued

environment-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ channels:
77
dependencies:
88
- numpy>=1.24,<2.0
99
- pytorch>=1.9
10+
- torchio
1011
- torchvision
1112
- pytorch-cuda>=11.6
1213
- pip

monai/apps/utils.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import logging
1717
import os
18+
import re
1819
import shutil
1920
import sys
2021
import tarfile
@@ -30,7 +31,9 @@
3031
from monai.config.type_definitions import PathLike
3132
from monai.utils import look_up_option, min_version, optional_import
3233

34+
requests, has_requests = optional_import("requests")
3335
gdown, has_gdown = optional_import("gdown", "4.7.3")
36+
BeautifulSoup, has_bs4 = optional_import("bs4", name="BeautifulSoup")
3437

3538
if TYPE_CHECKING:
3639
from tqdm import tqdm
@@ -298,6 +301,29 @@ def extractall(
298301
)
299302

300303

304+
def get_filename_from_url(data_url: str) -> str:
305+
"""
306+
Get the filename from the URL link.
307+
"""
308+
try:
309+
response = requests.head(data_url, allow_redirects=True)
310+
content_disposition = response.headers.get("Content-Disposition")
311+
if content_disposition:
312+
filename = re.findall('filename="?([^";]+)"?', content_disposition)
313+
if filename:
314+
return str(filename[0])
315+
if "drive.google.com" in data_url:
316+
response = requests.get(data_url)
317+
if "text/html" in response.headers.get("Content-Type", ""):
318+
soup = BeautifulSoup(response.text, "html.parser")
319+
filename_div = soup.find("span", {"class": "uc-name-size"})
320+
if filename_div:
321+
return str(filename_div.find("a").text)
322+
return _basename(data_url)
323+
except Exception as e:
324+
raise Exception(f"Error processing URL: {e}") from e
325+
326+
301327
def download_and_extract(
302328
url: str,
303329
filepath: PathLike = "",
@@ -327,7 +353,18 @@ def download_and_extract(
327353
be False.
328354
progress: whether to display progress bar.
329355
"""
356+
url_filename_ext = "".join(Path(get_filename_from_url(url)).suffixes)
357+
filepath_ext = "".join(Path(_basename(filepath)).suffixes)
358+
if filepath not in ["", "."]:
359+
if filepath_ext == "":
360+
new_filepath = Path(filepath).with_suffix(url_filename_ext)
361+
logger.warning(
362+
f"filepath={filepath}, which missing file extension. Auto-appending extension to: {new_filepath}"
363+
)
364+
filepath = new_filepath
365+
if filepath_ext and filepath_ext != url_filename_ext:
366+
raise ValueError(f"File extension mismatch: expected extension {url_filename_ext}, but get {filepath_ext}")
330367
with tempfile.TemporaryDirectory() as tmp_dir:
331-
filename = filepath or Path(tmp_dir, _basename(url)).resolve()
368+
filename = filepath or Path(tmp_dir, get_filename_from_url(url)).resolve()
332369
download_url(url=url, filepath=filename, hash_val=hash_val, hash_type=hash_type, progress=progress)
333370
extractall(filepath=filename, output_dir=output_dir, file_type=file_type, has_base=has_base)

monai/bundle/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
MACRO_KEY,
4444
load_bundle_config,
4545
)
46-
from .workflows import BundleWorkflow, ConfigWorkflow
46+
from .workflows import BundleWorkflow, ConfigWorkflow, PythonicWorkflow

0 commit comments

Comments
 (0)