-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_finalData.py
34 lines (24 loc) · 1.05 KB
/
create_finalData.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
import os
import numpy as np
imgs_path = r"C:/Users/Windows/Desktop/ZYZ/BraTS/BraTS2020/data/preprocessed data/image/"
masks_path = r"C:/Users/Windows/Desktop/ZYZ/BraTS/BraTS2020/data/preprocessed data/mask/"
finalImg_savePath = r"C:/Users/Windows/Desktop/ZYZ/BraTS/BraTS2020/data/preprocessed data/"
finalMask_savePath = r"C:/Users/Windows/Desktop/ZYZ/BraTS/BraTS2020/data/preprocessed data/"
imgs_list = os.listdir(imgs_path)
masks_list = os.listdir(masks_path)
final_array = []
final_mask = []
for img in imgs_list:
img_name = imgs_path + img
img_array = np.load(img_name)
final_array.append(img_array)
print("the image:", img, "is appended")
finalImg_saveName = finalImg_savePath + "finalImage.npy"
np.save(finalImg_saveName, final_array)
for mask in masks_list:
mask_name = masks_path + mask
mask_array = np.load(mask_name)
final_mask.append(mask_array)
print("the image:", mask, "is appended")
finalMask_saveName = finalMask_savePath + "finalMask.npy"
np.save(finalMask_saveName, final_mask)