makeMotionFiles.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:DW-POSSUM 作者: marksgraham 项目源码 文件源码
def add_motion_spikes(motion_mat,frequency,severity,TR):
    time = motion_mat[:,0]
    max_translation = 5 * severity / 1000 * np.sqrt(2*np.pi)#Max translations in m, factor of sqrt(2*pi) accounts for normalisation factor in norm.pdf later on
    max_rotation = np.radians(5 * severity) *np.sqrt(2*np.pi) #Max rotation in rad
    time_blocks = np.floor(time[-1]/TR).astype(np.int32)
    for i in range(time_blocks):
        if np.random.uniform(0,1) < frequency: #Decide whether to add spike
            for j in range(1,4):
                if np.random.uniform(0,1) < 1/6:
                    motion_mat[:,j] = motion_mat[:,j] \
                    + max_translation * random.uniform(-1,1) \
                    * norm.pdf(time,loc = (i+0.5)*TR,scale = TR/5)
            for j in range(4,7):
                if np.random.uniform(0,1) < 1/6:
                    motion_mat[:,j] = motion_mat[:,j] \
                    + max_rotation * random.uniform(-1,1) \
                    * norm.pdf(time,loc = (i+0.5 + np.random.uniform(-0.25,-.25))*TR,scale = TR/5)
    return motion_mat
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号