Example #1
0
 def __init__(
     self,
     keys: KeysCollection,
     prefix="Data",
     data_shape=True,
     intensity_range=True,
     data_value=False,
     additional_info=None,
     logger_handler: Optional[Handler] = None,
 ):
     """
     Args:
         keys: keys of the corresponding items to be transformed.
             See also: :py:class:`monai.transforms.compose.MapTransform`
         prefix (string or list of string): will be printed in format: "{prefix} statistics".
         data_shape (bool or list of bool): whether to show the shape of input data.
         intensity_range (bool or list of bool): whether to show the intensity value range of input data.
         data_value (bool or list of bool): whether to show the raw value of input data.
             a typical example is to print some properties of Nifti image: affine, pixdim, etc.
         additional_info (Callable or list of Callable): user can define callable function to extract
             additional info from input data.
         logger_handler (logging.handler): add additional handler to output data: save to file, etc.
             add existing python logging handlers: https://docs.python.org/3/library/logging.handlers.html
     """
     super().__init__(keys)
     self.prefix = ensure_tuple_rep(prefix, len(self.keys))
     self.data_shape = ensure_tuple_rep(data_shape, len(self.keys))
     self.intensity_range = ensure_tuple_rep(intensity_range,
                                             len(self.keys))
     self.data_value = ensure_tuple_rep(data_value, len(self.keys))
     self.additional_info = ensure_tuple_rep(additional_info,
                                             len(self.keys))
     self.logger_handler = logger_handler
     self.printer = DataStats(logger_handler=logger_handler)
Example #2
0
    def __init__(
        self,
        keys: KeysCollection,
        prefix: Union[Sequence[str], str] = "Data",
        data_type: Union[Sequence[bool], bool] = True,
        data_shape: Union[Sequence[bool], bool] = True,
        value_range: Union[Sequence[bool], bool] = True,
        data_value: Union[Sequence[bool], bool] = False,
        additional_info: Optional[Union[Sequence[Callable], Callable]] = None,
        logger_handler: Optional[logging.Handler] = None,
        allow_missing_keys: bool = False,
    ) -> None:
        """
        Args:
            keys: keys of the corresponding items to be transformed.
                See also: :py:class:`monai.transforms.compose.MapTransform`
            prefix: will be printed in format: "{prefix} statistics".
                it also can be a sequence of string, each element corresponds to a key in ``keys``.
            data_type: whether to show the type of input data.
                it also can be a sequence of bool, each element corresponds to a key in ``keys``.
            data_shape: whether to show the shape of input data.
                it also can be a sequence of bool, each element corresponds to a key in ``keys``.
            value_range: whether to show the value range of input data.
                it also can be a sequence of bool, each element corresponds to a key in ``keys``.
            data_value: whether to show the raw value of input data.
                it also can be a sequence of bool, each element corresponds to a key in ``keys``.
                a typical example is to print some properties of Nifti image: affine, pixdim, etc.
            additional_info: user can define callable function to extract
                additional info from input data. it also can be a sequence of string, each element
                corresponds to a key in ``keys``.
            logger_handler: add additional handler to output data: save to file, etc.
                add existing python logging handlers: https://docs.python.org/3/library/logging.handlers.html
                the handler should have a logging level of at least `INFO`.
            allow_missing_keys: don't raise exception if key is missing.

        """
        super().__init__(keys, allow_missing_keys)
        self.prefix = ensure_tuple_rep(prefix, len(self.keys))
        self.data_type = ensure_tuple_rep(data_type, len(self.keys))
        self.data_shape = ensure_tuple_rep(data_shape, len(self.keys))
        self.value_range = ensure_tuple_rep(value_range, len(self.keys))
        self.data_value = ensure_tuple_rep(data_value, len(self.keys))
        self.additional_info = ensure_tuple_rep(additional_info,
                                                len(self.keys))
        self.logger_handler = logger_handler
        self.printer = DataStats(logger_handler=logger_handler)