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

Method set_metadata

monai/data/image_writer.py:739–757  ·  view source on GitHub ↗

Resample ``self.data_obj`` if needed. This method assumes ``self.data_obj`` is a 'channel-last' ndarray. Args: meta_dict: a metadata dictionary for affine, original affine and spatial shape information. Optional key is ``"spatial_shape"``. r

(self, meta_dict: Mapping | None = None, resample: bool = True, **options)

Source from the content-addressed store, hash-verified

737 )
738
739 def set_metadata(self, meta_dict: Mapping | None = None, resample: bool = True, **options):
740 """
741 Resample ``self.data_obj`` if needed. This method assumes ``self.data_obj`` is a 'channel-last' ndarray.
742
743 Args:
744 meta_dict: a metadata dictionary for affine, original affine and spatial shape information.
745 Optional key is ``"spatial_shape"``.
746 resample: if ``True``, the data will be resampled to the spatial shape specified in ``meta_dict``.
747 options: keyword arguments passed to ``self.resample_if_needed``,
748 currently support ``mode``, defaulting to ``bicubic``.
749 """
750 spatial_shape = self.get_meta_info(meta_dict)
751 if self.output_dtype is None and hasattr(self.data_obj, "dtype"): # pylint: disable=E0203
752 self.output_dtype = self.data_obj.dtype # type: ignore
753 self.data_obj = self.resample_and_clip(
754 data_array=self.data_obj,
755 output_spatial_shape=spatial_shape if resample else None,
756 mode=options.pop("mode", InterpolateMode.BICUBIC),
757 )
758
759 def write(self, filename: PathLike, verbose: bool = False, **kwargs):
760 """

Callers 1

Calls 3

get_meta_infoMethod · 0.95
resample_and_clipMethod · 0.95
popMethod · 0.80

Tested by 1