Skip to content

Commit

Permalink
Merge doc updates from master
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Apr 7, 2019
2 parents 4257b3f + ec5f59d commit c9583cf
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 50 deletions.
12 changes: 6 additions & 6 deletions fooof_mat/fooof.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% fooof() - Fit the FOOOF model on a neural power spectrum.
%
% Usage:
% >> fooof_results = fooof(freqs, power_spectrum, f_range, settings);
% >> fooof_results = fooof(freqs, power_spectrum, f_range, settings, return_model);
%
% Inputs:
% freqs = row vector of frequency values
Expand All @@ -14,7 +14,7 @@
% settings.peak_threshold
% settings.aperiodic_mode
% settings.verbose
% return_model = boolean of whether to return actual model, optional
% return_model = boolean of whether to return the FOOOF model fit, optional
%
% Outputs:
% fooof_results = fooof model ouputs, in a struct, including:
Expand All @@ -30,9 +30,9 @@
% fooof_results.ap_fit
%
% Notes
% Not all settings need to be set. Any settings that are not
% provided as set to default values. To run with all defaults,
% input settings as an empty struct.
% Not all settings need to be defined by the user.
% Any settings that are not provided are set to default values.
% To run with all defaults, input settings as an empty struct.

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

Expand Down Expand Up @@ -63,7 +63,7 @@
% This will default to not return model, if variable not set
if exist('return_model', 'var') && return_model

% Get the model, and add outputs to foof_results
% Get the model, and add outputs to fooof_results
model_out = fooof_get_model(fm);
for field = fieldnames(model_out)'
fooof_results.(field{1}) = model_out.(field{1});
Expand Down
6 changes: 3 additions & 3 deletions fooof_mat/fooof_check_settings.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
% settings.aperiodic_mode
% settings.verbose
%
% Returns:
% Outputs:
% settings = struct, with all settings defined:
% settings.peak_width_limts
% settings.max_n_peaks
% settings.min_peak_amplitude
% settings.peak_threshold
% settings.aperiodic_mode
% settings.verbose

%
% Notes:
% This is a helper function, probably not called directly by the user.
% Any settings not specified are set to default values
Expand All @@ -36,7 +36,7 @@
'aperiodic_mode', 'fixed', ...
'verbose', true);

% Overwrite any non-existent of nan settings with defaults
% Overwrite any non-existent or nan settings with defaults
for field = fieldnames(defaults)'
if ~isfield(settings, field) || all(isnan(settings.(field{1})))
settings.(field{1}) = defaults.(field{1});
Expand Down
6 changes: 2 additions & 4 deletions fooof_mat/fooof_get_model.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
% model_fit.ap_fit
%
% Notes
% This function is mostly an internal function, but can be called
% directly by the user if you are interacting with FOOOF objects
% directly.
% This function is mostly an internal function.
% It can be called directly by the user if you are interacting with FOOOF objects directly.

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

model_fit = struct();
Expand Down
6 changes: 4 additions & 2 deletions fooof_mat/fooof_plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
function fooof_plot(fooof_results, log_freqs)

%% Data Checking

if ~isfield(fooof_results, 'freqs')
error('FOOOF results struct does not contain model output.')
end

%% Set Up

if exist('log_freqs', 'var') && log_freqs
plt_freqs = log10(fooof_results.freqs);
else
Expand All @@ -27,17 +29,17 @@ function fooof_plot(fooof_results, log_freqs)
% Plot settings
lw = 2.5;

%% Create the Plots
%% Create the plots

figure()
hold on

% Plot the original data
data = plot(plt_freqs, fooof_results.power_spectrum, 'black');

% Plot the full model fit
model = plot(plt_freqs, fooof_results.fooofed_spectrum, 'red');


% Plot the aperiodic fit
ap_fit = plot(plt_freqs, fooof_results.ap_fit, 'b--');

Expand Down
17 changes: 9 additions & 8 deletions fooof_mat/fooof_unpack_results.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
% fooof_unpack_results() - Extract model fit results from FOOOFResults.
%
% Usage:
% >> results_out = fooof_unpack_results(fooof_results);
% >> results_out = fooof_unpack_results(results_in);
%
% Inputs:
% fooof_results = FOOOFResults object
%
% Outputs:
% results_out = fooof model results, in a struct, including:
% results_out.aperiodic_params
Expand All @@ -13,10 +14,9 @@
% results_out.error
% results_out.r_squared
%
% Notes:
% This function is mostly an internal function, and doesn't need to be
% called directly by the user - but can be if you are interacting
% directly with FOOOF objects.
% Notes
% This function is mostly an internal function.
% It can be called directly by the user if you are interacting with FOOOF objects directly.

function results_out = fooof_unpack_results(results_in)

Expand All @@ -36,10 +36,11 @@
results_out.error = ...
double(py.array.array('d', py.numpy.nditer(results_in.error)));

% Note: r_squared seems to come out as float
% It's not clear why this value is different, but doesn't seem
% to require the type casting like other (code commented below)
results_out.r_squared = results_in.r_squared;

% Note: r_squared seems to come out as float, and does not need type casting
% It is not clear why this value is different
% Just in case, the code for type casting is commented out below:
%results_out.r_squared = ...
% double(py.array.array('d', py.numpy.nditer(results_in.r_squared)));

Expand Down
6 changes: 5 additions & 1 deletion fooof_mat/fooof_version.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
% fooof_version() - Get FOOOF version information, of both Python & Wrapper.
% fooof_version() - Get FOOOF version information.
%
% Usage:
% >> fooof_version()
%
% Notes
% This function returns versions of both the installed FOOOF in Python, and of this Matlab wrapper.
% The version number of the Matlab FOOOF wrapper is defined in this function.

function fooof_version()

Expand Down
26 changes: 0 additions & 26 deletions fooof_mat/new_fooof_group.m

This file was deleted.

0 comments on commit c9583cf

Please sign in to comment.