Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bundle/05_spleen_segmentation_lightning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"outputs": [],
"source": [
"!python -c \"import monai\" || pip install -q \"monai-weekly[ignite,pyyaml]\"\n",
"!pip install -q pytorch-lightning~=2.0.0"
"!pip install -q pytorch-lightning>=2.1"
]
},
{
Expand Down Expand Up @@ -855,7 +855,7 @@
"execution_count": 11,
"id": "c5ba337d-a5b0-47de-9ae2-1554a2cb4f86",
"metadata": {},
"outputs": [
"outputs": [
{
"name": "stdout",
"output_type": "stream",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
],
"source": [
"for lb in labels:\n",
" print(f\"{lb:30} {df_scene[df_scene[lb]>0].scene.nunique()}\")"
" print(f\"{lb:30} {df_scene[df_scene[lb] > 0].scene.nunique()}\")"
]
},
{
Expand Down
100 changes: 3 additions & 97 deletions computer_assisted_intervention/endoscopic_inbody_classification.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions deep_atlas/deep_atlas_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@
"val_interval = 5\n",
"\n",
"for epoch_number in range(max_epochs):\n",
" print(f\"Epoch {epoch_number+1}/{max_epochs}:\")\n",
" print(f\"Epoch {epoch_number + 1}/{max_epochs}:\")\n",
"\n",
" seg_net.train()\n",
" losses = []\n",
Expand Down Expand Up @@ -1797,7 +1797,7 @@
"best_reg_validation_loss = float(\"inf\")\n",
"\n",
"for epoch_number in range(max_epochs):\n",
" print(f\"Epoch {epoch_number+1}/{max_epochs}:\")\n",
" print(f\"Epoch {epoch_number + 1}/{max_epochs}:\")\n",
"\n",
" # ------------------------------------------------\n",
" # reg_net training, with seg_net frozen\n",
Expand Down Expand Up @@ -2320,7 +2320,7 @@
"preview_image(det, normalize_by=\"slice\", threshold=0)\n",
"loss = lncc_loss(example_warped_image, img12[:, [0], :, :, :]).item()\n",
"print(f\"Similarity loss: {loss}\")\n",
"print(f\"number of folds: {(det<=0).sum()}\")\n",
"print(f\"number of folds: {(det <= 0).sum()}\")\n",
"\n",
"del reg_net_example_output, img12, example_warped_image\n",
"torch.cuda.empty_cache()"
Expand Down
452 changes: 452 additions & 0 deletions diagnose_1_6_release.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions modules/interpretability/class_lung_lesion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@
" name += \"lesion\" if label == 1 else \"non-lesion\"\n",
" name += \"\\npred: \"\n",
" name += \"lesion\" if pred_label == 1 else \"non-lesion\"\n",
" name += f\"\\nlesion: {y_pred[0,1]:.3}\"\n",
" name += f\"\\nnon-lesion: {y_pred[0,0]:.3}\"\n",
" name += f\"\\nlesion: {y_pred[0, 1]:.3}\"\n",
" name += f\"\\nnon-lesion: {y_pred[0, 0]:.3}\"\n",
"\n",
" # run CAM\n",
" cam_result = cam(x=image, class_idx=None)\n",
Expand Down
3 changes: 2 additions & 1 deletion modules/load_medical_images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@
"outputs": [],
"source": [
"filename = os.path.join(tempdir, \"MONAI-logo_color.png\")\n",
"monai.apps.download_url(\"https://monai.io/assets/img/MONAI-logo_color.png\", filepath=filename)"
"url = \"https://raw.githubusercontent.com/Project-MONAI/MONAI/dev/docs/images/MONAI-logo-color.png\"\n",
"monai.apps.download_url(url, filepath=filename)"
]
},
{
Expand Down
9 changes: 8 additions & 1 deletion runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" maisi_inference_tut
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" realism_diversity_metrics.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" omniverse_integration.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" hugging_face_pipeline_for_monai.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" msd_crossval_datalist_generator.ipynb) # inference/datalist-only notebook, no training loop

# Execution of the notebook in these folders / with the filename cannot be automated
skip_run_papermill=()
Expand Down Expand Up @@ -135,6 +136,12 @@ skip_run_papermill=("${skip_run_papermill[@]}" .*learn2reg_oasis_unpaired_brain_
skip_run_papermill=("${skip_run_papermill[@]}" .*finetune_vista3d_for_hugging_face_pipeline.ipynb*)
skip_run_papermill=("${skip_run_papermill[@]}" .*TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb*) # https://github.com/Project-MONAI/tutorials/issues/2029
skip_run_papermill=("${skip_run_papermill[@]}" .*maisi_inference_tutorial.ipynb*)
skip_run_papermill=("${skip_run_papermill[@]}" .*image_restoration.ipynb*) # monai.networks.nets.restormer not yet in dev branch
skip_run_papermill=("${skip_run_papermill[@]}" .*05_spleen_segmentation_lightning*) # requires GPU; hardcoded .to("cuda") with no CPU fallback
skip_run_papermill=("${skip_run_papermill[@]}" .*deep_atlas_tutorial*) # requires GPU; device hardcoded to "cuda:0"
skip_run_papermill=("${skip_run_papermill[@]}" .*class_lung_lesion*) # unknown error: No recognizable error pattern found
skip_run_papermill=("${skip_run_papermill[@]}" .*lazy_resampling_benchmark*) # unknown error: No recognizable error pattern found
skip_run_papermill=("${skip_run_papermill[@]}" .*omniverse_integration*) # unknown error: No recognizable error pattern found

# output formatting
separator=""
Expand Down Expand Up @@ -443,7 +450,7 @@ function replace_text {
}

# Get notebooks (pattern is an empty string unless the user specifies otherwise)
files=($(echo $pattern | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*"))
files=($(echo "$pattern" | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Quoting $pattern fixes one issue but files=($(...)) still splits on whitespace/globs.

The fix correctly quotes $pattern to avoid breaking on spaces within the pattern, but the outer array assignment files=($(echo ... | xargs find ...)) still performs unquoted command substitution, which is subject to word-splitting and pathname expansion on the find output (e.g., filenames with spaces will be split into multiple array elements). Shellcheck flags this (SC2207).

🛠️ Suggested fix using mapfile
-files=($(echo "$pattern" | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*"))
+mapfile -t files < <(echo "$pattern" | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
files=($(echo "$pattern" | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*"))
mapfile -t files < <(echo "$pattern" | xargs find . -type f -name "*.ipynb" -and ! -wholename "*.ipynb_checkpoints*")
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 453-453: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@runner.sh` at line 453, The `files=($(...))` assignment in `runner.sh` still
performs unsafe word-splitting and glob expansion on the `find` output, so
filenames with spaces will break. Update the array population to use a safe read
mechanism such as `mapfile`/`readarray` around the `find` command output,
keeping the existing quoted `$pattern` behavior while ensuring each path is
stored as one array element.

Source: Linters/SAST tools

if [[ $files == "" ]]; then
print_error_msg "No files match pattern"
exit 0
Expand Down