[637b40]: / adpkd_segmentation / process_nifti.py

Download this file

30 lines (24 with data), 997 Bytes

 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
"""Process nifti annotations to png masks"""
from argparse import ArgumentParser
from pathlib import Path
from adpkd_segmentation.utils.nifti_utils import process_nifti_dirs
# "source" can be any nested directory structure containing study directories
# each study directory should have a unique name, and it should
# contain "DICOM_anon" dir containing dcm files and "Untitled.nii.gz"
# check nifti_utils for expected constant definitions
# all study dirs will be processed and copied to a single root target dir
parser = ArgumentParser()
parser.add_argument(
"source", type=str, help="Source directory with annotations"
)
parser.add_argument(
"target", type=str, help="Target directory for processed studies"
)
if __name__ == "__main__":
args = parser.parse_args()
source_dir = Path(args.source)
target_dir = Path(args.target)
print(
f"Processing studies: \nSource {source_dir}, Target {target_dir}\n\n"
)
process_nifti_dirs(source_dir, target_dir)