Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of plotting all stimuli and masks
- Loading branch information
makohl2020me
committed
Apr 12, 2022
1 parent
26f2672
commit ebfb7ef
Showing
1 changed file
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
import numpy as np | ||
from os.path import dirname, join as pjoin | ||
import scipy.io as sio | ||
import matplotlib.pyplot as plt | ||
|
||
data_dir = pjoin(dirname(sio.__file__), 'matlab', 'ablage') | ||
mat_fname = pjoin(data_dir, 'grid_stimuli.mat') | ||
mat_content = sio.loadmat(mat_fname) | ||
|
||
def argyle(): | ||
argyle = mat_content['argyle'] | ||
argyle = np.array(((argyle[0])[0])[0]) | ||
#print(argyle) | ||
return argyle | ||
|
||
def argyle_control(): | ||
argyle_control = mat_content['argyle_control'] | ||
argyle_control = np.array(((argyle_control[0])[0])[0]) | ||
#print(argyle_control) | ||
return argyle_control | ||
|
||
def argyle_long(): | ||
argyle_long = mat_content['argyle_long'] | ||
argyle_long = np.array(((argyle_long[0])[0])[0]) | ||
#print(argyle_long) | ||
return argyle_long | ||
|
||
def snake(): | ||
snake = mat_content['snake'] | ||
snake = np.array(((snake[0])[0])[0]) | ||
#print(snake) | ||
return snake | ||
|
||
def snake_control(): | ||
snake_control = mat_content['snake_control'] | ||
snake_control = np.array(((snake_control[0])[0])[0]) | ||
#print(snake_control) | ||
return snake_control | ||
|
||
def koffka_adelson(): | ||
koffka_adelson = mat_content['koffka_adelson'] | ||
koffka_adelson = np.array(((koffka_adelson[0])[0])[0]) | ||
#print(koffka_adelson) | ||
return koffka_adelson | ||
|
||
def koffka_broken(): | ||
koffka_broken = mat_content['koffka_broken'] | ||
koffka_broken = np.array(((koffka_adelson[0])[0])[0]) | ||
#print(koffka_broken) | ||
return koffka_broken | ||
|
||
def koffka_connected(): | ||
koffka_connected = mat_content['koffka_connected'] | ||
koffka_connected = np.array(((koffka_connected[0])[0])[0]) | ||
#print(koffka_connected) | ||
return koffka_connected | ||
|
||
def checkassim(): | ||
checkassim = mat_content['checkassim'] | ||
checkassim = np.array(((checkassim[0])[0])[0]) | ||
#print(checkassim) | ||
return checkassim | ||
|
||
def simcon(): | ||
simcon = mat_content['simcon'] | ||
simcon = np.array(((simcon[0])[0])[0]) | ||
#print(simcon) | ||
return simcon | ||
|
||
def simcon_articulated(): | ||
simcon_articulated = mat_content['simcon_articulated'] | ||
simcon_articulated = np.array(((simcon_articulated[0])[0])[0]) | ||
#print(simcon_articulated) | ||
return simcon_articulated | ||
|
||
def white(): | ||
white = mat_content['white'] | ||
white = np.array(((white[0])[0])[0]) | ||
#print(white) | ||
return white | ||
|
||
|
||
def get_mask(arr_list, ppd, mask): | ||
target1 = arr_list[0] | ||
target2 = arr_list[1] | ||
y = target1[0] | ||
x = target1[1] | ||
mask[y][x] = 1 | ||
y = target1[2] | ||
x = target1[3] | ||
mask[y][x] = 1 | ||
|
||
x_diff = target1[3] - target1[1] +1 | ||
for i in range(x_diff): | ||
y_diff = target1[2] - target1[0] +1 | ||
for j in range(y_diff): | ||
y = target1[0] | ||
x = target1[1] | ||
mask[y+j][x+i] = 1 | ||
|
||
y = target2[0] | ||
x = target2[1] | ||
mask[y][x] = 2 | ||
y = target2[2] | ||
x = target2[3] | ||
mask[y][x] = 2 | ||
|
||
x_diff = target2[3] - target2[1] +1 | ||
for i in range(x_diff): | ||
y_diff = target2[2] - target2[0] +1 | ||
for j in range(y_diff): | ||
y = target2[0] | ||
x = target2[1] | ||
mask[y+j][x+i] = 2 | ||
|
||
plt.imshow(mask) | ||
return(mask) | ||
|
||
|
||
def ini_matrix(ppd): | ||
a = [] | ||
for i in range(ppd): | ||
a.append(np.zeros(ppd)) | ||
return(a) | ||
|
||
def ini_matrix_2(ppd): | ||
a = [] | ||
for i in range(ppd): | ||
a.append(np.zeros(25)) | ||
return(a) | ||
|
||
|
||
def get_mask_argyle(): | ||
a = mat_content['argyle'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-int(ppd/16),t2-int(ppd/16)] | ||
#arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return (get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_argyle_control(): | ||
a = mat_content['argyle_control'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_argyle_long(): | ||
a = mat_content['argyle_long'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix_2(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_snake(): | ||
a = mat_content['snake'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_snake_control(): | ||
a = mat_content['snake_control'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_koffka_adelson(): | ||
a = mat_content['koffka_adelson'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
get_mask(arr_list, ppd, mask) | ||
|
||
def get_mask_koffka_broken(): | ||
a = mat_content['koffka_broken'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_koffka_connected(): | ||
a = mat_content['koffka_connected'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_checkassim(): | ||
a = mat_content['checkassim'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_simcon(): | ||
a = mat_content['simcon'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_simcon_articulated(): | ||
a = mat_content['simcon_articulated'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
def get_mask_white(): | ||
a = mat_content['white'] | ||
t = np.array((((a[0])[0])[1])[0]) | ||
t2 = np.array((((a[0])[0])[2])[0]) | ||
arr_list = [t-1,t2-1] | ||
mask = np.array(ini_matrix(ppd)) | ||
return(get_mask(arr_list, ppd, mask)) | ||
|
||
if __name__ == '__main__': | ||
|
||
ppd = 16 | ||
|
||
# test argyle illusion | ||
plt.subplot(1,2,1) | ||
plt.imshow(argyle(), cmap='gray') | ||
plt.subplot(1,2,2) | ||
plt.imshow(get_mask_argyle(), cmap='gray') | ||
|