| 55 | return np.asarray(sids) |
| 56 | |
| 57 | def __call__(self, data: Any) -> dict: |
| 58 | d: dict = dict(data) |
| 59 | label = d[self.label].numpy() if isinstance(data[self.label], torch.Tensor) else data[self.label] |
| 60 | if label.shape[0] != 1: |
| 61 | raise ValueError(f"Only supports single channel labels, got label shape {label.shape}!") |
| 62 | |
| 63 | if len(label.shape) != 4: # only for 3D |
| 64 | raise ValueError(f"Only supports label with shape CDHW, got label shape {label.shape}!") |
| 65 | |
| 66 | sids = self._apply(label) |
| 67 | if sids is not None and len(sids): |
| 68 | d[self.sids] = sids |
| 69 | return d |
| 70 | |
| 71 | |
| 72 | class AddInitialSeedPointd(Randomizable, Transform): |