c8b28432a637a780eed96547260722ff3dede57e,niftynet/engine/sampler_selective.py,,rand_choice_coordinates,#Any#Any#Any#Any#Any#Any#,350

Before Change


    // print(len(candidates_indices), candidates_indices.shape)
    if mean_counts_size is not None:
        print("Probability weighting considered")
        proba = []
        for (c,  p) in zip(candidates.flatten(), mean_counts_size.flatten()):
            if c >= 1:
                proba.append(p)
        print(len(list_indices), len(proba))
        list_indices_fin = np.random.choice(list_indices, n_samples,
                                            replace=False, p=proba)
    else:
        print("No probability weighting needed")
        list_indices_fin = list_indices
        np.random.shuffle(list_indices)
    for i in range(0, n_samples):
        indices_to_add = candidates_indices[list_indices_fin[i]]
        // print(max_coords.shape, indices_to_add)
        for s in range(0, N_SPATIAL):
            max_coords[i, s] = indices_to_add[s] - np.floor(
                spatial_win_sizes[0]/2)[s]
    // for i in range(0, N_SPATIAL):
    //     assert uniq_spatial_size[i] >= max_spatial_win[i], \
    //         "window size {} is larger than image size {}".format(
    //             max_spatial_win[i], uniq_spatial_size[i])
    //     max_coords[:, i] = np.random.randint(
    //         0, max(uniq_spatial_size[i] - max_spatial_win[i], 1), n_samples)

    // adjust max spatial coordinates based on each spatial window size
    all_coordinates = {}
    for mod in list(win_sizes):
        win_size = win_sizes[mod][:N_SPATIAL]
        half_win_diff = np.floor((max_spatial_win - win_size) / 2.0)
        // shift starting coords of the window
        // so that smaller windows are centred within the large windows
        spatial_coords = np.zeros((n_samples, N_SPATIAL * 2), dtype=np.int32)
        spatial_coords[:, :N_SPATIAL] = \
            max_coords[:, :N_SPATIAL] + half_win_diff[:N_SPATIAL]

        spatial_coords[:, N_SPATIAL:] = \

After Change


        list_indices_fin = list_indices_fin[:n_samples]

    max_coords = np.zeros((n_samples, N_SPATIAL), dtype=np.int32)
    half_win = np.floor(np.asarray(win_sizes["image"]) / 2).astype(np.int)
    for (i_sample, ind) in enumerate(list_indices_fin):
        indices_to_add = candidates_indices[ind]
        max_coords[i_sample, :N_SPATIAL] = \
            indices_to_add[:N_SPATIAL] - half_win[:N_SPATIAL]

    // adjust max spatial coordinates based on each spatial window size
    all_coordinates = {}
    for mod in list(win_sizes):
        win_size = win_sizes[mod][:N_SPATIAL]
        half_win_diff = np.floor((max_spatial_win - win_size) / 2.0)
        // shift starting coords of the window
        // so that smaller windows are centred within the large windows
        spatial_coords = np.zeros((n_samples, N_SPATIAL * 2), dtype=np.int32)
        spatial_coords[:, :N_SPATIAL] = \
            max_coords[:, :N_SPATIAL] + half_win_diff[:N_SPATIAL]
        spatial_coords[:, N_SPATIAL:] = \
            spatial_coords[:, :N_SPATIAL] + win_size[:N_SPATIAL]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: NifTK/NiftyNet
Commit Name: c8b28432a637a780eed96547260722ff3dede57e
Time: 2017-10-04
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/engine/sampler_selective.py
Class Name:
Method Name: rand_choice_coordinates


Project Name: ilastik/ilastik
Commit Name: eee44cb44984b803a0c4a0e6a2b41b48b200989e
Time: 2018-11-26
Author: carstenhaubold@googlemail.com
File Name: lazyflow/classifiers/pytorchLazyflowClassifier.py
Class Name: PyTorchLazyflowClassifier
Method Name: predict_probabilities_pixelwise


Project Name: ilastik/ilastik
Commit Name: 31987e99d495f8eafc83fa5294be44a746c51e19
Time: 2018-04-25
Author: carstenhaubold@googlemail.com
File Name: lazyflow/classifiers/pytorchLazyflowClassifier.py
Class Name: PyTorchLazyflowClassifier
Method Name: predict_probabilities_pixelwise