[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 https://laurentperrinet.github.io/sciblog/posts/2015-07-02_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 ...)
In [ ]:
import numpy as np
import MotionClouds as mc
ds = 2
fx, fy, ft = mc.get_grids(mc.N_X//ds, mc.N_Y//ds, mc.N_frame//ds)
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 [ ]:
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 [ ]:
# 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 [ ]:
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 [ ]:
# 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 [ ]:
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 [ ]:
# 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 [ ]:
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 [ ]:
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 [ ]:
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 [ ]:
def guess_my_orientation(N_B_theta=5, 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, N_B_theta)[::-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)