-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcvds.py
More file actions
53 lines (42 loc) · 2.06 KB
/
cvds.py
File metadata and controls
53 lines (42 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import logging
import click
import converters
logging.basicConfig(format="%(msecs)dms [%(levelname)s]: %(message)s", level=logging.DEBUG)
@click.command()
@click.argument("dataset-dir-or-file-path", type=click.Path(exists=True))
@click.argument("output-dir", type=click.Path(exists=True, dir_okay=True, file_okay=False))
def run(
dataset_dir_or_file_path: str,
output_dir: str,
) -> None:
"""Converts CT (or MRI) data into a human readable metadata.txt file and
chunked, lz4-compressed, binary chunked volumetric dataSet (CVDS) format.
CVDS is a simple format that is meant to be consumed directly by Unity with
very minimal (or none) transformations during runtime. The format is meant
to be consumed by Unity's Texture3D. For instance, if a volume brick
(i.e., chunk) is requested during rendering, the chunk is simply
decompressed and applied directly to the Texture3D.
Out-of-core conversion is supported (i.e., dataset is too large to fit in
memory all at once). The converter has a minimal memory footprint and keeps
at most a decoded image raw data (i.e., slice) in memory at once.
Currently supported CT (or MRI) datasets include:
IMAGE SEQUENCES (PNG, TIFF):
a sequence of slice images ordered according to their names. User is
prompted for crucial and optional volumetric properties such as: width,
height, color depth, etc.
DICOM:
a widely used international standard to transmit, store, retrieve,
print, process, and display medical imaging information. Everything needed
to correctly visualize the volumetric data is also provided within the
same file.
RAW:
binary raw format. Users are prompted for crucial volumetric properties
such as: width, height, color depth, etc.
"""
uvds_converter = converters.Converter.factory(dataset_dir_or_file_path)
uvds_converter.import_dataset(dataset_dir_or_file_path)
uvds_converter.write_metadata(output_dir)
uvds_converter.write_binary_chunks(output_dir)
logging.info("done")
if __name__ == "__main__":
run()