Skip to content

Commit 6db5983

Browse files
committed
nifti read
Signed-off-by: Wenqi Li <[email protected]>
1 parent b4f811c commit 6db5983

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

modules/nifti_read_example.ipynb

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,29 @@
4747
"name": "stdout",
4848
"output_type": "stream",
4949
"text": [
50-
"MONAI version: 0.8.1\n",
51-
"Numpy version: 1.21.5\n",
52-
"Pytorch version: 1.10.2\n",
53-
"MONAI flags: HAS_EXT = False, USE_COMPILED = False\n",
54-
"MONAI rev id: 71ff399a3ea07aef667b23653620a290364095b1\n",
50+
"MONAI version: 0.9.1rc2+2.gc0268266.dirty\n",
51+
"Numpy version: 1.23.0\n",
52+
"Pytorch version: 1.12.0+cu102\n",
53+
"MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
54+
"MONAI rev id: c0268266f688c3bacd9c92ef7458f54b6afdf609\n",
55+
"MONAI __file__: /home/wenqil/Documents/MONAI/monai/__init__.py\n",
5556
"\n",
5657
"Optional dependencies:\n",
57-
"Pytorch Ignite version: 0.4.8\n",
58-
"Nibabel version: 3.2.1\n",
59-
"scikit-image version: 0.19.1\n",
60-
"Pillow version: 9.0.0\n",
61-
"Tensorboard version: 2.8.0\n",
62-
"gdown version: 4.2.0\n",
63-
"TorchVision version: 0.11.3\n",
64-
"tqdm version: 4.62.3\n",
58+
"Pytorch Ignite version: 0.4.9\n",
59+
"Nibabel version: 4.0.1\n",
60+
"scikit-image version: 0.19.3\n",
61+
"Pillow version: 9.2.0\n",
62+
"Tensorboard version: 2.9.1\n",
63+
"gdown version: 4.5.1\n",
64+
"TorchVision version: 0.13.0+cu102\n",
65+
"tqdm version: 4.64.0\n",
6566
"lmdb version: 1.3.0\n",
66-
"psutil version: 5.9.0\n",
67-
"pandas version: 1.1.5\n",
68-
"einops version: 0.4.0\n",
69-
"transformers version: 4.16.1\n",
70-
"mlflow version: 1.23.1\n",
67+
"psutil version: 5.9.1\n",
68+
"pandas version: 1.4.3\n",
69+
"einops version: 0.4.1\n",
70+
"transformers version: 4.20.1\n",
71+
"mlflow version: 1.27.0\n",
72+
"pynrrd version: 0.4.3\n",
7173
"\n",
7274
"For details about installing the optional dependencies, please visit:\n",
7375
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
@@ -125,11 +127,19 @@
125127
},
126128
{
127129
"cell_type": "code",
128-
"execution_count": null,
130+
"execution_count": 3,
129131
"metadata": {
130132
"tags": []
131133
},
132-
"outputs": [],
134+
"outputs": [
135+
{
136+
"name": "stdout",
137+
"output_type": "stream",
138+
"text": [
139+
"/tmp/tmpkzde8m5b\n"
140+
]
141+
}
142+
],
133143
"source": [
134144
"directory = os.environ.get(\"MONAI_DATA_DIRECTORY\")\n",
135145
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
@@ -177,7 +187,7 @@
177187
"name": "stdout",
178188
"output_type": "stream",
179189
"text": [
180-
"torch.Size([5, 1, 64, 64, 64]) torch.Size([5, 1, 64, 64, 64])\n"
190+
"(5, 1, 64, 64, 64) (5, 1, 64, 64, 64)\n"
181191
]
182192
}
183193
],
@@ -187,27 +197,23 @@
187197
"\n",
188198
"imtrans = Compose(\n",
189199
" [\n",
190-
" LoadImage(image_only=True),\n",
200+
" LoadImage(image_only=True, ensure_channel_first=True),\n",
191201
" ScaleIntensity(),\n",
192-
" AddChannel(),\n",
193202
" RandSpatialCrop((64, 64, 64), random_size=False),\n",
194-
" EnsureType(),\n",
195203
" ]\n",
196204
")\n",
197205
"\n",
198206
"segtrans = Compose(\n",
199207
" [\n",
200-
" LoadImage(image_only=True),\n",
201-
" AddChannel(),\n",
208+
" LoadImage(image_only=True, ensure_channel_first=True),\n",
202209
" RandSpatialCrop((64, 64, 64), random_size=False),\n",
203-
" EnsureType(),\n",
204210
" ]\n",
205211
")\n",
206212
"\n",
207213
"ds = ArrayDataset(images, imtrans, segs, segtrans)\n",
208214
"\n",
209215
"loader = torch.utils.data.DataLoader(\n",
210-
" ds, batch_size=10, num_workers=2, pin_memory=torch.cuda.is_available()\n",
216+
" ds, batch_size=10, num_workers=0, pin_memory=torch.cuda.is_available()\n",
211217
")\n",
212218
"im, seg = first(loader)\n",
213219
"print(im.shape, seg.shape)"
@@ -283,7 +289,7 @@
283289
],
284290
"metadata": {
285291
"kernelspec": {
286-
"display_name": "Python 3",
292+
"display_name": "Python 3 (ipykernel)",
287293
"language": "python",
288294
"name": "python3"
289295
},
@@ -297,7 +303,7 @@
297303
"name": "python",
298304
"nbconvert_exporter": "python",
299305
"pygments_lexer": "ipython3",
300-
"version": "3.7.10"
306+
"version": "3.8.0"
301307
}
302308
},
303309
"nbformat": 4,

0 commit comments

Comments
 (0)