コード例 #1
0
ファイル: dataset.py プロジェクト: ChenglongWang/MONAI_EX
    def __getitem__(self, index: int):
        if self.shuffle:
            self.randomize(self.data)

        data1 = self.data[index]
        data2 = self.data[index+self.__len__()]

        if self.transform is not None:
            data1 = apply_transform(self.transform, data1)
            data2 = apply_transform(self.transform, data2)

        return (data1, data2)
コード例 #2
0
 def __call__(self, data):
     if len(self.transforms) == 0:
         return data
     index = self.R.multinomial(1, self.weights).argmax()
     _transform = self.transforms[index]
     data = apply_transform(_transform, data, self.map_items,
                            self.unpack_items, self.log_stats)
     # if the data is a mapping (dictionary), append the OneOf transform to the end
     if isinstance(data, Mapping):
         for key in data.keys():
             if self.trace_key(key) in data:
                 self.push_transform(data, key, extra_info={"index": index})
     return data
コード例 #3
0
ファイル: compose.py プロジェクト: wpddmcmc/MONAI
    def inverse(self, data):
        invertible_transforms = [
            t for t in self.flatten().transforms
            if isinstance(t, InvertibleTransform)
        ]
        if len(invertible_transforms) == 0:
            warnings.warn(
                "inverse has been called but no invertible transforms have been supplied"
            )

        # loop backwards over transforms
        for t in reversed(invertible_transforms):
            data = apply_transform(t.inverse, data)
        return data
コード例 #4
0
    def inverse(self, data):
        invertible_transforms = [
            t for t in self.flatten().transforms
            if isinstance(t, InvertibleTransform)
        ]
        if not invertible_transforms:
            warnings.warn(
                "inverse has been called but no invertible transforms have been supplied"
            )

        # loop backwards over transforms
        for t in reversed(invertible_transforms):
            data = apply_transform(t.inverse, data, self.map_items,
                                   self.unpack_items, self.log_stats)
        return data
コード例 #5
0
 def __call__(self, input_):
     for _transform in self.transforms:
         input_ = apply_transform(_transform, input_, self.map_items,
                                  self.unpack_items, self.log_stats)
     return input_
コード例 #6
0
 def __call__(self, input_):
     for _transform in self.transforms:
         input_ = apply_transform(_transform, input_)
     return input_