return AF, BF


###############################################################################
# Main script 
###############################################################################

# generate the data
n_subj = 10
shape = (60, 60)
pos = np.array([[12, 14],
                [20, 20],
                [30, 20]])
ampli = np.array([5, 7, 6])
sjitter = 1.0
betas = simul.surrogate_2d_dataset(n_subj=n_subj, shape=shape, pos=pos, 
                                     ampli=ampli, width=5.0)

# set various parameters
theta = float(st.t.isf(0.01, 100))
dmax = 5. / 1.5
ths = n_subj / 4
thq = 0.9
verbose = 1
smin = 5
method = 'simple'#'loo'#'quick'#

# run the algo
AF, BF = make_bsa_2d(betas, theta, dmax, ths, thq, smin, method,
                     verbose=verbose)
#mp.show()
Exemple #2
0
    raise RuntimeError("This script needs the matplotlib library")
import matplotlib as mpl

from nipy.labs.spatial_models.hroi import HROI_from_watershed
from nipy.labs.spatial_models.discrete_domain import grid_domain_from_shape
import nipy.labs.utils.simul_multisubject_fmri_dataset as simul

###############################################################################
# data simulation

shape = (60, 60)
pos = np.array([[12, 14],
                [20, 20],
                [30, 20]])
ampli = np.array([3, 4, 4])
x = simul.surrogate_2d_dataset(n_subj=1, shape=shape, pos=pos, ampli=ampli,
                               width=10.0).squeeze()

th = 2.36

# compute the field structure and perform the watershed
domain = grid_domain_from_shape(shape)
nroi = HROI_from_watershed(domain, np.ravel(x), threshold=th)
label = nroi.label

#compute the region-based signal average
bfm = np.array([np.mean(x.ravel()[label == k]) for k in range(label.max() + 1)])
bmap = np.zeros(x.size)
if label.max() > - 1:
    bmap[label > - 1] = bfm[label[label > - 1]]

label = np.reshape(label, shape)
    plt.colorbar(shrink=.8)
    plt.savefig('bsa_results.png')

###############################################################################
# Main script
###############################################################################

# generate the data
n_subjects = 10
shape = (60, 60)
pos = np.array([[12, 14],
                [20, 20],
                [30, 20]])
ampli = np.array([5, 7, 6])
sjitter = 1.0
stats = simul.surrogate_2d_dataset(n_subj=n_subjects, shape=shape, pos=pos,
                                   ampli=ampli, width=5.0, seed=1)

# set various parameters
threshold = float(st.t.isf(0.01, 100))
sigma = 4. / 1.5
prevalence_threshold = n_subjects * .25
prevalence_pval = 0.9
smin = 5
algorithm = 'co-occurrence' #  'density'

domain = grid_domain_from_shape(shape) 

# get the functional information
stats_ = np.array([np.ravel(stats[k]) for k in range(n_subjects)]).T
    
# run the algo
Exemple #4
0
import nipy.labs.utils.simul_multisubject_fmri_dataset as simul
import nipy.labs.spatial_models.hroi as hroi
from nipy.labs.spatial_models.discrete_domain import domain_from_array

# ---------------------------------------------------------
# simulate an activation image
# ---------------------------------------------------------

dimx = 60
dimy = 60
pos = np.array([[12, 14], [20, 20], [30, 20]])
ampli = np.array([3, 4, 4])

nbvox = dimx * dimy
dataset = simul.surrogate_2d_dataset(nbsubj=1, dimx=dimx, dimy=dimy, pos=pos,
                                     ampli=ampli, width=10.0).squeeze()
values = dataset.ravel()


#-------------------------------------------------------
# Computations
#------------------------------------------------------- 

# create a domain descriptor associated with this
domain = domain_from_array(dataset ** 2 > 0)

nroi = hroi.HROI_as_discrete_domain_blobs(domain, dataset.ravel(),
                                          threshold=2.0, smin=3)
label = np.reshape(nroi.label, ((dimx, dimy)))

# create an average activaion image
import nipy.labs.utils.simul_multisubject_fmri_dataset as simul
from nipy.labs.utils.reproducibility_measures import \
     voxel_reproducibility, cluster_reproducibility, map_reproducibility,\
     peak_reproducibility
from nipy.labs.spatial_models.discrete_domain import grid_domain_from_array

###############################################################################
# Generate the data 
nsubj = 105
dimx = 60
dimy = 60
pos = np.array([[12, 14],
                [20, 20],
                [30, 20]])
ampli = np.array([2.5, 3.5, 3])
dataset = simul.surrogate_2d_dataset(nbsubj=nsubj, dimx=dimx, dimy=dimy, 
                                     pos=pos, ampli=ampli, width=5.0)
betas = np.reshape(dataset, (nsubj, dimx, dimy))

# set the variance at 1 everywhere
func = np.reshape(betas, (nsubj, dimx * dimy)).T
var = np.ones((dimx * dimy, nsubj))
domain = grid_domain_from_array(np.ones((dimx, dimy, 1)))

###############################################################################
# Run reproducibility analysis 

ngroups = 10
thresholds = np.arange(.5, 6., .5)
sigma = 2.0
csize = 10
niter = 10
Exemple #6
0
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
import numpy as np

import pylab as pl

from nipy.labs.utils.simul_multisubject_fmri_dataset import \
     surrogate_2d_dataset

pos = np.array([[10, 10],
                [14, 20],
                [23, 18]])
ampli = np.array([4, 5, 2])

# First generate some noiseless data
noiseless_data = surrogate_2d_dataset(n_subj=1, noise_level=0, spatial_jitter=0,
                                      signal_jitter=0, pos=pos, ampli=ampli)

pl.figure(figsize=(10, 3))
pl.subplot(1, 4, 1)
pl.imshow(noiseless_data[0])
pl.title('Noise-less data')

# Second, generate some group data, with default noise parameters
group_data = surrogate_2d_dataset(n_subj=3, pos=pos, ampli=ampli)

pl.subplot(1, 4, 2)
pl.imshow(group_data[0])
pl.title('Subject 1')
pl.subplot(1, 4, 3)
pl.title('Subject 2')
pl.imshow(group_data[1])