Skip to content

Commit bd44b6b

Browse files
committed
Add mat_py_mat stuff after move
1 parent 047bda0 commit bd44b6b

9 files changed

+417
-0
lines changed

LonePSD_A_matlab_preprocessing.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%% Matlab PreProcessing - Multiple PSDs
2+
3+
% Load data
4+
load('dat/ch_dat_one.mat');
5+
6+
%% Calculate Power Spectra
7+
8+
% Calculate a power spectrum with Welch's method
9+
[psd, freqs] = pwelch(ch_dat_one, 500, [], [], s_rate);
10+
11+
% Save the power spectra out to mat files
12+
save('power_spectrum', 'freqs', 'psd');

LonePSD_B_python_fooofing.ipynb

Lines changed: 152 additions & 0 deletions
Large diffs are not rendered by default.

LonePSD_C_matlab_analysis.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%% Load and Analyze FOOOF Results in Matlab
2+
3+
% Load FOOOF results
4+
fooof_results = load('fooof_results.mat');
5+
6+
% Check out FOOOF results
7+
fooof_results
8+
9+
%% Now you can do anything you want with your FOOOF results

MultiPSD_A_matlab_preprocessing.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%% Matlab PreProcessing - Multiple PSDs
2+
3+
% Load data
4+
load('dat/ch_dat_one.mat');
5+
load('dat/ch_dat_two.mat');
6+
7+
% Combine into a multi-channel data matrix
8+
chs_dat = [ch_dat_one; ch_dat_two]';
9+
10+
%% Calculate Power Spectra
11+
12+
% Calculate power spectra with Welch's method
13+
[psds, freqs] = pwelch(chs_dat, 500, [], [], s_rate);
14+
15+
% Save the power spectra out to mat files
16+
save('power_spectra', 'freqs', 'psds');

MultiPSD_B_python_fooofing.ipynb

Lines changed: 166 additions & 0 deletions
Large diffs are not rendered by default.

MultiPSD_C_matlab_analysis.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
%% Load and Analyze FOOOF Results in Matlab
2+
3+
%% Load a specific variable that was saved out to a mat file
4+
5+
% Load slopes
6+
sls = load('slopes');
7+
8+
% Check out slopes
9+
sls
10+
11+
%% Load in FOOOF results that have been saved out - from json file
12+
13+
% Add the utils folder to path, that has the load function
14+
addpath('utils')
15+
16+
% Load the fooof-formated json file, saved out from Python
17+
fooof_results = load_fooof_results('fooof_results.json');
18+
19+
% Check out fooof_results
20+
fooof_results
21+
22+
%% Load in FOOOF results that have been saved out - from mat files
23+
24+
fooof_results = [];
25+
for ind = 0:1
26+
fooof_results = load(strcat('f_res_', string(ind)));
27+
fooof_results = [outputs, output];
28+
end
29+
30+
% Check out outputs
31+
fooof_results
32+
33+
%% Now you can do anything you want with your FOOOF results

dat/ch_dat_one.mat

210 KB
Binary file not shown.

dat/ch_dat_two.mat

215 KB
Binary file not shown.

utils/load_fooof_results.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
% load_fooof_results () - load results from a json file (as saved out by FOOOF)
2+
%
3+
% Usage:
4+
% >> fooof_results = load_fooof_results(file_name)
5+
%
6+
% Inputs:
7+
% file_name = file name of the fooof-format json file to load
8+
%
9+
% Ouputs:
10+
% fooof_results = fooof model ouputs, in a struct, including:
11+
% fooof_results.background_params
12+
% fooof_results.peak_params
13+
% fooof_results.gaussian_params
14+
% fooof_results.error
15+
% fooof_results.r_squared
16+
%
17+
% Notes
18+
% This function uses the json support added to Matlab in r2016b.
19+
20+
function fooof_results = load_fooof_results(file_name)
21+
22+
dat = importdata(file_name);
23+
24+
fooof_results = [];
25+
for ind = 1:length(dat)
26+
fooof_results = [fooof_results, jsondecode(dat{ind})];
27+
end
28+
29+
end

0 commit comments

Comments
 (0)