Helper function to introduce a given intensity at given location. Args: k: intensity array to alter. idx: index of location where to apply change. val: value of intensity to write in.
(self, k: NdarrayOrTensor, idx: tuple, val: Sequence[float] | float)
| 2173 | ) |
| 2174 | |
| 2175 | def _set_spike(self, k: NdarrayOrTensor, idx: tuple, val: Sequence[float] | float): |
| 2176 | """ |
| 2177 | Helper function to introduce a given intensity at given location. |
| 2178 | |
| 2179 | Args: |
| 2180 | k: intensity array to alter. |
| 2181 | idx: index of location where to apply change. |
| 2182 | val: value of intensity to write in. |
| 2183 | """ |
| 2184 | if len(k.shape) == len(idx): |
| 2185 | k[idx] = val[idx[0]] if isinstance(val, Sequence) else val |
| 2186 | elif len(k.shape) == 4 and len(idx) == 3: |
| 2187 | k[:, idx[0], idx[1], idx[2]] = val # type: ignore |
| 2188 | elif len(k.shape) == 3 and len(idx) == 2: |
| 2189 | k[:, idx[0], idx[1]] = val # type: ignore |
| 2190 | |
| 2191 | |
| 2192 | class RandKSpaceSpikeNoise(RandomizableTransform, Fourier): |