-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_noises.py
executable file
·76 lines (64 loc) · 2.96 KB
/
create_noises.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
This script creates the noise masks needed to optimize the models.
This scripts needs to be run before optimizing the models.
@author: Lynn Schmittwilken
Last update: June 2024
"""
import numpy as np
import sys
from functions import create_directory, create_noise
sys.path.append('../experiment')
from params import stim_params
# from stimulus_functions import create_whitenoise, create_pinknoise, create_narrownoise
from helper_functions import save_mask
n_masks = 50 # How many noise masks to create?
file_path = "./noise_masks/" # Where to save them?
if __name__ == "__main__":
np.random.seed(23)
sp = stim_params
stim_size = sp["stim_size"]
ppd = sp["ppd"]
rms = sp["noise_contrast"] * sp["mean_lum"]
create_directory(file_path, True)
# Create and save white noise
noise_dir = file_path + sp["noise_types"][1] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_whitenoise(size=stim_size*ppd, rms_contrast=rms)
noise = create_noise(sp["noise_types"][1], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")
# Create pink1 noise
noise_dir = file_path + sp["noise_types"][2] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_pinknoise(size=stim_size*ppd, ppd=ppd, rms_contrast=rms, exponent=1.)
noise = create_noise(sp["noise_types"][2], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")
# Create pink2 / brown noise
noise_dir = file_path + sp["noise_types"][3] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_pinknoise(size=stim_size*ppd, ppd=ppd, rms_contrast=rms, exponent=2.)
noise = create_noise(sp["noise_types"][3], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")
# Create narrowband noise with center frequency of 0.5 cpd
noise_dir = file_path + sp["noise_types"][4] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_narrownoise(size=stim_size*ppd, noisefreq=0.5, ppd=ppd, rms_contrast=rms)
noise = create_noise(sp["noise_types"][4], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")
# Create narrowband noise with center frequency of 3. cpd
noise_dir = file_path + sp["noise_types"][5] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_narrownoise(size=stim_size*ppd, noisefreq=3., ppd=ppd, rms_contrast=rms)
noise = create_noise(sp["noise_types"][5], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")
# Create narrowband noise with center frequency of 9. cpd
noise_dir = file_path + sp["noise_types"][6] + "/"
create_directory(noise_dir)
for i in range(n_masks):
# noise = create_narrownoise(size=stim_size*ppd, noisefreq=9., ppd=ppd, rms_contrast=rms)
noise = create_noise(sp["noise_types"][6], sp)
save_mask(noise, sp, noise_dir + str(i) + ".pickle")