The module nipy.labs.utils.simul_multisubject_fmri_dataset contains a various functions to create simulated activation maps in two, three and four dimensions. A 2D example is surrogate_2d_dataset(). The functions can position various activations and add noise, both as background noise and jitter in the activation positions and amplitude.
These functions can be useful to test methods.
# 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])
pl.subplot(1, 4, 4)
pl.title('Subject 3')
pl.imshow(group_data[2])
Create surrogate (simulated) 2D activation data with spatial noise
Parameters: | n_subj: integer, optionnal :
shape=(30,30): tuple of integers, :
sk: float, optionnal :
noise_level: float, optionnal :
pos: 2D ndarray of integers, optionnal :
ampli: 1D ndarray of floats, optionnal :
spatial_jitter: float, optionnal :
signal_jitter: float, optionnal :
width: float or ndarray, optionnal :
width_jitter: float :
out_text_file: string or None, optionnal :
out_image_file: string or None, optionnal :
seed=False: int, optionnal :
|
---|---|
Returns: | dataset: 3D ndarray :
|
Create surrogate (simulated) 3D activation data with spatial noise.
Parameters: | n_subj: integer, optionnal :
shape=(20,20,20): tuple of 3 integers, :
mask=None: Nifti1Image instance, :
sk: float, optionnal :
noise_level: float, optionnal :
pos: 2D ndarray of integers, optionnal :
ampli: 1D ndarray of floats, optionnal :
spatial_jitter: float, optionnal :
signal_jitter: float, optionnal :
width: float or ndarray, optionnal :
out_text_file: string or None, optionnal :
out_image_file: string or None, optionnal :
seed=False: int, optionnal :
|
---|---|
Returns: | dataset: 3D ndarray :
|
Create surrogate (simulated) 3D activation data with spatial noise.
Parameters: | shape = (20, 20, 20): tuple of integers, :
mask=None: brifti image instance, :
n_scans: int, optional, :
n_sess: int, optional, :
dmtx: array of shape(n_scans, n_rows), :
sk: float, optionnal :
noise_level: float, optionnal :
signal_level: float, optional, :
out_image_file: string or list of strings or None, optionnal :
seed=False: int, optionnal :
|
---|---|
Returns: | dataset: a list of n_sess ndarray of shape :
|