-
Notifications
You must be signed in to change notification settings - Fork 0
/
augment.py
48 lines (35 loc) · 1.18 KB
/
augment.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
import numpy as np
from tqdm import tqdm
import os
from scipy.ndimage import rotate
import random
from random import shuffle
import ThreeDLabeler as td
from ThreeDLabeler.images import Image
import sys
basepath = '/Users/michaeldac/Code/CUNY/698/ReducedData64/'
file_list = os.listdir(basepath)
file_list = [i for i in file_list if i.endswith('.npy')]
skulls = []
print('LOADING .npy FILES...')
for file in tqdm(file_list): # -1 because of the model
file = np.load(basepath + file, allow_pickle=True)
file = td.Image(file[0], file[1])
skulls.append(file)
#skulls = np.array(skulls)
print(f'index value type: {type(skulls[0])}')
def rotate_skulls(skulls):
skull_list = []
for i in tqdm(skulls):
skull_list.append(i.img_transformer())
skull_list = np.array(skull_list).flatten()
skull_list = np.array(skull_list)
return skull_list
augmented_skulls = rotate_skulls(skulls)
print (f'length of augmented data: {len(augmented_skulls)}')
file_path = '/Users/michaeldac/Code/CUNY/698/AugmentedData'
count = 1
for i in tqdm(augmented_skulls):
npy_file = (i.voxels, i.point_position)
np.save(f'{file_path}/skull_{count}.npy', npy_file)
count += 1