cmiranda16PonceHealthSciencesUniversity
/
dsb3_Celso-Schematic-Spatial-Reducing-Inception-3D-Block
Public
forked from EliasVansteenkiste/dsb3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_luna_histograms.py
52 lines (38 loc) · 1.3 KB
/
generate_luna_histograms.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
import cPickle as pickle
import string
import sys
import time
from itertools import izip
import numpy as np
from datetime import datetime, timedelta
import utils
import logger
import buffering
from configuration import config, set_configuration
import pathfinder
import utils_plots
import data_iterators
import data_transforms
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
train_valid_ids = utils.load_pkl(pathfinder.LUNA_VALIDATION_SPLIT_PATH)
train_pids, valid_pids = train_valid_ids['train'], train_valid_ids['valid']
all_pids = train_pids + valid_pids
data_iterator = data_iterators.LunaSimpleDataGenerator(data_path=pathfinder.LUNA_DATA_PATH, patient_ids=all_pids)
histograms = {}
# bins = np.arange(-960,1700,40)
# avg_histogram = np.zeros((bins.shape[0]-1), dtype=np.int64)
# use buffering.buffered_gen_threaded()
for idx, (x, pid) in enumerate(data_iterator.generate()):
print idx, 'pid', pid
# if (idx == 10):
# break
histograms[pid]= data_transforms.get_rescale_params_hist_eq(x)
#plot avg histogram
# width = 0.7 * (bins[1] - bins[0])
# center = (bins[:-1] + bins[1:]) / 2
# plt.bar(center, avg_histogram, align='center', width=width)
# plt.savefig('dsb_histogram_avg.jpg')
# plt.clf()
pickle.dump(histograms, open( "luna_rescale_params_hist_eq.pkl", "wb" ) )