7e696de70513fa05a69d21b45d2935e0b7681d04,niftynet/contrib/csv_reader/sampler_csvpatch.py,CSVPatchSampler,layer_op,#CSVPatchSampler#Any#,55

Before Change


                    if len(csv_data_array) == 1:
                        output_dict[name] = np.asarray(csv_data_array[0])
                    else:
                        output_dict[name] = np.concatenate(csv_data_array,0)

                else:
                    csv_data_array=[]
                    for n in range(0, self.window.n_samples):
                        csv_data_array.append(csv_data_dict["sampler"])
                    if len(csv_data_array) == 1:
                        output_dict["sampler"] = np.asarray(csv_data_array[0])
                    else:
                        output_dict["sampler"] = np.concatenate(csv_data_array,0)
            // _, label_dict, _ = self.csv_reader(subject_id=image_id)
            // for name in self.csv_reader.task_param.keys():
            //
            // output_dict.update(label_dict)
            for name in csv_data_dict.keys():
                output_dict[name + "_location"] = output_dict["image_location"]
        yield output_dict
        // the output image shape should be
        // [enqueue_batch_size, x, y, z, time, modality]
        // where enqueue_batch_size = windows_per_image

After Change


        // initialise output dict, placeholders as dictionary keys
        // this dictionary will be used in
        // enqueue operation in the form of: `feed_dict=output_dict`
        output_dict = {}
        // fill output dict with data
        for name in list(data):
            coordinates_key = LOCATION_FORMAT.format(name)
            image_data_key = name

            // fill the coordinates
            location_array = coordinates[name]
            output_dict[coordinates_key] = location_array

            // fill output window array
            image_array = []
            for window_id in range(self.window.n_samples):
                x_start, y_start, z_start, x_end, y_end, z_end = \
                    location_array[window_id, 1:]
                try:
                    image_window = data[name][
                        x_start:x_end, y_start:y_end, z_start:z_end, ...]
                    image_array.append(image_window[np.newaxis, ...])
                except ValueError:
                    tf.logging.fatal(
                        "dimensionality miss match in input volumes, "
                        "please specify spatial_window_size with a "
                        "3D tuple and make sure each element is "
                        "smaller than the image length in each dim. "
                        "Current coords %s", location_array[window_id])
                    raise
            if len(image_array) > 1:
                output_dict[image_data_key] = \
                    np.concatenate(image_array, axis=0)
            else:
                output_dict[image_data_key] = image_array[0]
        // fill output dict with csv_data
        if self.csv_reader is not None:
            idx_dict = {}
            list_keys = self.csv_reader.df_by_task.keys()
            for k in list_keys:
                if k == "sampler":
                    idx_dict[k] = idx
                else:
                    for n in range(0, self.window.n_samples):
                        idx_dict[k] = 0

            _, csv_data_dict,_ = self.csv_reader(idx=idx_dict,
                                                 subject_id=subject_id)
            for name in csv_data_dict.keys():
                if name != "sampler":
                    csv_data_array = []
                    for n in range(0, self.window.n_samples):
                        csv_data_array.append(csv_data_dict[name])
                    if len(csv_data_array) == 1:
                        output_dict[name] = np.asarray(csv_data_array[0],
                                                       dtype=np.float32)
                    else:
                        output_dict[name] = np.concatenate(
                            csv_data_array,0).astype(dtype=np.float32)

                else:
                    csv_data_array=[]
                    for n in range(0, self.window.n_samples):
                        csv_data_array.append(csv_data_dict["sampler"])
                    if len(csv_data_array) == 1:
                        output_dict["sampler"] = np.asarray(csv_data_array[0],
                                                       dtype=np.float32)
                    else:
                        output_dict["sampler"] = np.concatenate(
                            csv_data_array,0).astype(np.float32)
            // _, label_dict, _ = self.csv_reader(subject_id=image_id)
            // for name in self.csv_reader.task_param.keys():
            //
            // output_dict.update(label_dict)
            for name in csv_data_dict.keys():
                output_dict[name + "_location"] = output_dict["image_location"]
        return output_dict
        // the output image shape should be
        // [enqueue_batch_size, x, y, z, time, modality]
        // where enqueue_batch_size = windows_per_image
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: NifTK/NiftyNet
Commit Name: 7e696de70513fa05a69d21b45d2935e0b7681d04
Time: 2019-06-05
Author: carole.sudre@kcl.ac.uk
File Name: niftynet/contrib/csv_reader/sampler_csvpatch.py
Class Name: CSVPatchSampler
Method Name: layer_op


Project Name: NifTK/NiftyNet
Commit Name: c482d17936d566ed7806708dca64160f1d632707
Time: 2019-07-03
Author: carole.sudre@kcl.ac.uk
File Name: niftynet/contrib/csv_reader/sampler_csvpatch.py
Class Name: CSVPatchSampler
Method Name: layer_op


Project Name: NifTK/NiftyNet
Commit Name: 7e696de70513fa05a69d21b45d2935e0b7681d04
Time: 2019-06-05
Author: carole.sudre@kcl.ac.uk
File Name: niftynet/contrib/csv_reader/sampler_csvpatch.py
Class Name: CSVPatchSampler
Method Name: layer_op


Project Name: NifTK/NiftyNet
Commit Name: bd333dd43d69b26015eb3f201afe1772ba701a41
Time: 2018-05-07
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/contrib/dataset_sampler/sampler_uniform_v2.py
Class Name: UniformSampler
Method Name: layer_op