Skip to content

Commit 4257b3f

Browse files
committed
Update naming background -> aperiodic
1 parent cb8b553 commit 4257b3f

File tree

7 files changed

+52
-52
lines changed

7 files changed

+52
-52
lines changed

fooof_mat/fooof.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
% settings.max_n_peaks
1313
% settings.min_peak_amplitude
1414
% settings.peak_threshold
15-
% settings.background_mode
15+
% settings.aperiodic_mode
1616
% settings.verbose
17-
% return_model = boolean of whether to return actual model, optional
17+
% return_model = boolean of whether to return actual model, optional
1818
%
1919
% Outputs:
2020
% fooof_results = fooof model ouputs, in a struct, including:
21-
% fooof_results.background_params
21+
% fooof_results.aperiodic_params
2222
% fooof_results.peak_params
2323
% fooof_results.gaussian_params
2424
% fooof_results.error
@@ -27,12 +27,12 @@
2727
% fooof_results.freqs
2828
% fooof_results.power_spectrum
2929
% fooof_results.fooofed_spectrum
30-
% fooof_results.bg_fit
30+
% fooof_results.ap_fit
3131
%
3232
% Notes
33-
% Not all settings need to be set. Any settings that are not
34-
% provided as set to default values. To run with all defaults,
35-
% input settings as an empty struct.
33+
% Not all settings need to be set. Any settings that are not
34+
% provided as set to default values. To run with all defaults,
35+
% input settings as an empty struct.
3636

3737
function fooof_results = fooof(freqs, power_spectrum, f_range, settings, return_model)
3838

@@ -43,32 +43,32 @@
4343
freqs = py.numpy.array(freqs);
4444
power_spectrum = py.numpy.array(power_spectrum);
4545
f_range = py.list(f_range);
46-
46+
4747
% Initialize FOOOF object
4848
fm = py.fooof.FOOOF(settings.peak_width_limits, ...
4949
settings.max_n_peaks, ...
5050
settings.min_peak_amplitude, ...
5151
settings.peak_threshold, ...
52-
settings.background_mode, ...
52+
settings.aperiodic_mode, ...
5353
settings.verbose);
54-
54+
5555
% Run FOOOF fit
5656
fm.fit(freqs, power_spectrum, f_range)
5757

5858
% Extract outputs
5959
fooof_results = fm.get_results();
6060
fooof_results = fooof_unpack_results(fooof_results);
61-
61+
6262
% Also return the actual model fit, if requested
6363
% This will default to not return model, if variable not set
6464
if exist('return_model', 'var') && return_model
65-
65+
6666
% Get the model, and add outputs to foof_results
6767
model_out = fooof_get_model(fm);
6868
for field = fieldnames(model_out)'
6969
fooof_results.(field{1}) = model_out.(field{1});
7070
end
71-
71+
7272
end
73-
73+
7474
end

fooof_mat/fooof_check_settings.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
% settings.max_n_peaks
1010
% settings.min_peak_amplitude
1111
% settings.peak_threshold
12-
% settings.background_mode
12+
% settings.aperiodic_mode
1313
% settings.verbose
1414
%
1515
% Returns:
@@ -18,11 +18,11 @@
1818
% settings.max_n_peaks
1919
% settings.min_peak_amplitude
2020
% settings.peak_threshold
21-
% settings.background_mode
21+
% settings.aperiodic_mode
2222
% settings.verbose
2323

2424
% Notes:
25-
% This is a helper function, probably not called directly by the user.
25+
% This is a helper function, probably not called directly by the user.
2626
% Any settings not specified are set to default values
2727

2828
function settings = fooof_check_settings(settings)
@@ -33,9 +33,9 @@
3333
'max_n_peaks', Inf, ...
3434
'min_peak_amplitude', 0.0, ...
3535
'peak_threshold', 2.0, ...
36-
'background_mode', 'fixed', ...
36+
'aperiodic_mode', 'fixed', ...
3737
'verbose', true);
38-
38+
3939
% Overwrite any non-existent of nan settings with defaults
4040
for field = fieldnames(defaults)'
4141
if ~isfield(settings, field) || all(isnan(settings.(field{1})))

fooof_mat/fooof_get_model.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
% model_fit.freqs
1212
% model_fit.power_spectrum
1313
% model_fit.fooofed_spectrum
14-
% model_fit.bg_fit
14+
% model_fit.ap_fit
1515
%
1616
% Notes
17-
% This function is mostly an internal function, but can be called
17+
% This function is mostly an internal function, but can be called
1818
% directly by the user if you are interacting with FOOOF objects
19-
% directly.
19+
% directly.
2020

2121
% Get the actual fit model from a FOOOF object
2222
function model_fit = fooof_get_model(fm)
2323

