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

Method set_data_array

monai/data/image_writer.py:711–737  ·  view source on GitHub ↗

Convert ``data_array`` into 'channel-last' numpy ndarray. Args: data_array: input data array with the channel dimension specified by ``channel_dim``. channel_dim: channel dimension of the data array. Defaults to 0. ``None`` indicates data wit

(
        self,
        data_array: NdarrayOrTensor,
        channel_dim: int | None = 0,
        squeeze_end_dims: bool = True,
        contiguous: bool = False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

709 super().__init__(output_dtype=output_dtype, channel_dim=channel_dim, scale=scale, **kwargs)
710
711 def set_data_array(
712 self,
713 data_array: NdarrayOrTensor,
714 channel_dim: int | None = 0,
715 squeeze_end_dims: bool = True,
716 contiguous: bool = False,
717 **kwargs,
718 ):
719 """
720 Convert ``data_array`` into 'channel-last' numpy ndarray.
721
722 Args:
723 data_array: input data array with the channel dimension specified by ``channel_dim``.
724 channel_dim: channel dimension of the data array. Defaults to 0.
725 ``None`` indicates data without any channel dimension.
726 squeeze_end_dims: if ``True``, any trailing singleton dimensions will be removed.
727 contiguous: if ``True``, the data array will be converted to a contiguous array. Default is ``False``.
728 kwargs: keyword arguments passed to ``self.convert_to_channel_last``,
729 currently support ``spatial_ndim``, defaulting to ``2``.
730 """
731 self.data_obj = self.convert_to_channel_last(
732 data=data_array,
733 channel_dim=channel_dim,
734 squeeze_end_dims=squeeze_end_dims,
735 spatial_ndim=kwargs.pop("spatial_ndim", 2),
736 contiguous=contiguous,
737 )
738
739 def set_metadata(self, meta_dict: Mapping | None = None, resample: bool = True, **options):
740 """

Callers 6

test_write_grayMethod · 0.95
test_write_rgbMethod · 0.95
test_write_2channelsMethod · 0.95

Calls 2

popMethod · 0.80

Tested by 6

test_write_grayMethod · 0.76
test_write_rgbMethod · 0.76
test_write_2channelsMethod · 0.76