-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
44 lines (34 loc) · 1.63 KB
/
test.py
File metadata and controls
44 lines (34 loc) · 1.63 KB
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
import SimpleITK as sitk
import tre3d as t
import cv2
from scipy import ndimage
import os,shutil
import helper
def test():
print('start')
for patient in os.listdir('/mnt/hd1/puwenbo/Dataset/T1T2/moving/'):
print('do ' + patient + 'now')
elastixImageFilter = sitk.ElastixImageFilter()
fix = sitk.ReadImage('/mnt/hd1/puwenbo/Dataset/T1T2/fixed/' + patient)
elastixImageFilter.SetFixedImage(fix)
elastixImageFilter.SetMovingImage(sitk.ReadImage('/mnt/hd1/puwenbo/Dataset/T1T2/moving/' + patient))
elastixImageFilter.SetParameterMap(helper.p)
elastixImageFilter.SetOutputDirectory('/mnt/hd1/puwenbo/Dataset/T1T2/output/')
elastixImageFilter.Execute()
res = helper.normalization(sitk.GetArrayFromImage(elastixImageFilter.GetResultImage()))
sitk.WriteImage(sitk.GetImageFromArray(res), '/mnt/hd1/puwenbo/Dataset/T1T2/output/'+ patient)
def move():
for patient in os.listdir('/mnt/hd1/puwenbo/Dataset/T1T2/fixed/'):
if patient in os.listdir('/mnt/hd1/leixiaotang/PD1/'):
shutil.copy('/mnt/hd1/puwenbo/Dataset/T1T2/fixed/' + patient, '/mnt/hd1/puwenbo/Dataset/T1PD/fixed/')
move()
# test()
def size():
for patient in os.listdir('/mnt/hd1/puwenbo/Dataset/IXI/PD'):
fix = sitk.ReadImage('/mnt/hd1/puwenbo/Dataset/IXI/PD/' + patient)
# moving = sitk.ReadImage('/mnt/hd1/puwenbo/Dataset/T1T2/moving/' + patient + '/result.0.nii')
# print(patient)
print('fix shape:', sitk.GetArrayFromImage(fix).shape)
# print('moving shape:', sitk.GetArrayFromImage(moving).shape)
# print('----------------')
# size()