-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (27 loc) · 1.18 KB
/
test.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
"""
TEST
"""
import numpy as np
import mvpa2
from mvpa2.suite import *
import os
os.chdir('C:/Users/Angela Andreella/Documents/GitHub/ProMisesModel')
from ProMisesModel import ProMisesModel
#Load dataset
ds_all = h5load('C:/Users/Angela Andreella/Documents/GitHub/ProMisesModel/Data/Faces_Objects/hyperalignment_tutorial_data_2.4.hdf5.gz')
#Number of voxels to select
nf = 10
# Automatic feature selection
fselector = FixedNElementTailSelector(nf, tail='upper',mode='select', sort=False)
anova = OneWayAnova()
fscores = [anova(sd) for sd in ds_all]
featsels = [StaticFeatureSelection(fselector(fscore)) for fscore in fscores]
ds_all_fs = [fs.forward(sd) for fs, sd in zip(featsels, ds_all)]
#Compute Location Parameter as Similarity Matrix using the euclidean distance of the three dimensional coordinates of the voxels
coord = [ds.fa.voxel_indices for ds in ds_all_fs]
dist = [cdist(np.array(c), np.array(c), "euclidean") for c in coord]
Q = [np.exp(-d) for d,c in zip(dist,coord)]
#Alignment step
gp = ProMisesModel(maxIt = 10, t = 0.001, k = 1, Q = Q, ref_ds = None, scaling=True, reflection = True, subj=True)
mappers = gp.gpa(ds_all_fs)[1]
len(mappers)