Skip to content

Commit

Permalink
refactor: separate params-permutation and stimspace-stim-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken authored and JorisVincent committed May 10, 2023
1 parent 35aae7e commit ae20b4d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions stimupy/utils/utils.py
Expand Up @@ -18,7 +18,8 @@
"flip_dict",
"roll_dict",
"strip_dict",
"generate_stimspace",
"permutate_params",
"create_stimspace_stimuli",
]


Expand Down Expand Up @@ -439,16 +440,20 @@ def strip_dict(
return new_dict


def generate_stimspace(stimulus_function, params, title_params=None):
if not callable(stimulus_function):
raise ValueError("stimulus_function needs to be a function")
def permutate_params(params):
if not isinstance(params, dict):
raise ValueError("params needs to be a dict with all stimulus parameters")
if isinstance(title_params, str):
title_params = [title_params, ]

keys, values = zip(*params.items())
permutations_dicts = [dict(zip(keys, v)) for v in itertools.product(*values)]
return permutations_dicts


def create_stimspace_stimuli(stimulus_function, permutations_dicts, title_params=None):
if not callable(stimulus_function):
raise ValueError("stimulus_function needs to be a function")
if isinstance(title_params, str):
title_params = [title_params, ]

stimuli = {}
for i, p in enumerate(permutations_dicts):
Expand Down

0 comments on commit ae20b4d

Please sign in to comment.