コード例 #1
0
def dummy_data_and_labels():
    """Create a dummy data with partial volume effect, with associated mask, for testing extract_metric()."""
    data = Metric(data=np.array([19., 21., 30., 39., 41.]))
    # Create 3 labels. The last label has very small volume fraction to assess the efficacy of MAP estimation.
    labels = np.array([[0., 0., 0.5, 1., 1.],
                       [0.9, 1., 0.5, 0., 0.],
                       [0.1, 0., 0., 0., 0.]]).T  # need to transpose because last dim are labels
    # Create label_struc{}
    label_struc = {0: aggregate_slicewise.LabelStruc(id=0, name='label_0', map_cluster=0),
                   1: aggregate_slicewise.LabelStruc(id=1, name='label_1', map_cluster=1),
                   2: aggregate_slicewise.LabelStruc(id=2, name='label_2', map_cluster=1),
                   99: aggregate_slicewise.LabelStruc(id=[1, 2], name='label_1,2', map_cluster=None)}
    return data, labels, label_struc
コード例 #2
0
def dummy_data_and_labels_2d():
    """Create a dummy 2d data with associated 2d label, for testing extract_metric()."""
    data = Metric(data=np.array([[5, 5],
                                 [5, 5]]))
    labels = np.array([[1, 1],
                       [1, 1]]).T  # need to transpose because last dim are labels
    labels = np.expand_dims(labels, axis=2)  # because ndim(label) = ndim(data)+1
    # Create label_struc{}
    label_struc = {0: aggregate_slicewise.LabelStruc(id=0, name='mask')}
    return data, labels, label_struc