2014-06-18 [Stage M1] Chloé Pasturel : week 3

Travail sur les Motion Clouds et observation des différents changement de paramètre particulièrement B_sf

  • introduction aux motions clouds: installation et display dans un notebook
  • synthèse de clouds avec différents theta
  • synthèse avec différents B_theta (V=0)
  • utilisation du trick dans http://motionclouds.invibe.net/posts/smooth-transition-between-mcs.html pour créer un stimulus pour lequel l'orientation tourne de 0 à 2*pi
  • proposer une façon simple de passer de ce signal à une entré pour le ring (un peu de maths? un MC est une texture définie en fourier, une cellule simple fait une convolution dans l'espace, donc une multiplication dans Fourier: on pourrait avoir la sortie linéaire du neurone de V1 directement ...)

http://neuralensemble.github.io/MotionClouds/

http://invibe.net/LaurentPerrinet/TagMotionClouds

In [1]:
import numpy as np
import MotionClouds as mc
#mc.MAYAVI = 'on en veut pas'
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)
figpath = mc.figpath = '../files/2014-06-18-stage-m1-chloe-pasturel-week-3/'
name = 'B_theta'
theta =  np.pi/4
B_theta = np.pi/10
mc1 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta)
name_ = name + '_' + str(B_theta).replace('.', '_')
mc.figures(mc1, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [2]:
B_theta =  np.pi
mc2 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta)
name_ = name + '_' + str(B_theta).replace('.', '_')
mc.figures(mc2, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [3]:
# Demonstration of studying the role of speed bandwidth using MotionClouds.

name = 'B_V'

theta, B_theta = np.pi/2., np.pi/32
seed=12234565

B_V = 0.01
mc1 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_V=B_V, B_theta=B_theta)

name_ = name + '_' + str(B_V).replace('.', '_')
mc.figures(mc1, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [4]:
B_V = 20.
mc2 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_V=B_V, B_theta=B_theta)
name_ = name + '_' + str(B_V).replace('.', '_')
mc.figures(mc2, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [5]:
# Demonstration of studying the role of horizontal speed component using MotionClouds.

name = 'V_X'

theta, B_theta = np.pi/4., np.pi/32
B_V = 10.
seed=12234565

V_X=0.
mc1 = mc.envelope_gabor(fx, fy, ft, V_X=V_X, V_Y=0., theta=theta, B_V=B_V, B_theta=B_theta)
name_ = name + '_' + str(V_X).replace('.', '_')
mc.figures(mc1, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [6]:
V_X=8.
mc2 = mc.envelope_gabor(fx, fy, ft, V_X=8., V_Y=0., theta=theta, B_V=B_V, B_theta=B_theta)
name_ = name + '_' + str(V_X).replace('.', '_')
mc.figures(mc2, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [7]:
# Demonstration of studying the role of vertical speed component using MotionClouds.

name = 'V_Y'

theta, B_theta = np.pi/4., np.pi/32
B_V = 1.
seed=12234565

V_Y=0.
mc1 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=V_Y, theta=theta, B_V=B_V, B_theta=B_theta)

name_ = name + '_' + str(V_Y).replace('.', '_')
mc.figures(mc1, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [8]:
V_Y=8.
mc2 = mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=V_Y, theta=theta, B_V=B_V, B_theta=B_theta)
mc.figures(mc2, name_, figpath=figpath)
mc.in_show_video(name_, figpath=figpath)
In [9]:
import os

name = 'B_theta-smooth'

fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)

theta = 2*np.pi*np.random.rand()
seed = 123456
B_theta_ = np.pi * 2**np.linspace(-5, 0, 9)[::-1]
B_theta_ = np.concatenate((B_theta_, B_theta_[:-1][::-1]))
im = np.empty(shape=(mc.N_X, mc.N_Y, 0))
if mc.check_if_anim_exist(name_):
    for i_, B_theta in enumerate(B_theta_):
        im_new = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta), seed=seed)
        im = np.concatenate((im, im_new), axis=-1)
    mc.anim_save(mc.rectif(im), os.path.join(figpath, name))
mc.in_show_video(name_, figpath=figpath)    
In [10]:
name = 'B_theta-smoother'
if mc.check_if_anim_exist(name):
    smooth = (ft - ft.min())/(ft.max() - ft.min()) # smoothly progress from 0. to 1.
    N = len(B_theta_)
    im = np.empty(shape=(mc.N_X, mc.N_Y, 0))
    for i_, B_theta in enumerate(B_theta_):
        im_old = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta), seed=seed)
        im_new = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta_[(i_+1) % N]), seed=seed)
        im = np.concatenate((im, (1.-smooth)*im_old+smooth*im_new), axis=-1)
    mc.anim_save(mc.rectif(im),os.path.join(figpath, name))
mc.in_show_video(name_, figpath=figpath)
In [11]:
def guess_my_orientation(seed=None, figpath=figpath):
    np.random.seed(seed=seed)
    theta = 2*np.pi*np.random.rand()
    seed = 123456
    B_theta_ = np.pi * 2**np.linspace(-5, 0, 9)[::-1]
    B_theta_ = np.concatenate((B_theta_, B_theta_[:-1][::-1]))

    im = np.empty(shape=(mc.N_X, mc.N_Y, 0))
    name_ = 'guess_theta_' + str(theta).replace('.', '_')
    if mc.check_if_anim_exist(name_):
        smooth = (ft - ft.min())/(ft.max() - ft.min()) # smoothly progress from 0. to 1.
        N = len(B_theta_)
        im = np.empty(shape=(mc.N_X, mc.N_Y, 0))
        for i_, B_theta in enumerate(B_theta_):
            im_old = mc.rectif(mc.random_cloud(mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta), seed=seed))
            im_new = mc.rectif(mc.random_cloud(mc.envelope_gabor(fx, fy, ft, V_X=0., V_Y=0., theta=theta, B_theta=B_theta_[(i_+1) % N]), seed=seed))
            im = np.concatenate((im, (1.-smooth)*im_old+smooth*im_new), axis=-1)
        mc.anim_save(mc.rectif(im), os.path.join(figpath, name_))
    return name_
    
for seed in [42, 1973, 2016]:
    name_ = guess_my_orientation(seed=seed, figpath=figpath)
    mc.in_show_video(name_, figpath=figpath)

Comments

Comments powered by Disqus