-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·61 lines (44 loc) · 2.01 KB
/
main.py
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
#!/usr/bin/env python3
import argparse
import ants
import os
from tissue_reconstruction import tissue_reconstruction
parser = argparse.ArgumentParser()
parser.add_argument('patient', help='path to the MRI patient scan with a tumor.\n In nifti file format and registered into SRI space')
parser.add_argument('output', help='Output Folder to which the results will be saved')
parser.add_argument('-d', '--transform_DTI', required=False, action="store_true",
help='Additionally transform DTI Atlas fiber tractation in to the patients anatomy')
parser.add_argument('-t', '--transform_TS', required=False, action="store_true",
help='Additionally transform Atlas tissue segementation and probability maps for WM, GM, CSF in to the patients anatomy')
parser.add_argument('-v', '--verbose', required=False, action="store_true",
help='Verbose ...')
args = parser.parse_args()
V = args.verbose
patient_file = os.path.abspath(args.patient)
output_directory = os.path.abspath(args.output)
if not os.path.isfile(patient_file):
print("Couldn't find the patient file: ", patient_file)
print("Cancel process")
quit()
if not os.path.isdir(output_directory):
if os.path.isfile(output_directory):
print("The output is a file not a directory: ", output_directory)
print("Cancel process")
quit()
print("Output Directory not found! Creating Directory: ", output_directory)
os.makedirs(output_directory)
patient_scan = ants.image_read(patient_file)
if V:
print(f"Reconstructing pre-tumor tissue for patient: {patient_file}")
#print(f"")
print()
results = tissue_reconstruction.reconstruct_pre_tumor_tissue(patient_scan, args.transform_DTI, args.transform_TS, V)
if not results == None:
if V:
print("saving results to specified folder: ", output_directory)
tissue_reconstruction.save_results(results, output_directory)
else:
if V:
print("Results == None, nothing to save")
if V:
print("process Finished")