forked from mlcommons/GaNDLF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gandlf_constructCSV
71 lines (61 loc) · 1.99 KB
/
gandlf_constructCSV
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!usr/bin/env python
# -*- coding: utf-8 -*-
import os, argparse, sys
from datetime import date
from GANDLF.utils import writeTrainingCSV
def main():
copyrightMessage = (
"Contact: [email protected]\n\n"
+ "This program is NOT FDA/CE approved and NOT intended for clinical use.\nCopyright (c) "
+ str(date.today().year)
+ " University of Pennsylvania. All rights reserved."
)
parser = argparse.ArgumentParser(
prog="GANDLF_ConstructCSV",
formatter_class=argparse.RawTextHelpFormatter,
description="Generate training/inference CSV from data directory.\n\n"
+ copyrightMessage,
)
parser.add_argument(
"-i",
"--inputDir",
metavar="",
type=str,
help="Input data directory which contains images in specified format",
)
parser.add_argument(
"-c",
"--channelsID",
metavar="",
type=str,
help="Channels/modalities identifier string to check for in all files in 'input_dir'; for example: --channelsID _t1.nii.gz,_t2.nii.gz",
)
parser.add_argument(
"-l",
"--labelID",
default=None,
type=str,
help="Label/mask identifier string to check for in all files in 'input_dir'; for example: --labelID _seg.nii.gz",
)
parser.add_argument(
"-o",
"--outputFile",
metavar="",
type=str,
help="Output CSV file",
)
args = parser.parse_args()
# check for required parameters - this is needed here to keep the cli clean
for param_none_check in [
args.inputDir,
args.channelsID,
args.outputFile,
]:
if param_none_check is None:
sys.exit("ERROR: Missing required parameter:", param_none_check)
inputDir = os.path.normpath(args.inputDir)
outputFile = os.path.normpath(args.outputFile)
writeTrainingCSV(inputDir, args.channelsID, args.labelID, outputFile)
# main function
if __name__ == "__main__":
main()