本文整理汇总了Python中protoclass.data_management.GTModality.extract_gt_data方法的典型用法代码示例。如果您正苦于以下问题:Python GTModality.extract_gt_data方法的具体用法?Python GTModality.extract_gt_data怎么用?Python GTModality.extract_gt_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protoclass.data_management.GTModality
的用法示例。
在下文中一共展示了GTModality.extract_gt_data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_graph
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_build_graph():
"""Test the method to build a graph from the heatmap."""
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 'dce')
# Create an object to handle the data
dce_mod = DCEModality()
# Read the data
dce_mod.read_data_from_path(path_data)
# Load the GT data
path_gt = [os.path.join(currdir, 'data', 'gt_folders', 'prostate')]
label_gt = ['prostate']
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)
# Build a heatmap from the dce data
# Reduce the number of bins to enforce low memory consumption
nb_bins = [100] * dce_mod.n_serie_
heatmap, bins_heatmap = dce_mod.build_heatmap(gt_mod.extract_gt_data(
label_gt[0]), nb_bins=nb_bins)
# Build the graph by taking the inverse exponential of the heatmap
graph = StandardTimeNormalization._build_graph(heatmap, .5)
graph_dense = graph.toarray()
data = np.load(os.path.join(currdir, 'data', 'graph.npy'))
assert_array_equal(graph_dense, data)
示例2: test_shift_heatmap
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_shift_heatmap():
"""Test the routine which shift the heatmap."""
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 'dce')
# Create an object to handle the data
dce_mod = DCEModality()
# Read the data
dce_mod.read_data_from_path(path_data)
# Load the GT data
path_gt = [os.path.join(currdir, 'data', 'gt_folders', 'prostate')]
label_gt = ['prostate']
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)
# Build a heatmap from the dce data
# Reduce the number of bins to enforce low memory consumption
nb_bins = [100] * dce_mod.n_serie_
heatmap, bins_heatmap = dce_mod.build_heatmap(gt_mod.extract_gt_data(
label_gt[0]), nb_bins=nb_bins)
# Create a list of shift which do not have the same number of entries
# than the heatmap - There is 4 series, let's create only 2
shift_arr = np.array([10] * 4)
heatmap_shifted = StandardTimeNormalization._shift_heatmap(heatmap,
shift_arr)
data = np.load(os.path.join(currdir, 'data', 'heatmap_shifted.npy'))
assert_array_equal(heatmap_shifted, data)
示例3: test_shift_heatmap_wrong_shift
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_shift_heatmap_wrong_shift():
"""Test if an error is raised when the shidt provided is not consistent."""
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 'dce')
# Create an object to handle the data
dce_mod = DCEModality()
# Read the data
dce_mod.read_data_from_path(path_data)
# Load the GT data
path_gt = [os.path.join(currdir, 'data', 'gt_folders', 'prostate')]
label_gt = ['prostate']
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)
# Build a heatmap from the dce data
# Reduce the number of bins to enforce low memory consumption
nb_bins = [100] * dce_mod.n_serie_
heatmap, bins_heatmap = dce_mod.build_heatmap(gt_mod.extract_gt_data(
label_gt[0]), nb_bins=nb_bins)
# Create a list of shift which do not have the same number of entries
# than the heatmap - There is 4 series, let's create only 2
shift_arr = np.array([10] * 2)
assert_raises(ValueError, StandardTimeNormalization._shift_heatmap,
heatmap, shift_arr)
示例4: test_extract_index
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_extract_index():
""" Test if the indexes of a GT will be well extracted. """
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 'gt_folders')
path_data_list = [os.path.join(path_data, 'prostate'),
os.path.join(path_data, 'cg'),
os.path.join(path_data, 'pz'),
os.path.join(path_data, 'cap')]
# Give the list for the ground_truth
label = ['prostate', 'cg', 'pz', 'cap']
# Create an object to handle the data
gt_mod = GTModality()
# Read the data
gt_mod.read_data_from_path(label, path_data=path_data_list)
# Extract the prostate indexes
label_extr = 'prostate'
idx_prostate = gt_mod.extract_gt_data(label_extr, 'index')
data = np.load(os.path.join(currdir, 'data', 'extract_gt_index.npy'))
# Check each table
for idx_arr, test_arr in zip(idx_prostate, data):
assert_array_equal(idx_arr, test_arr)
示例5: test_get_pdf_roi
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_get_pdf_roi():
"""Test the routine to get pdf and bins with a given roi."""
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 't2w')
# Create an object to handle the data
t2w_mod = T2WModality()
t2w_mod.read_data_from_path(path_data)
path_data = os.path.join(currdir, 'data', 'gt_folders')
path_data_list = [os.path.join(path_data, 'prostate'),
os.path.join(path_data, 'cg'),
os.path.join(path_data, 'pz'),
os.path.join(path_data, 'cap')]
# Give the list for the ground_truth
label = ['prostate', 'cg', 'pz', 'cap']
# Create an object to handle the data
gt_mod = GTModality()
# Read the data
gt_mod.read_data_from_path(label, path_data=path_data_list)
# Extract the prostate indexes
label_extr = 'prostate'
data_prostate = gt_mod.extract_gt_data(label_extr, 'index')
# Compute the hisogram with a wrong argument as string
pdf_data, bin_data = t2w_mod.get_pdf(roi_data=data_prostate)
# Check that the data correspond to the one save inside the the test
data = np.load(os.path.join(currdir, 'data',
'bin_t2w_get_pdf_roi.npy'))
assert_array_equal(bin_data, data)
data = np.load(os.path.join(currdir, 'data',
'pdf_t2w_get_pdf_roi.npy'))
assert_array_equal(pdf_data, data)
示例6: test_walk_through_graph_shortest_path
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
def test_walk_through_graph_shortest_path():
"""Test the routine to go through the graph using shortest path."""
# Load the data with only a single serie
currdir = os.path.dirname(os.path.abspath(__file__))
path_data = os.path.join(currdir, 'data', 'dce')
# Create an object to handle the data
dce_mod = DCEModality()
# Read the data
dce_mod.read_data_from_path(path_data)
# Load the GT data
path_gt = [os.path.join(currdir, 'data', 'gt_folders', 'prostate')]
label_gt = ['prostate']
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)
# Build a heatmap from the dce data
# Reduce the number of bins to enforce low memory consumption
nb_bins = [10] * dce_mod.n_serie_
heatmap, bins_heatmap = dce_mod.build_heatmap(gt_mod.extract_gt_data(
label_gt[0]), nb_bins=nb_bins)
# Build the graph by taking the inverse exponential of the heatmap
heatmap_inv_exp = np.exp(img_as_float(1. - (heatmap / np.max(heatmap))))
graph = StandardTimeNormalization._build_graph(heatmap_inv_exp, .99)
start_end_tuple = ((0, 6), (3, 6))
# Call the algorithm to walk through the graph
path = StandardTimeNormalization._walk_through_graph(graph,
heatmap_inv_exp,
start_end_tuple,
'shortest-path')
gt_path = np.array([[0, 6], [1, 6], [2, 6], [3, 6]])
assert_array_equal(path, gt_path)
示例7: GTModality
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
# Create the corresponding ground-truth
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt,
path_patients_list_gt[idx_pat])
print 'Read the GT data for the current patient ...'
# Load the approproate normalization object
filename_hoffmann = (id_patient_list[idx_pat].lower().replace(' ', '_') +
'_hoffmann.npy')
# Concatenate the training data
# Select the parameter kep
data.append(np.load(os.path.join(path_hoffmann, filename_hoffmann))[:, 2])
# Extract the corresponding ground-truth for the testing data
# Get the index corresponding to the ground-truth
roi_prostate = gt_mod.extract_gt_data('prostate', output_type='index')
# Get the label of the gt only for the prostate ROI
gt_cap = gt_mod.extract_gt_data('cap', output_type='data')
label.append(gt_cap[roi_prostate])
print 'Data and label extracted for the current patient ...'
n_jobs = 48
config = [{'classifier_str': 'random-forest', 'n_estimators': 100,
'gs_n_jobs': n_jobs}]
result_config = []
for c in config:
print 'The following configuration will be used: {}'.format(c)
result_cv = []
# Go for LOPO cross-validation
示例8: GTModality
# 需要导入模块: from protoclass.data_management import GTModality [as 别名]
# 或者: from protoclass.data_management.GTModality import extract_gt_data [as 别名]
# Load the ground truth
# Define the path of the ground for the prostate
path_gt = ['/data/prostate/experiments/Patient 1041/GT_inv/prostate',
'/data/prostate/experiments/Patient 1041/GT_inv/pz',
'/data/prostate/experiments/Patient 1041/GT_inv/cg',
'/data/prostate/experiments/Patient 1041/GT_inv/cap']
label_gt = ['prostate', 'pz', 'cg', 'cap']
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)
# Create an empty volume of the size of the modality data
prob_vol = np.zeros(t2w_mod.data_.shape)
prob_ca = np.zeros(t2w_mod.data_.shape)
# Extract the index of the prostate index
prostate_idx = np.array(gt_mod.extract_gt_data('prostate'))
ca_idx = np.array(gt_mod.extract_gt_data('cap'))
for ii in range(ca_idx.shape[1]):
coord = ca_idx[:, ii]
prob_ca[coord[0], coord[1], coord[2]] = 1
# Assign the value in the volume
for ii in range(prob_cancer.size):
coord = prostate_idx[:, ii]
prob_vol[coord[0], coord[1], coord[2]] = prob_cancer[ii]
idx_sl = 30
plt.figure()
plt.imshow(t2w_mod.data_[:, :, idx_sl])