-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimulateData.py
executable file
·75 lines (64 loc) · 3.15 KB
/
simulateData.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#NOTE: The section below is copy pasted (and slightly edited the values for C1 and C2) from the NAGFS-PY, since everything is same with there.
import numpy as np
import sys
np.set_printoptions(threshold=sys.maxsize)
np.set_printoptions(suppress=True)
def simulate_data(mu1,sigma1,mu2,sigma2):
cont = True
Labels = []
X = []
#* * (2.1) Sample number of Class-1 and Class-2 and Region of Interests are chosen by user.
prompt = 'Select the number of class 1 graphs: '
C1 = int(input(prompt))
while C1=="":
prompt = 'Please choose a number: '
C1 = int(input(prompt))
while (C1 < 9):
prompt = 'Please choose a number >8: '
C1 = int(input(prompt))
#NOTE: I kept getting a ValueError stating that i cannot copy a size enough to fit an array with dimension 8, that's why I changed C1 and C2 to be 9 MINIMUM.
prompt = 'Select the number of class 2 graphs: '
C2 = int(input(prompt))
while C2=="":
prompt = 'Please choose a number: '
C2 = int(input(prompt))
while (C2 < 9):
prompt = 'Please choose a number >8: '
C2 = int(input(prompt))
prompt = 'Select the number of nodes (i.e., ROIS for brain graphs): '
m = int(input(prompt))
while (m==""):
prompt = 'Please choose a number >20: '
m = int(input(prompt))
while ((m < 21)):
prompt = 'Please choose a number >20: '
m = int(input(prompt))
# * *
# * * (2.2) Matrixes are created as chosen numbers by user before which has random numbers.(not network atlasses yet.)
N = C1 + C2 #total sample number
dataC1 = np.random.normal(mu1, sigma1, [C1, m, m])
dataC2 = np.random.normal(mu2, sigma2, [C2, m, m])
data1 = np.append(dataC1,dataC2,axis=0) #main array which include random number matrixes of both classes
# * *
# * * (2.3) Matrixes with Random numbers are converted to Connectivity Matrixes
for i in range(N):
data1[i, :, :] = data1[i, :, :] - np.diag(np.diag(data1[i,:,:])) #Removing diagonal elements of each matrixes
data1[i, :,:] = (data1[i, :,:] + data1[i, :,:].transpose())/2 #Converting each matrixes symetric connectivity matrixes
t = np.triu(data1[i,:,:]) #Taking upper triangular part of each converted matrixes
x=t[np.triu_indices(m,1)] #Creating 1xK matrixes which K is connectivity number of upper triangular part.
x1=x.transpose()
# * *
# * * (2.4) All edited datas are added new arrays and these arrays are added in main array which called Data.
if cont:
Featurematrix = np.empty((0, x1.shape[0]), int)
cont=False
Featurematrix = np.append(Featurematrix, np.array([x1]), axis=0)
#Every loop step , random matrixes fixed and updated.
X=data1
#Labels are created and added into Label array as one by one. So they correspond with datas which they belong.
Label1 = np.ones((C1, 1))
Label2 = np.ones((C2, 1))*-1
Label=np.append(Label1,Label2,axis=0)
Data=[Featurematrix,X,Label] #Feature Matrix-->Nx1xK
# * * #X--->NxMxM
return Data #Label-->Nx1x1