forked from mlcommons/GaNDLF
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gandlf_constructCSV
56 lines (46 loc) · 1.65 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
#!usr/bin/env python
# -*- coding: utf-8 -*-
import os, argparse
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(
"-inputDir",
type=str,
help="Input data directory which contains images in specified format",
required=True,
)
parser.add_argument(
"-channelsID",
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",
required=True,
)
parser.add_argument(
"-labelID",
type=str,
help="Label/mask identifier string to check for in all files in 'input_dir'; for example: -labelID _seg.nii.gz",
required=False,
)
parser.add_argument("-outputFile", type=str, help="Output CSV file", required=True)
args = parser.parse_args()
inputDir = os.path.normpath(args.inputDir)
outputFile = os.path.normpath(args.outputFile)
if not args.labelID:
args.labelID = ""
writeTrainingCSV(inputDir, args.channelsID, args.labelID, outputFile)
# main function
if __name__ == "__main__":
main()