Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] burst_def bug #334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions neurodsp/sim/periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,31 @@ def sim_bursty_oscillation(n_seconds, fs, freq, burst_def='prob', burst_params=N
if isinstance(burst_def, str):
check_param_options(burst_def, 'burst_def', ['prob', 'durations'])

# Consistency fix: catch old parameters, and remap into burst_params
# This preserves the prior default values, and makes the old API work the same
burst_params = {} if not burst_params else burst_params
for burst_param in ['enter_burst', 'leave_burst']:
temp = cycle_params.pop(burst_param, 0.2)
if burst_def == 'prob' and burst_param not in burst_params:
burst_params[burst_param] = temp

# Simulate a normalized cycle to use for bursts
n_seconds_cycle = compute_cycle_nseconds(freq, fs)
osc_cycle = sim_normalized_cycle(n_seconds_cycle, fs, cycle, phase=phase, **cycle_params)

# Calculate the number of cycles needed to tile the full signal
n_cycles = int(np.floor(n_seconds * freq))
if not isinstance(burst_def, np.ndarray):

# Calculate the number of cycles needed to tile the full signal
n_cycles = int(np.floor(n_seconds * freq))

# Consistency fix: catch old parameters, and remap into burst_params
# This preserves the prior default values, and makes the old API work the same
burst_params = {} if not burst_params else burst_params
for burst_param in ['enter_burst', 'leave_burst']:
temp = cycle_params.pop(burst_param, 0.2)
if burst_def == 'prob' and burst_param not in burst_params:
burst_params[burst_param] = temp

# Determine which periods will be oscillating
if isinstance(burst_def, np.ndarray):
if burst_def == 'prob':
is_oscillating = make_is_osc_prob(n_cycles, **burst_params)
elif burst_def == 'durations':
is_oscillating = make_is_osc_durations(n_cycles, **burst_params)

else:
# Determine which periods will be oscillating
is_oscillating = burst_def
elif burst_def == 'prob':
is_oscillating = make_is_osc_prob(n_cycles, **burst_params)
elif burst_def == 'durations':
is_oscillating = make_is_osc_durations(n_cycles, **burst_params)

sig = make_bursts(n_seconds, fs, is_oscillating, osc_cycle)

Expand Down
Loading