forked from xingchenzhao/MixDANN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_dataset.py
More file actions
executable file
·27 lines (24 loc) · 812 Bytes
/
split_dataset.py
File metadata and controls
executable file
·27 lines (24 loc) · 812 Bytes
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
import os
import numpy as np
domain_name = 'Local'
domain_dir = 'dataset/Local'
split_path = 'path/'
patient_paths = os.listdir(domain_dir)
patient_paths.sort()
for cp in patient_paths:
current_patient = cp
cp_dir = os.path.join(domain_dir, cp)
all_subject_path = os.listdir(cp_dir)
split_dir = os.path.join(split_path, domain_name)
s = cp_dir + ' ' + str(current_patient) + '\n'
if np.random.random() < 0.8:
split_train_dir = str(split_dir) + '/train.txt'
with open(split_train_dir, 'a') as out:
out.write(s)
else:
split_val_dir = str(split_dir) + '/val.txt'
with open(split_val_dir, 'a') as out:
out.write(s)
split_test_dir = str(split_dir) + '/test.txt'
with open(split_test_dir, 'a') as out:
out.write(s)