Args: img: The input image with metadata.
(self, img: NdarrayOrTensor)
| 537 | self.mapping_file_path = Path(mapping_file_path) |
| 538 | |
| 539 | def __call__(self, img: NdarrayOrTensor): |
| 540 | """ |
| 541 | Args: |
| 542 | img: The input image with metadata. |
| 543 | """ |
| 544 | if isinstance(img, MetaTensor): |
| 545 | meta_data = img.meta |
| 546 | |
| 547 | if MetaKeys.SAVED_TO not in meta_data: |
| 548 | raise KeyError( |
| 549 | "Missing 'saved_to' key in metadata. Check SaveImage argument 'savepath_in_metadict' is True." |
| 550 | ) |
| 551 | |
| 552 | input_path = meta_data[ImageMetaKey.FILENAME_OR_OBJ] |
| 553 | output_path = meta_data[MetaKeys.SAVED_TO] |
| 554 | log_data = {"input": input_path, "output": output_path} |
| 555 | |
| 556 | if has_filelock: |
| 557 | with FileLock(str(self.mapping_file_path) + ".lock"): |
| 558 | self._write_to_file(log_data) |
| 559 | else: |
| 560 | self._write_to_file(log_data) |
| 561 | return img |
| 562 | |
| 563 | def _write_to_file(self, log_data): |
| 564 | try: |
nothing calls this directly
no test coverage detected