Skip to content

Commit

Permalink
fix monitor-api notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
a-kore committed Nov 21, 2023
1 parent 3c4da81 commit 08b4659
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cyclops/data/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
allow_missing_keys: bool = False,
):
self.transform = Dictd(

Check warning on line 47 in cyclops/data/transforms.py

View check run for this annotation

Codecov / codecov/patch

cyclops/data/transforms.py#L47

Added line #L47 was not covered by tests
transform=Lambda(func=func),
transform=Lambda(func),
keys=keys,
allow_missing_keys=allow_missing_keys,
)
Expand All @@ -70,7 +70,7 @@ def __init__(
allow_missing_keys: bool = False,
):
self.transform = Dictd(

Check warning on line 72 in cyclops/data/transforms.py

View check run for this annotation

Codecov / codecov/patch

cyclops/data/transforms.py#L72

Added line #L72 was not covered by tests
transform=Resize(spatial_size=spatial_size),
transform=Resize(size=spatial_size),
keys=keys,
allow_missing_keys=allow_missing_keys,
)
Expand Down
21 changes: 15 additions & 6 deletions docs/source/tutorials/nihcxr/monitor_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@
"\"\"\"NIHCXR Clinical Drift Experiments Tutorial.\"\"\"\n",
"\n",
"\n",
"import random\n",
"\n",
"import numpy as np\n",
"from monai.transforms import Compose, Lambdad, Resized\n",
"import torch\n",
"from torchvision.transforms import Compose\n",
"from torchxrayvision.models import DenseNet\n",
"\n",
"from cyclops.data.loader import load_nihcxr\n",
"from cyclops.data.slicer import SliceSpec\n",
"from cyclops.data.transforms import Lambdad, Resized\n",
"from cyclops.monitor import ClinicalShiftApplicator, Detector, Reductor, TSTester\n",
"from cyclops.monitor.plotter import plot_drift_experiment, plot_drift_timeseries\n",
"\n",
"\n",
"nih_ds = load_nihcxr(\"/mnt/data/clinical_datasets/NIHCXR\")[\"test\"]"
"nih_ds = load_nihcxr(\"/mnt/data/clinical_datasets/NIHCXR\")[\"test\"]\n",
"\n",
"random.seed(42)\n",
"np.random.seed(42)\n",
"torch.manual_seed(42)"
]
},
{
Expand Down Expand Up @@ -65,18 +73,19 @@
"transforms = Compose(\n",
" [\n",
" Resized(\n",
" keys=(\"image\",),\n",
" spatial_size=(224, 224),\n",
" keys=(\"image\",),\n",
" allow_missing_keys=True,\n",
" ),\n",
" Lambdad(\n",
" keys=(\"image\",),\n",
" func=lambda x: ((2 * (x / 255.0)) - 1.0) * 1024,\n",
" keys=(\"image\",),\n",
" allow_missing_keys=True,\n",
" ),\n",
" Lambdad(\n",
" (\"image\",),\n",
" func=lambda x: np.mean(x, axis=0)[np.newaxis, :] if x.shape[0] != 1 else x,\n",
" func=lambda x: x[0][np.newaxis, :] if x.shape[0] != 1 else x,\n",
" keys=(\"image\",),\n",
" allow_missing_keys=True,\n",
" ),\n",
" ],\n",
")"
Expand Down

0 comments on commit 08b4659

Please sign in to comment.