Exemple #1
0
def save_movement(allmove, datadir):
    allmove = np.asarray(allmove).squeeze()
    dims = ("x", "y", "z")
    cols = ["trans_%s" % x for x in dims] + ["rot_%s" % x for x in dims] + ["displacement"]
    movedf = pandas.DataFrame(allmove, columns=cols)
    movedf.to_excel(os.path.join(datadir, "movement.xls"))
    np.save(os.path.join(datadir, "movement.npy"), allmove)
    regressors = []
    for tmpf, tmp in zip(cols, allmove.T):
        outf = os.path.join(datadir, tmpf)
        tmp.tofile(outf, sep="\n", format="2.5%f")
        regressors.append(outf)
    xfm.plot_movement(allmove, datadir)
    return regressors
Exemple #2
0
def save_movement(allmove, datadir):
	allmove = np.asarray(allmove).squeeze()
	dims = ('x','y','z')
	cols = ['trans_%s'%x for x in dims] + ['rot_%s'%x for x in dims] +\
		['displacement']
	movedf = pandas.DataFrame(allmove, columns=cols)
	movedf.to_excel(os.path.join(datadir, 'movement.xls'))
	np.save( os.path.join(datadir, 'movement.npy'), allmove)
	regressors = []
	for tmpf, tmp in zip(cols, allmove.T):
		outf = os.path.join(datadir, tmpf)
		tmp.tofile(outf, sep='\n', format='2.5%f')
		regressors.append(outf)
	xfm.plot_movement(allmove, datadir)
	return regressors
Exemple #3
0
        allmoved = [target]
        for movin in allf[1:3]:
            tmpaff = reg.affine_register_cc(target, movin)
            if tmpaff is None:
                continue
            displacement, translate, angles = xfm.params_from_ants(tmpaff)
            allmove.append([translate.tolist() + angles + [displacement]])
            moved = reg.apply_affine(movin, tmpaff)
            allmoved.append(moved)
        ## merge aligned into 4D
        merged_fname = os.path.join(datadir, 'aligned_4d.nii.gz')
        try:
            merged_img = ni.concat_images(allmoved)
            merged_img.to_filename(merged_fname)
        except:
            cmd = 'fslmerge -t %s '%(merged_fname) 
            cmd = cmd + ' '.join([x for x in allmoved])
            os.system(cmd)
        allmove = np.asarray(allmove).squeeze()
        dims = ('x','y','z')
        cols = ['trans_%s'%x for x in dims] + ['rot_%s'%x for x in dims] +\
                ['displacement']
        movedf = pandas.DataFrame(allmove, columns=cols)
        movedf.to_excel(os.path.join(datadir, 'movement.xls'))
        np.save( os.path.join(datadir, 'movement.npy'), allmove)
        ## create subplots
        xfm.plot_movement(allmove, datadir)