zea.data.convert.images¶
The function convert_image_dataset convert an existing dataset of images or sequences of images to zea format.
Functions
|
Converts an existing dataset of images or sequences of images to zea format. |
- zea.data.convert.images.convert_image_dataset(existing_dataset_root, new_dataset_root, dataset_name=None, group_pattern=re.compile('(.*)\\..*'), sort_pattern=None)[source]¶
Converts an existing dataset of images or sequences of images to zea format.
Maps an image dataset to a hdf5 dataset containing those images, preserving directory structure. Can also be used to map a video dataset to hdf5 if the videos are stored as sequences on images.
- Parameters:
existing_dataset_root (str) – Path to the root directory of your image dataset.
new_dataset_root (str) – Path to the directory which will be the root of your new dataset.
dataset_name (str, optional) – Dataset name for hdf5 description attribute.
group_pattern (re.Pattern, optional) – Regex pattern to group images into the same hdf5 file.
sort_pattern (re.Pattern, optional) – Regex pattern to extract index for sorting frames in a group of images.
- Returns:
None
Note
If you have a video dataset, stored as sequences of images, you may want to group the files such that images from the same video clip are stored in order in the same hdf5 file, with shape [n_frames, height, width]. This is what the group_pattern and sort_pattern regexes are for. Any images in the current_dir whose paths match group_pattern will be grouped into a single hdf5 file. If the file paths have some index, e.g. frame_{i}.png, then you can match that index with sort_pattern, and the frames will be sorted numerically according to that matched substring.
Example
convert_image_dataset( "./temp/data/camus_test", "./temp/data/oisin/camus_test_h5", group_pattern=re.compile(r"(patient\d+)_\d+\.png"), sort_pattern=re.compile(r"patient\d+_(\d+)\.png"), )