MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _set_spike

Method _set_spike

monai/transforms/intensity/array.py:2175–2189  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
2192class RandKSpaceSpikeNoise(RandomizableTransform, Fourier):

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected