3e403dd963698ff77cac54cf8f38c3dbaa0de046,niftynet/engine/sampler_uniform.py,,rand_spatial_coordinates,#Any#Any#Any#Any#,156

Before Change




def rand_spatial_coordinates(subject_id, win_sizes, img_sizes, n_samples):
    if len(set(img_size[:N_SPATIAL] for img_size in img_sizes)) > 1:
        tf.logging.fatal("Don"t know how to generate sampling "
                         "locations: Spatial dimensions of the "
                         "grouped input sources are not "
                         "consistent. {}".format(img_sizes))
        raise NotImplementedError

    // find spatial window location based on the largest spatial window
    spatial_win_sizes = [win_size[:N_SPATIAL] for win_size in win_sizes]
    spatial_win_sizes = np.asarray(spatial_win_sizes, dtype=np.int32)
    max_spatial_win = np.max(spatial_win_sizes, axis=0)
    max_coords = np.zeros((n_samples, N_SPATIAL), dtype=np.int32)
    for i in range(0, N_SPATIAL):
        max_coords[:, i] = np.random.randint(
            0, max(img_sizes[0][i] - max_spatial_win[i], 1), n_samples)

    // adjust max spatial coordinates based on each spatial window size
    all_coordinates = []
    for win_size in spatial_win_sizes:
        subject_id = np.ones((n_samples,), dtype=np.int32) * subject_id
        spatial_coords = np.zeros(
            (n_samples, N_SPATIAL * 2), dtype=np.int32)
        // shift starting coords of the window
        // so that smaller windows are centred within the large windows
        half_win_diff = np.floor((max_spatial_win - win_size) / 2.0)
        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]
        // include the subject id
        spatial_coords = np.append(
            subject_id[:, None], spatial_coords, axis=1)
        all_coordinates.append(spatial_coords)
    return all_coordinates


    // def __init__(self,

After Change


            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]
        subject_id = np.ones((n_samples,), dtype=np.int32) * subject_id
        spatial_coords = np.zeros(
            (n_samples, N_SPATIAL * 2), dtype=np.int32)
        // shift starting coords of the window
        // so that smaller windows are centred within the large windows
        half_win_diff = np.floor((max_spatial_win - win_size) / 2.0)
        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]
        // include the subject id
        spatial_coords = np.append(
            subject_id[:, None], spatial_coords, axis=1)
        all_coordinates[mod] = spatial_coords
    return all_coordinates


    // def __init__(self,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: NifTK/NiftyNet
Commit Name: 3e403dd963698ff77cac54cf8f38c3dbaa0de046
Time: 2017-08-06
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/engine/sampler_uniform.py
Class Name:
Method Name: rand_spatial_coordinates


Project Name: SPFlow/SPFlow
Commit Name: 5f12688e83bfb0acadb6b8ab56c293ed123e3a7a
Time: 2019-03-14
Author: molina@cs.tu-darmstadt.de
File Name: src/spn/algorithms/MPE.py
Class Name:
Method Name: mpe_sum


Project Name: SPFlow/SPFlow
Commit Name: 5f12688e83bfb0acadb6b8ab56c293ed123e3a7a
Time: 2019-03-14
Author: molina@cs.tu-darmstadt.de
File Name: src/spn/algorithms/Sampling.py
Class Name:
Method Name: sample_sum