예제 #1
0
                                              rMin=minR,
                                              rMax=fovHeight / 2.)

# %% add gradients as a function of distance to border

aryImaOtw = np.zeros((aryImaNtr.shape))
aryImaInw = np.zeros((aryImaNtr.shape))

for indIma in range(aryImaNtr.shape[-1]):
    # get image
    inputIma = aryImaNtr[..., indIma]

    # add gradients as a function of distance to border for outward motion
    aryImaOtw[..., indIma] = getDistIma(inputIma,
                                        fovHeight=fovHeight,
                                        pix=pix,
                                        pixSlct="stimAprt",
                                        borderType="right",
                                        normalize=True)
    # add gradients as a function of distance to border for inward motion
    aryImaInw[..., indIma] = getDistIma(inputIma,
                                        fovHeight=fovHeight,
                                        pix=pix,
                                        pixSlct="stimAprt",
                                        borderType="left",
                                        normalize=True)

for indIma in range(aryImaNtr.shape[-1]):
    # get image
    inputIma = aryImaNtr[..., indIma]
    varFigName = os.path.join("/media/sf_D_DRIVE/MotDepPrf/Presentation",
                              "figures", "Figure_prfshift",
    (cfg.pix, cfg.pix)).reshape(cfg.pix, cfg.pix, 1), opaPgDnMasks),
                              axis=2)

# %% create masks for the foreground (raised cosine) and group masks for the
# foreground together (raised cosine)

opaPgUpMasks = np.empty((cfg.pix, cfg.pix, opaPgDnMasks.shape[-1]),
                        dtype='float32')
for i in range(opaPgDnMasks.shape[-1]):
    # get a single mask
    binMask = opaPgDnMasks[..., i]
    # check whether there is at least one element of 1
    if np.any(binMask == 1):
        print "image " + str(i)
        # get its distance image
        distIma = getDistIma(binMask, cfg.fovHeight, cfg.pix)
        # assign raised cosine values to bixels less than 0.5 away from border
        opaPgUpMasks[..., i] = assignBorderVals(binMask,
                                                distIma,
                                                borderRange=cfg.borderRange)
    else:
        # assign old contrast mask
        opaPgUpMasks[..., i] = binMask

# %% save masks as npz array

# restructure arrays such that if indexed with linspace, outward motion results
ouwardInd = np.arange(len(combis) / cfg.numAprtCrcle * cfg.numRep,
                      dtype='int32').reshape((-1, cfg.numRep)).T
# add 1 to account for the zero image in the begging
ouwardInd = ouwardInd.flatten() + 1