示例#1
0
 def add_chan(self):
     shape = self.source.blender.main_rgba.shape[:3]
     img = np.zeros(shape, dtype='B')
     center = np.array(shape)/2.
     vx = utils.voxel_index_list(shape) - center
     sz = np.random.randint(4, high=15)**2
     good_vx = np.where( (vx**2).sum(axis=1) < sz )[0]
     np.put(img, good_vx, 1)
     self.source.set_new_array(img, 'new_img_%d'%self.n_added, update=True)
     self.n_added += 1
示例#2
0
def gen_beam():
    # make a little offset between MEG and MRI space
    meg2mri_aff = np.eye(4)
    meg2mri_aff[:3,-1] = -5, -2.5, -2.5
    cr = beam.MEG_coreg('', '', meg2mri_aff, np.eye(3))

    # make a mapping from a 10x10x10 index grid to MEG space
    # -- each voxel edge is 2mm, and the origin is at ijk = 5,5,5
    idx2meg_aff = np.eye(4)*2
    idx2meg_aff[-1,-1] = 1
    idx2meg_aff[:3,-1] = -10,-10,-10
    cmap = ni_api.AffineTransform.from_params('ijk',
                                              beam.xipy_ras,
                                              idx2meg_aff)

    vx = cmap(voxel_index_list((10,10,10)))
    time_pts = np.arange(20)
    sig = np.random.rand(vx.shape[0], len(time_pts))
    b = beam.Beam([2.]*3, vx, 1000., time_pts, sig, cr, coordmap=cmap)
    return b
示例#3
0
def full_beam_coords(dr):
    dr = np.asarray(dr)
    vox = voxel_index_list(full_beam_volume_shape(dr))
    return (vox*dr+np.array([BEAM_SPACE_LEFT, BEAM_SPACE_POST, BEAM_SPACE_INF]))