-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2ch12_explore_data.py
83 lines (64 loc) · 1.91 KB
/
p2ch12_explore_data.py
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
72
73
74
75
76
77
78
79
80
81
82
83
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.16.3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %matplotlib inline
import copy
import numpy as np
import matplotlib.pyplot as plt
# +
import torch
from p2ch12.dsets import getCandidateInfoList, getCt, LunaDataset
from util.util import xyz2irc
candidateInfo_list = getCandidateInfoList(requireOnDisk_bool=False)
candidateInfo_list[0]
# -
from p2ch12.vis import findPositiveSamples, showCandidate
positiveSample_list = findPositiveSamples()
# +
augmentation_dict = {}
augmentation_list = [
('None', {}),
('flip', {'flip': True}),
('offset', {'offset': 0.1}),
('scale', {'scale': 0.2}),
('rotate', {'rotate': True}),
('noise', {'noise': 25.0}),
]
ds_list = [
LunaDataset(sortby_str='label_and_size', augmentation_dict=augmentation_dict)
for title_str, augmentation_dict in augmentation_list
]
all_dict = {}
for title_str, augmentation_dict in augmentation_list:
all_dict.update(augmentation_dict)
all_ds = LunaDataset(sortby_str='label_and_size', augmentation_dict=all_dict)
augmentation_list.extend([('All', augmentation_dict)] * 3)
ds_list.extend([all_ds] * 3)
# +
sample_ndx = 100
sample_ndx = 154
sample_ndx = 155
sample_tup = all_ds[sample_ndx]
print(sample_tup[0].shape, sample_tup[1:])
fig = plt.figure(figsize=(30, 30))
clim=(-1000.0, 300)
for i, ((title_str, _), ds) in enumerate(zip(augmentation_list, ds_list)):
sample_tup = ds[sample_ndx]
subplot = fig.add_subplot(3, 3, i+1)
subplot.set_title(title_str, fontsize=30)
for label in (subplot.get_xticklabels() + subplot.get_yticklabels()):
label.set_fontsize(20)
plt.imshow(sample_tup[0][0][16], clim=clim, cmap='gray')
# -
series_uid = positiveSample_list[1][2]
showCandidate(series_uid)