def _convert_masks(gt_dir: Path) -> None:
        """Convert mask files from ``.mat`` to ``.png`` format.

        The masks in the Avenue datasets are provided as matlab (``.mat``) files.
        To speed up data loading, we convert the masks into a separate ``.png``
        file for every video frame in the dataset.

        Args:
            gt_dir (Path): Ground truth folder of the dataset.
        """
        # convert masks to numpy
        masks_dir = gt_dir / "testing_label_mask"
        # get file names
        mat_files = list(masks_dir.glob("*.mat"))
        mask_folders = [matfile.with_suffix("") for matfile in mat_files]
        if not all(folder.exists() for folder in mask_folders):
            # convert mask files to images
            logger.info("converting mat files to .png format.")
            for mat_file, mask_folder in zip(mat_files, mask_folders, strict=True):
                mat = scipy.io.loadmat(mat_file)
                mask_folder.mkdir(parents=True, exist_ok=True)
                masks = mat["volLabel"].squeeze()
                for idx, mask in enumerate(masks):
                    filename = (mask_folder / str(idx).zfill(int(math.log10(len(masks)) + 1))).with_suffix(".png")
                    cv2.imwrite(str(filename), mask)
Convert mask files from ``.mat`` to ``.png`` format.

        The masks in the Avenue datasets are provided as matlab (``.mat``) files.
        To speed up data loading, we convert the masks into a separate ``.png``
        file for every video frame in the dataset.

        Args:
            gt_dir (Path): Ground truth folder of the dataset.
        
src/anomalib/data/datamodules/video/avenue.py