File: example1.py

package info (click to toggle)
connectomeviewer 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 5,860 kB
  • ctags: 1,417
  • sloc: python: 6,234; makefile: 167
file content (39 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (2)
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
""" This script provides a toy example of the NBS """

import numpy as np
import cviewer.libs.pyconto.groupstatistics.nbs as nbs
from pylab import imshow, show, title

# import test data
# you need to be in the correct path when executing the script
# or enter absolute path
import scipy.io as io
Xmat = io.loadmat('X.mat')
Ymat = io.loadmat('Y.mat')
X = Xmat['X']
Y = Ymat['Y']
n = X.shape[0]

# Run the NBS with the following parameter options: 
# Set an appropriate threshold. It is difficult to provide a rule of thumb 
# to guide the choice of this threshold. Trial-and-error is always an option
# with the number of permutations generated per trial set low. 
THRESH=3

# Generate 10 permutations. Many more permutations are required in practice
# to yield a reliable estimate. 
K=10

# Set TAIL to left, and thus test the alternative hypothesis that mean of 
# population X < mean of population Y
TAIL='left'

# Run the NBS
PVAL, ADJ, NULL = nbs.compute_nbs(X,Y,THRESH,K,TAIL)

print "pval", PVAL
print "null", NULL

imshow(ADJ, interpolation='nearest')
title('Edges identified by the NBS')
show()