| Hello! I am a student research trying to learn your toolset, and am using s105 from OpenfMRI as my input. I feel like I have a pretty good idea of how things work, but when I reach the end of the http://www.pymvpa.org/tutorial_mappers.html tutorial, and go to export, the file I get is just a gradient. Am I doing something wrong with my reverse mapping? I have attached my python script to help with debugging. Thank you, Adrian Smith Sonoma State University smithdev.io |
import mvpa2 from mvpa2.tutorial_suite import * from os.path import join as opj from mvpa2.datasets.sources import OpenFMRIDataset
data_path = "/Users/asmith/Documents/research/fMRI/ds105_raw"
dhandle = OpenFMRIDataset(data_path)
print dhandle.get_subj_ids()
print dhandle.get_task_descriptions()
model = 1
subj = 1
run = 1
events = dhandle.get_bold_run_model(model, subj, run)
for ev in events[:2]:
print ev
print "--Ending simple tests--"
task = 1 #Object viewing
model = 1 # image stimulus category model
subj = 1
run_datasets = []
for run_id in dhandle.get_task_bold_run_ids(task)[subj]:
#load design info for this run
run_events = dhandle.get_bold_run_model(model, subj, run_id)
# load BOLD data for this run; add 0-based chunk ID
run_ds = dhandle.get_bold_run_dataset(subj, task, run_id, chunks = run_id - 1)
# Convert event info into a sample attribute and assign as 'targets'
run_ds.sa['targets'] = events2sample_attr(run_events, run_ds.sa.time_coords, noinfolabel='rest')
#Additional time setires preprocessing can go here
run_datasets.append(run_ds)
# this is PyMVPA's vstack() for merging samples from multiple datasets
# a=0 indicates that the dataset attributes of the first run should be used
# for the merged dataset
fds = vstack(run_datasets, a=0)
print fds.shape
print fds.summary()
# Detrending linearly
detrender = PolyDetrendMapper(polyord=1, chunks_attr='chunks')
detrended_fds = fds.get_mapped(detrender)
print detrended_fds.a.mapper
# Normalizing by zscore against rest condition
zscorer = ZScoreMapper(param_est=('targets', ['rest']))
zscore(detrended_fds, param_est=('targets', ['rest']))
fds = detrended_fds
print fds.a.mapper
fds = fds[fds.sa.targets != 'rest']
print fds.shape
# Computing patterns of activation
# Don't know what this really means, need to research more
rnames = {0: 'even', 1: 'odd'}
fds.sa['runtype'] = [rnames[c % 2] for c in fds.sa.chunks]
averager = mean_group_sample(['targets', 'runtype'])
print type(averager)
fds = fds.get_mapped(averager)
print fds.shape
print fds.sa.targets
print fds.sa.chunks
#Exporting with prep
print fds.a.mapper
fds.nfeatures
revdata = np.arange(100, 100 + fds.nfeatures)
rmapped = fds.a.mapper.reverse1(revdata)
print rmapped.shape
yimg = map2nifti(fds,rmapped)
nimg = map2nifti(fds, revdata)
nimg.to_filename('processed.nii.gz')
yimg.to_filename('processed.nii.gz')
_______________________________________________ Pkg-ExpPsy-PyMVPA mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa

