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

Method write

monai/data/image_writer.py:451–476  ·  view source on GitHub ↗

Create an ITK object from ``self.create_backend_obj(self.obj, ...)`` and call ``itk.imwrite``. Args: filename: filename or PathLike object. verbose: if ``True``, log the progress. kwargs: keyword arguments passed to ``itk.imwrite``,

(self, filename: PathLike, verbose: bool = False, **kwargs)

Source from the content-addressed store, hash-verified

449 )
450
451 def write(self, filename: PathLike, verbose: bool = False, **kwargs):
452 """
453 Create an ITK object from ``self.create_backend_obj(self.obj, ...)`` and call ``itk.imwrite``.
454
455 Args:
456 filename: filename or PathLike object.
457 verbose: if ``True``, log the progress.
458 kwargs: keyword arguments passed to ``itk.imwrite``,
459 currently support ``compression`` and ``imageio``.
460
461 See also:
462
463 - https://github.com/InsightSoftwareConsortium/ITK/blob/v5.2.1/Wrapping/Generators/Python/itk/support/extras.py#L809
464 """
465 super().write(filename, verbose=verbose)
466 self.data_obj = self.create_backend_obj(
467 cast(NdarrayOrTensor, self.data_obj),
468 channel_dim=self.channel_dim,
469 affine=self.affine,
470 dtype=self.output_dtype,
471 affine_lps_to_ras=self.affine_lps_to_ras, # type: ignore
472 **kwargs,
473 )
474 itk.imwrite(
475 self.data_obj, filename, compression=kwargs.pop("compression", False), imageio=kwargs.pop("imageio", None)
476 )
477
478 @classmethod
479 def create_backend_obj(

Callers 15

test_channel_shapeMethod · 0.95
test_rgbMethod · 0.95
test_no_channelMethod · 0.95
do_vcs_installFunction · 0.45
write_to_version_fileFunction · 0.45
runMethod · 0.45
runMethod · 0.45
find_sourcesMethod · 0.45
do_setupFunction · 0.45
_build_and_saveMethod · 0.45
_onnx_trt_compileFunction · 0.45
warmup_kvikioMethod · 0.45

Calls 2

create_backend_objMethod · 0.95
popMethod · 0.80

Tested by 15

test_channel_shapeMethod · 0.76
test_rgbMethod · 0.76
test_no_channelMethod · 0.76
test_scripts_foldMethod · 0.36
setUpMethod · 0.36
prepare_csv_fileMethod · 0.36
test_seg_valuesMethod · 0.36
test_seg_valuesMethod · 0.36
test_cls_valuesMethod · 0.36
test_seg_no_basedirMethod · 0.36
test_seg_no_labelsMethod · 0.36
test_additional_itemsMethod · 0.36