-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73b00e5
commit 7c0ad91
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 | ||
|
||
|
||
predictions_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) | ||
outputs_path = predictions_dir + 'dsb_scan_histograms' | ||
utils.auto_make_dir(outputs_path) | ||
|
||
train_valid_ids = utils.load_pkl(pathfinder.VALIDATION_SPLIT_PATH) | ||
train_pids, valid_pids, test_pids = train_valid_ids['training'], train_valid_ids['validation'], train_valid_ids['test'] | ||
print 'n train', len(train_pids) | ||
print 'n valid', len(valid_pids) | ||
print 'n test', len(test_pids) | ||
|
||
all_pids = train_pids + valid_pids + test_pids | ||
|
||
data_iterator = data_iterators.DSBDataGenerator(data_path=pathfinder.DATA_PATH, patient_pids=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 | ||
histograms[pid]= data_transforms.get_rescale_params_hist_eq(x) | ||
|
||
|
||
|
||
pickle.dump(histograms, open( "dsb_rescale_params_hist_eq.pkl", "wb" ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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" ) ) | ||
|
||
|
||
|