def test_fetch_spm_multimodal(request_mocker, tmp_path): data_dir = str(tmp_path / 'spm_multimodal_fmri') os.mkdir(data_dir) subject_dir = os.path.join(data_dir, 'sub001') os.mkdir(subject_dir) os.mkdir(os.path.join(subject_dir, 'fMRI')) os.mkdir(os.path.join(subject_dir, 'sMRI')) open(os.path.join(subject_dir, 'sMRI', 'smri.img'), 'a').close() for session in [0, 1]: open( os.path.join(subject_dir, 'fMRI', 'trials_ses%i.mat' % (session + 1)), 'a').close() dir_ = os.path.join(subject_dir, 'fMRI', 'Session%d' % (session + 1)) os.mkdir(dir_) for i in range(390): open( os.path.join(dir_, 'fMETHODS-000%i-%i-01.img' % (session + 5, i)), 'a').close() dataset = func.fetch_spm_multimodal_fmri(data_dir=tmp_path) assert isinstance(dataset.anat, str) assert isinstance(dataset.func1[0], str) assert len(dataset.func1) == 390 assert isinstance(dataset.func2[0], str) assert len(dataset.func2) == 390 assert dataset.slice_order == 'descending' assert isinstance(dataset.trials_ses1, str) assert isinstance(dataset.trials_ses2, str)
Henson, R.N., Goshen-Gottstein, Y., Ganel, T., Otten, L.J., Quayle, A., Rugg, M.D. Electrophysiological and haemodynamic correlates of face perception, recognition and priming. Cereb Cortex. 2003 Jul;13(7):793-805. http://www.dx.doi.org/10.1093/cercor/13.7.793 This example takes a lot of time because the input are lists of 3D images sampled in different positions (encoded by different affine functions). """ print(__doc__) ######################################################################### # Fetch the SPM multimodal_faces data. from nilearn.datasets.func import fetch_spm_multimodal_fmri subject_data = fetch_spm_multimodal_fmri() ######################################################################### # Specfiy timing and design matrix parameters. tr = 2. # repetition time, in seconds slice_time_ref = 0. # we will sample the design matrix at the beggining of each acquisition drift_model = 'Cosine' # We use a discrete cosine transform to model signal drifts. high_pass = .01 # The cutoff for the drift model is 0.01 Hz. hrf_model = 'spm + derivative' # The hemodynamic response function is the SPM canonical one. ######################################################################### # Resample the images. # # This is achieved by the concat_imgs function of Nilearn. from nilearn.image import concat_imgs, resample_img, mean_img fmri_img = [