accuplot_mini.m 1.0 KB

1234567891011121314151617181920212223242526
  1. function [G,fAxis,showFreqs]=accuplot_mini(EEG, ch1, fs)
  2. % function for creating the Accusleep function
  3. % calls createSpectrogram.m, standardizeSR.m and processEMG.m (from Accusleep source code)
  4. EEGr=EEG';
  5. %% Accusleep
  6. epochLen=1;
  7. G = struct; % holds everything
  8. G.originalSR = fs; % EEG/EMG sampling rate
  9. G.SR = 128; % sampling rate used when calculating spectrogram and processed EMG
  10. G.epochLen = epochLen; % length of one epoch (spectrogram column) in seconds
  11. G.EEG=EEGr(ch1,:);
  12. % create spectrogram and process EMG at a standard SR (128)
  13. [spec, tAxis, fAxis] = createSpectrogram(standardizeSR(G.EEG, G.originalSR, G.SR), G.SR, G.epochLen);
  14. G.nbins = length(tAxis); % total number of time bins in the recording
  15. % get spectrogram and time axes
  16. showFreqs = find(fAxis <= 30); % only show frequencies under 30 Hz
  17. G.specTs = (1:G.nbins)*G.epochLen - G.epochLen/2; % spectrogram time axis, in seconds
  18. G.specTh = G.specTs./3600; % spectrogram time axis, in hours
  19. G.spectrogram = spec(:,showFreqs); % our EEG spectrogram
  20. end