当前位置: 首页>>代码示例>>Python>>正文


Python DCEModality.build_heatmap方法代码示例

本文整理汇总了Python中protoclass.data_management.DCEModality.build_heatmap方法的典型用法代码示例。如果您正苦于以下问题:Python DCEModality.build_heatmap方法的具体用法?Python DCEModality.build_heatmap怎么用?Python DCEModality.build_heatmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在protoclass.data_management.DCEModality的用法示例。


在下文中一共展示了DCEModality.build_heatmap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_build_graph

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [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)
开发者ID:glemaitre,项目名称:protoclass,代码行数:32,代码来源:test_standard_time_normalization.py

示例2: test_shift_heatmap

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [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)
开发者ID:glemaitre,项目名称:protoclass,代码行数:35,代码来源:test_standard_time_normalization.py

示例3: test_shift_heatmap_wrong_shift

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [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)
开发者ID:glemaitre,项目名称:protoclass,代码行数:32,代码来源:test_standard_time_normalization.py

示例4: test_build_heatmap_roi

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [as 别名]
def test_build_heatmap_roi():
    """ Test if the heatmap is built properly when providing a ROI. """

    # 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)
    dce_mod.data_ /= 2.
    dce_mod.update_histogram()

    # Create some ground-truth
    pos = np.ones((368, 448), dtype=bool)
    neg = np.zeros((368, 448), dtype=bool)
    gt_index = np.rollaxis(np.array([neg, pos, pos, pos, neg]), 0, 3)

    # Build the heatmap
    heatmap, bins_heatmap = dce_mod.build_heatmap(roi_data=(gt_index))

    # Check that heatmap is what we expect
    data = np.load(os.path.join(currdir, 'data', 'heatmap_roi_mod.npy'))
    assert_array_equal(heatmap, data)
    data = np.load(os.path.join(currdir, 'data', 'bins_heatmap_roi_mod.npy'))
    assert_array_equal(bins_heatmap, data)
开发者ID:glemaitre,项目名称:protoclass,代码行数:29,代码来源:test_dce_modality.py

示例5: test_build_heatmap_none_bins

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [as 别名]
def test_build_heatmap_none_bins():
    """ Test if the heatmap is built properly with None value for bins."""

    # 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)

    # Build the heatmap
    heatmap, bins_heatmap = dce_mod.build_heatmap(nb_bins=None)

    # Check that heatmap is what we expect
    data = np.load(os.path.join(currdir, 'data', 'heatmap.npy'))
    assert_array_equal(heatmap, data)
    data = np.load(os.path.join(currdir, 'data', 'bins_heatmap.npy'))
    assert_array_equal(bins_heatmap, data)
开发者ID:glemaitre,项目名称:protoclass,代码行数:22,代码来源:test_dce_modality.py

示例6: test_walk_through_graph_shortest_path

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [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)
开发者ID:glemaitre,项目名称:protoclass,代码行数:40,代码来源:test_standard_time_normalization.py

示例7: DCEModality

# 需要导入模块: from protoclass.data_management import DCEModality [as 别名]
# 或者: from protoclass.data_management.DCEModality import build_heatmap [as 别名]
path_dce = '/data/prostate/experiments/Patient 387/DCE'

# Define the list of path for the GT
path_gt = ['/data/prostate/experiments/Patient 387/GT_inv/prostate']
# Define the associated list of label for the GT
label_gt = ['prostate']

# Read the DCE
dce_mod = DCEModality()
dce_mod.read_data_from_path(path_dce)

# Read the GT
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)

# Fit the data to get the normalization parameters
dce_norm.fit(dce_mod, ground_truth=gt_mod,
                           cat='prostate')

dce_mod_norm = dce_norm.normalize(dce_mod)
# Plot the figure
plt.figure()
heatmap, bins_heatmap = dce_mod.build_heatmap(np.nonzero(gt_mod.data_[0, :, :, :]))
sns.heatmap(heatmap, cmap='jet')
# plt.plot(dce_norm.shift_idx_, np.arange(0, dce_mod.n_serie_)[::-1] + .5 ,'ro')
# plt.plot(dce_norm.shift_idx_ + dce_norm.rmse,
#          np.arange(0, dce_mod.n_serie_)[::-1] + .5 ,'go')
# plt.plot(dce_norm.shift_idx_ - dce_norm.rmse,
#          np.arange(0, dce_mod.n_serie_)[::-1] + .5 ,'go')
plt.savefig('heatmap.png')
开发者ID:I2Cvb,项目名称:prostate,代码行数:32,代码来源:dce_normalization.py


注:本文中的protoclass.data_management.DCEModality.build_heatmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。