Skip to content

Commit

Permalink
fix: aligned function args and output_dict keys
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnSchmittwilken committed May 16, 2023
1 parent e054d55 commit 6981318
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 5 deletions.
2 changes: 2 additions & 0 deletions stimupy/stimuli/gabors.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ def gabor(
)
mean_int = (intensity_bars[0] + intensity_bars[1]) / 2
stim["img"] = (stim["img"] - mean_int) * gaussian_window["img"] + mean_int
del stim["intensities"]

return {
**stim,
"sigma": sigma,
"gaussian_mask": gaussian_window["gaussian_mask"],
"intensity_bars": intensity_bars,
}


Expand Down
7 changes: 7 additions & 0 deletions stimupy/stimuli/mueller_lyers.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ def mueller_lyer(
target_line["line_mask"] = np.where(target_line["line_mask"] > 5, 5, target_line["line_mask"])

target_line["target_mask"] = np.where(target_line["line_mask"] == 1, 1, 0).astype(int)
target_line["outer_lines_length"] = outer_lines_length
target_line["outer_lines_angle"] = outer_lines_angle
target_line["target_length"] = target_length
target_line["line_width"] = line_width
target_line["intensity_outer_lines"] = intensity_outer_lines
target_line["intensity_target"] = intensity_target
target_line["intensity_background"] = intensity_background
return target_line


Expand Down
6 changes: 6 additions & 0 deletions stimupy/stimuli/pinwheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def pinwheel(
intensity_segments=intensity_segments,
)
radius = min(stim["visual_size"]) / 2

stim["target_indices"] = target_indices
stim["target_center"] = target_center
stim["target_width"] = target_width
stim["intensity_target"] = intensity_target

circle_mask = circle(
visual_size=visual_size,
Expand Down Expand Up @@ -163,6 +168,7 @@ def pinwheel(
target_mask = np.where(condition1 & condition2, target_idx + 1, target_mask)
stim["img"] = np.where(target_mask == (target_idx + 1), intensity, stim["img"])
stim["target_mask"] = target_mask
stim["intensity_background"] = intensity_background
return stim


Expand Down
45 changes: 42 additions & 3 deletions stimupy/stimuli/plaids.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,20 @@ def gabors(
grating1 = gabors_stim.gabor(**gabor_parameters1)
grating2 = gabors_stim.gabor(**gabor_parameters2)
plaid = add_waves(grating1, grating2, weight1, weight2)
return plaid

out = {
"img": plaid["img"],
"grating_mask1": plaid["grating_mask"],
"grating_mask2": plaid["grating_mask2"],
"gabor_parameters1": gabor_parameters1,
"gabor_parameters2": gabor_parameters2,
"weight1": weight1,
"weight2": weight2,
"visual_size": plaid["visual_size"],
"shape": plaid["shape"],
"ppd": plaid["ppd"],
}
return out


def sine_waves(
Expand Down Expand Up @@ -120,7 +133,20 @@ def sine_waves(
grating1 = waves.sine_linear(**grating_parameters1)
grating2 = waves.sine_linear(**grating_parameters2)
plaid = add_waves(grating1, grating2, weight1, weight2)
return plaid

out = {
"img": plaid["img"],
"grating_mask1": plaid["grating_mask"],
"grating_mask2": plaid["grating_mask2"],
"grating_parameters1": grating_parameters1,
"grating_parameters2": grating_parameters2,
"weight1": weight1,
"weight2": weight2,
"visual_size": plaid["visual_size"],
"shape": plaid["shape"],
"ppd": plaid["ppd"],
}
return out


def square_waves(
Expand Down Expand Up @@ -154,7 +180,20 @@ def square_waves(
grating1 = waves.square_linear(**grating_parameters1)
grating2 = waves.square_linear(**grating_parameters2)
plaid = add_waves(grating1, grating2, weight1, weight2)
return plaid

out = {
"img": plaid["img"],
"grating_mask1": plaid["grating_mask"],
"grating_mask2": plaid["grating_mask2"],
"grating_parameters1": grating_parameters1,
"grating_parameters2": grating_parameters2,
"weight1": weight1,
"weight2": weight2,
"visual_size": plaid["visual_size"],
"shape": plaid["shape"],
"ppd": plaid["ppd"],
}
return out


def overview(**kwargs):
Expand Down
19 changes: 18 additions & 1 deletion stimupy/stimuli/ponzos.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,24 @@ def ponzo(
line1["img"] += line3["img"] + line4["img"] + intensity_background
line1["line_mask"] += line3["line_mask"] * 3 + line4["line_mask"] * 4
line1["target_mask"] = line3["line_mask"] + line4["line_mask"] * 2
return line1

stim = {}
stim["img"] = line1["img"]
stim["line_mask"] = line1["line_mask"]
stim["target_mask"] = line1["target_mask"]
stim["visual_size"] = line1["visual_size"]
stim["shape"] = line1["shape"]
stim["ppd"] = line1["ppd"]
stim["outer_lines_length"] = outer_lines_length
stim["outer_lines_width"] = outer_lines_width
stim["outer_lines_angle"] = outer_lines_angle
stim["target_lines_length"] = target_lines_length
stim["target_lines_width"] = target_lines_width
stim["target_distance"] = target_distance
stim["intensity_outer_lines"] = intensity_outer_lines
stim["intensity_target_lines"] = intensity_target_lines
stim["intensity_background"] = intensity_background
return stim


def overview(**kwargs):
Expand Down
3 changes: 3 additions & 0 deletions stimupy/stimuli/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def circular_two_sided(
stim = stack_dicts(stim1, stim2)
stim["shape"] = shape
stim["visual_size"] = visual_size
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -195,6 +196,7 @@ def rectangular_generalized(
origin=origin,
rotation=rotation,
)
stim["intensity_target"] = intensity_target

# Resolve target parameters
if isinstance(target_indices, (int)):
Expand All @@ -217,6 +219,7 @@ def rectangular_generalized(

# Update and return stimulus
stim["target_mask"] = targets_mask
stim["target_indices"] = target_indices
return stim


Expand Down
38 changes: 37 additions & 1 deletion stimupy/stimuli/waves.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def sine_linear(
# Add targets(?)
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)


stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
return stim


Expand Down Expand Up @@ -252,6 +254,8 @@ def square_linear(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
return stim


Expand Down Expand Up @@ -358,6 +362,8 @@ def staircase_linear(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
return stim


Expand Down Expand Up @@ -477,6 +483,10 @@ def sine_radial(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -596,6 +606,10 @@ def square_radial(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -716,6 +730,10 @@ def staircase_radial(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -843,6 +861,10 @@ def sine_rectilinear(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -971,6 +993,10 @@ def square_rectilinear(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -1101,6 +1127,10 @@ def staircase_rectilinear(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
stim["clip"] = clip
stim["intensity_background"] = intensity_background
return stim


Expand Down Expand Up @@ -1197,6 +1227,8 @@ def sine_angular(
stim["n_segments"] = stim.pop("n_phases")
stim["segment_width"] = stim.pop("phase_width")
stim.pop("distance_metric")
stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target

# Resolve target parameters
if target_indices is not None and target_indices != ():
Expand Down Expand Up @@ -1319,6 +1351,8 @@ def square_angular(
stim["segment_width"] = stim.pop("phase_width")
stim["intensity_segments"] = stim.pop("intensities")
stim.pop("distance_metric")
stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target

# Resolve target parameters
if target_indices is not None and target_indices != ():
Expand Down Expand Up @@ -1444,6 +1478,8 @@ def staircase_angular(
if target_indices is not None and target_indices != ():
stim = add_targets(stim, target_indices=target_indices, intensity_target=intensity_target)

stim["target_indices"] = target_indices
stim["intensity_target"] = intensity_target
return stim


Expand Down

0 comments on commit 6981318

Please sign in to comment.