-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimagePreprocess.py
44 lines (33 loc) · 1.09 KB
/
imagePreprocess.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 05 February, 2018 @ 11:16 PM
@author: Bryant Chhun
email: [email protected]
Project: BayLabs
License:
"""
import glob
import src.preprocess.mask_preprocess as mp
import os
def imagePreprocess():
'''
method to generate images, binary-interpolated-aligned masks, and save them as npy arrays:
1) load img.mhd, scale it, then save to directory './images'
2) load mask.vtk
a) preprocess with contour_preprocess
b) align using apply_recentering_mask3d
c) save to directory './masks'
:return:
'''
data_dir = './data'
glob_search = os.path.join(data_dir, "Patient*")
patient_dirs = sorted(glob.glob(glob_search))
if len(patient_dirs) == 0:
raise Exception("No patient directories found in {}".format(data_dir))
for patient_dir in patient_dirs:
# each Patient folder contains approx 20 time frames of 3D images
p = mp.preprocessData(patient_dir, frame="ED")
p = mp.preprocessData(patient_dir, frame="ES")
if __name__ == '__main__':
imagePreprocess()