2424
model_fit = struct();
25-
25+
2626
model_fit.freqs = double(py.array.array('d',fm.freqs));
2727
model_fit.power_spectrum = double(py.array.array('d', fm.power_spectrum));
2828
model_fit.fooofed_spectrum = double(py.array.array('d', fm.fooofed_spectrum_));
29-
model_fit.bg_fit = double(py.array.array('d', py.getattr(fm, '_bg_fit')));
29+
model_fit.ap_fit = double(py.array.array('d', py.getattr(fm, '_ap_fit')));

fooof_mat/fooof_group.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
% settings.max_n_peaks
1313
% settings.min_peak_amplitude
1414
% settings.peak_threshold
15-
% settings.background_mode
15+
% settings.aperiodic_mode
1616
% settings.verbose
1717
%
1818
% Outputs:
1919
% fooof_results = fooof model ouputs, in a struct, including:
20-
% fooof_results.background_params
20+
% fooof_results.aperiodic_params
2121
% fooof_results.peak_params
2222
% fooof_results.gaussian_params
2323
% fooof_results.error

fooof_mat/fooof_plot.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,37 @@ function fooof_plot(fooof_results, log_freqs)
2323
else
2424
plt_freqs = fooof_results.freqs;
2525
end
26-
26+
2727
% Plot settings
2828
lw = 2.5;
29-
29+
3030
%% Create the Plots
31-
31+
3232
figure()
3333
hold on
3434
% Plot the original data
3535
data = plot(plt_freqs, fooof_results.power_spectrum, 'black');
36-
36+
3737
% Plot the full model fit
3838
model = plot(plt_freqs, fooof_results.fooofed_spectrum, 'red');
3939

40-
41-
% Plot the background fit
42-
bg_fit = plot(plt_freqs, fooof_results.bg_fit, 'b--');
43-
40+
41+
% Plot the aperiodic fit
42+
ap_fit = plot(plt_freqs, fooof_results.ap_fit, 'b--');
43+
4444
%% Plot Settings
45-
45+
4646
% Apply general plot settings
47-
for plt = [data, model, bg_fit]
47+
for plt = [data, model, ap_fit]
4848
set(plt, 'LineWidth', lw);
49-
49+
5050
% Set alpha value for model - in a wonky way, because Matlab
51-
% Note: the '4' is magical and mysterious. No idea.
51+
% Note: the '4' is magical and mysterious. No idea.
5252
model.Color(4) = 0.5;
53-
53+
5454
grid on
5555
legend('Original Spectrum', 'Full Model Fit', 'Aperiodic Fit')
56-
56+
5757
hold off
5858

5959
end

fooof_mat/fooof_unpack_results.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
% fooof_results = FOOOFResults object
88
% Outputs:
99
% results_out = fooof model results, in a struct, including:
10-
% results_out.background_params
10+
% results_out.aperiodic_params
1111
% results_out.peak_params
1212
% results_out.gaussian_params
1313
% results_out.error
@@ -16,31 +16,31 @@
1616
% Notes:
1717
% This function is mostly an internal function, and doesn't need to be
1818
% called directly by the user - but can be if you are interacting
19-
% directly with FOOOF objects.
19+
% directly with FOOOF objects.
2020

2121
function results_out = fooof_unpack_results(results_in)
2222

2323
results_out = struct();
2424

25-
results_out.background_params = ...
26-
double(py.array.array('d', results_in.background_params));
27-
25+
results_out.aperiodic_params = ...
26+
double(py.array.array('d', results_in.aperiodic_params));
27+
2828
temp = double(py.array.array('d', results_in.peak_params.ravel));
2929
results_out.peak_params = ...
3030
transpose(reshape(temp, 3, length(temp) / 3));
31-
31+
3232
temp = double(py.array.array('d', results_in.gaussian_params.ravel));
3333
results_out.gaussian_params = ...
3434
transpose(reshape(temp, 3, length(temp) / 3));
35-
35+
3636
results_out.error = ...
3737
double(py.array.array('d', py.numpy.nditer(results_in.error)));
38-
38+
3939
% Note: r_squared seems to come out as float
4040
% It's not clear why this value is different, but doesn't seem
4141
% to require the type casting like other (code commented below)
4242
results_out.r_squared = results_in.r_squared;
4343
%results_out.r_squared = ...
4444
% double(py.array.array('d', py.numpy.nditer(results_in.r_squared)));
45-
45+
4646
end

fooof_mat/new_fooof_group.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
freqs = py.numpy.array(freqs);
1414
psds = py.numpy.array(psds);
1515
f_range = py.list(f_range);
16-
16+
1717
% Initialize FOOOF object
1818
fg = py.fooof.FOOOFGroup(settings.peak_width_limits, ...
1919
settings.max_n_peaks, ...
2020
settings.min_peak_amplitude, ...
2121
settings.peak_threshold, ...
22-
settings.background_mode, ...
22+
settings.aperiodic_mode, ...
2323
settings.verbose);
2424
fg.fit(freqs, psds, f_range)
25-
25+
2626
out = 1

0 commit comments

Comments
 (0)