def test_read_paradigm(): """ test that a paradigm is correctly read """ import tempfile tmpdir = tempfile.mkdtemp() for paradigm in (block_paradigm(), modulated_event_paradigm(), modulated_block_paradigm(), basic_paradigm()): csvfile = write_paradigm(paradigm, tmpdir) read_paradigm = paradigm_from_csv(csvfile) assert_true((read_paradigm['onset'] == paradigm['onset']).all())
def test_read_paradigm(): """ test that a paradigm is correctly read """ import tempfile tmpdir = tempfile.mkdtemp() for paradigm in (block_paradigm(), modulated_event_paradigm(), modulated_block_paradigm(), basic_paradigm()): csvfile = write_paradigm(paradigm, tmpdir) read_paradigm = paradigm_from_csv(csvfile) assert_true((read_paradigm["onset"] == paradigm["onset"]).all())
# This is just a flag to be able to use the same script for the plotting if False: for study in studies: voxel_fn = op.join(folder, study + '.npy') # Paradigm file paradigm_fn = op.join(folder0, 'onsets.csv') ######################################################################## # Load data and parameters n_scans = 144 t_r = 3. ys = np.load(voxel_fn) # Create design matrix frametimes = np.arange(0, n_scans * t_r, t_r) paradigm = experimental_paradigm.paradigm_from_csv(paradigm_fn) dm = design_matrix.make_design_matrix(frametimes, paradigm=paradigm) modulation = np.array(paradigm)[:, 4] # GP parameters time_offset = 10 gamma = 10. fmin_max_iter = 50 n_restarts_optimizer = 10 n_iter = 3 normalize_y = False optimize = True zeros_extremes = True # Estimation gp = SuperDuperGP(hrf_length=hrf_length, t_r=t_r, oversampling=1./dt,
'func BOLD': 'nipype_mem/*Smooth/*/swrvismot1*.nii' }) func_file = preprocessed_heroes['func BOLD'][0] anat_file = preprocessed_heroes['anat'][0] # Give the path to the paradigm heroes = datasets.load_heroes_dataset( subjects=subjects, subjects_parent_directory=os.path.join( os.path.expanduser('~/procasl_data'), 'heroes'), paths_patterns={'paradigm': 'paradigms/acquisition1/*BOLD*1b.csv'}) paradigm_file = heroes['paradigm'][0] # Read the paradigm from nistats import experimental_paradigm paradigm = experimental_paradigm.paradigm_from_csv(paradigm_file) # Create the design matrix import numpy as np import matplotlib.pyplot as plt import nibabel from nistats.design_matrix import make_design_matrix, plot_design_matrix tr = 2.5 n_scans = nibabel.load(func_file).get_data().shape[-1] frametimes = np.arange(0, n_scans * tr, tr) design_matrix = make_design_matrix(frametimes, paradigm) plot_design_matrix(design_matrix) plt.tight_layout() # Fit GLM print('Fitting a GLM')