Skip to content

Commit ec78d2f

Browse files
authored
471 Update CSV datasets tutorial (#472)
* [DLMED] update csv tutorial Signed-off-by: Nic Ma <nma@nvidia.com> * [DLMED] update tcia Signed-off-by: Nic Ma <nma@nvidia.com>
1 parent 4735dd0 commit ec78d2f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

modules/csv_datasets.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
}
264264
],
265265
"source": [
266-
"dataset = CSVDataset(filename=filepath1)\n",
266+
"dataset = CSVDataset(src=filepath1)\n",
267267
"# construct pandas table to show the data, `CSVDataset` inherits from PyTorch Dataset\n",
268268
"print(pd.DataFrame(dataset.data))"
269269
]
@@ -308,7 +308,7 @@
308308
}
309309
],
310310
"source": [
311-
"dataset = CSVDataset([filepath1, filepath2, filepath3], on=\"subject_id\")\n",
311+
"dataset = CSVDataset(src=[filepath1, filepath2, filepath3], on=\"subject_id\")\n",
312312
"# construct pandas table to show the joined data of 3 tables\n",
313313
"print(pd.DataFrame(dataset.data))"
314314
]
@@ -339,7 +339,7 @@
339339
],
340340
"source": [
341341
"dataset = CSVDataset(\n",
342-
" filename=[filepath1, filepath2, filepath3],\n",
342+
" src=[filepath1, filepath2, filepath3],\n",
343343
" row_indices=[[0, 2], 3], # load row: 0, 1, 3\n",
344344
" col_names=[\"subject_id\", \"label\", \"ehr_1\", \"ehr_7\", \"meta_1\"],\n",
345345
")\n",
@@ -396,7 +396,7 @@
396396
],
397397
"source": [
398398
"dataset = CSVDataset(\n",
399-
" filename=[filepath1, filepath2, filepath3],\n",
399+
" src=[filepath1, filepath2, filepath3],\n",
400400
" col_names=[\"subject_id\", \"image\", *[f\"ehr_{i}\" for i in range(11)], \"meta_0\", \"meta_1\", \"meta_2\"],\n",
401401
" col_groups={\"ehr\": [f\"ehr_{i}\" for i in range(11)], \"meta\": [\"meta_0\", \"meta_1\", \"meta_2\"]},\n",
402402
")\n",
@@ -433,7 +433,7 @@
433433
],
434434
"source": [
435435
"dataset = CSVDataset(\n",
436-
" filename=[filepath1, filepath2, filepath3],\n",
436+
" src=[filepath1, filepath2, filepath3],\n",
437437
" col_names=[\"subject_id\", \"label\", \"ehr_0\", \"ehr_1\", \"ehr_9\", \"meta_1\"],\n",
438438
" col_types={\"label\": {\"default\": \"No label\"}, \"ehr_1\": {\"type\": int, \"default\": 0}},\n",
439439
" how=\"outer\", # will load the NaN values in this merge mode\n",
@@ -481,7 +481,7 @@
481481
],
482482
"source": [
483483
"dataset = CSVDataset(\n",
484-
" filename=[filepath1, filepath2, filepath3],\n",
484+
" src=[filepath1, filepath2, filepath3],\n",
485485
" col_groups={\"ehr\": [f\"ehr_{i}\" for i in range(5)]},\n",
486486
" transform=Compose([LoadImaged(keys=\"image\"), ToNumpyd(keys=\"ehr\")]),\n",
487487
")\n",
@@ -527,7 +527,7 @@
527527
}
528528
],
529529
"source": [
530-
"dataset = CSVIterableDataset(filename=[filepath1, filepath2, filepath3], shuffle=False)\n",
530+
"dataset = CSVIterableDataset(src=[filepath1, filepath2, filepath3], shuffle=False)\n",
531531
"# set num workers = 0 for mac / win\n",
532532
"num_workers = 2 if sys.platform == \"linux\" else 0\n",
533533
"dataloader = DataLoader(dataset=dataset, num_workers=num_workers, batch_size=2)\n",
@@ -546,7 +546,7 @@
546546
},
547547
{
548548
"cell_type": "code",
549-
"execution_count": 15,
549+
"execution_count": 13,
550550
"metadata": {},
551551
"outputs": [
552552
{
@@ -563,7 +563,7 @@
563563
"dataset = CSVIterableDataset(\n",
564564
" chunksize=2,\n",
565565
" buffer_size=4,\n",
566-
" filename=[filepath1, filepath2, filepath3],\n",
566+
" src=[filepath1, filepath2, filepath3],\n",
567567
" col_names=[\"subject_id\", \"label\", \"ehr_1\", \"ehr_7\", \"meta_1\"],\n",
568568
" transform=ToNumpyd(keys=\"ehr_1\"),\n",
569569
" shuffle=True,\n",

modules/tcia_csv_processing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
" download_url(url=u, filepath=f)\n",
176176
"\n",
177177
" super().__init__(\n",
178-
" filename=filename,\n",
178+
" src=filename,\n",
179179
" row_indices=row_indices,\n",
180180
" col_names=col_names,\n",
181181
" col_types=col_types,\n",

0 commit comments

Comments
 (0)