[637b40]: / notebooks / split_checks.py

Download this file

72 lines (58 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# %%
import os
# enable lib loading even if not installed as a pip package or in PYTHONPATH
from pathlib import Path
os.chdir(Path(__file__).resolve().parent.parent)
from adpkd_segmentation.data.data_utils import get_labeled, make_dcmdicts # noqa
from adpkd_segmentation.datasets.splits import GenSplit # noqa
# %%
dcm_paths = sorted(get_labeled())
dcm2attribs, patient2dcm = make_dcmdicts(tuple(dcm_paths))
all_patient_IDS = list(patient2dcm.keys())
# %%
seed = 1
splitter = GenSplit(seed=seed)
split = splitter(all_patient_IDS)
# %%
print(split["val"])
# %%
for patient in split["val"]:
sequences = set()
mrs = set()
for dcm in patient2dcm[patient]:
sequences.add(dcm2attribs[dcm]["seq"])
mrs.add(dcm2attribs[dcm]["MR"])
print(sequences)
print(mrs)
# %%
print(split["test"])
# %%
for patient in split["test"]:
sequences = set()
mrs = set()
for dcm in patient2dcm[patient]:
sequences.add(dcm2attribs[dcm]["seq"])
mrs.add(dcm2attribs[dcm]["MR"])
print(sequences)
print(mrs)
# %%
print(split["train"])
# %%
for patient in split["train"]:
sequences = set()
mrs = set()
for dcm in patient2dcm[patient]:
sequences.add(dcm2attribs[dcm]["seq"])
mrs.add(dcm2attribs[dcm]["MR"])
print(sequences)
print(mrs)
# %%
for patient in all_patient_IDS:
sequences = set()
mrs = set()
for dcm in patient2dcm[patient]:
sequences.add(dcm2attribs[dcm]["seq"])
mrs.add(dcm2attribs[dcm]["MR"])
print(sequences)
print(mrs)
# %%