# Calculating Marginal Hilbert Spectrum across IMFs using mhs() in MATLAB

I'm working on an EEG dataset from which I need to extract the power of five different frequency bands. I'm doing this by performing Hilbert Transform on the ICA activations from performing channel-wise ICA -- using EEGLAB -- on the data. I have created 6 IMFs per component using runemd from EMDLAB. I have copied the tail end of the code below.

The problem is when I try to implement the last line, I'm not sure what should be going into the first argument for mhs(). The documentation says the "hilbert spectrum amplitudes" but I'm not sure if that's the instantaneous energy from the IMFs or the hilbert spectrum itself or the IMFs themselves... When I run the code, the only input that works is the instantaneous frequency (imfinse), but I want to make sure I'm understanding this process correctly. I apologize, I'm not very well versed in signal processing but am picking my way through.

Any suggestions would be greatly appreciated!

%% Hilbert Huang Transform

% First step: Empirical Mode Decomposition
% This forms a matrix of Intrinsic mode functions from decomposed signals
[allmodes] = runemd(EEG.icaact); % Empirical Mode Decomposition per component
current_component_imfs = squeeze(allmodes(1,:,:)); % Get the first component

%%
% Second step: Hilbert Spectrum Analysis
% This is used to calculate the power of five freq. bands:
% Delta(1-4Hz), Theta (4-8Hz), Alpha (8-12Hz), Beta (12-30Hz),
% and Gamma (30-64Hz).
% First, we'll calculate the hilbert spectrum of the IMFs (sampling rate = 128Hz)
[hs,f,t,imfinsf,imfinse] = hht(current_component_imfs,128);
%%
% Then the marginal spectrum can be calculated by integrating the hilbert
% spectrum over time

% [A F] = mhs(???,imfinsf,0,1.0,128);



The code for Marginal Hilbert Spectrum (by Jaimie Delgado Saa) can be found here: https://www.mathworks.com/matlabcentral/fileexchange/27531-marginal-hilbert-spectrum

Thank you.