Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

NSxPowerSpectrum.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function NSxPowerSpectrum(NSx, channelNumber, colorCode)
  2. % NSxPowerSpectrum
  3. %
  4. % Plots a power spectrum of a given channel.
  5. %
  6. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  7. % Use NSxPowerSpectrum
  8. %
  9. % Use settingsManager(NSx, channelNumber, colorCode)
  10. %
  11. % NSx: The NSx file containing the data.
  12. %
  13. % channelNumber: The channel to be plotted.
  14. %
  15. % colorCode: The color of the plot. This follows the standard "plot"
  16. % colors in MATLAB. See "help plot" for more information.
  17. %
  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. % Kian Torab
  20. % support@blackrockmicro.com
  21. % Blackrock Microsystems
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % Version History
  24. %
  25. % 1.1.0.0: October 2, 2020
  26. % - Fixed a bug where the sampling frequency is now read from the header
  27. % file instead of it being fixed at 300 Hz.
  28. %
  29. % 1.1.1.0: October 23, 2020
  30. % - Fixed a small bug with double defining the function name.
  31. %
  32. if ~exist('colorCode', 'var')
  33. colorCode = 'b';
  34. end
  35. x = double(NSx.Data(channelNumber,:));
  36. rng default;
  37. Fs = NSx.MetaTags.SamplingFreq;
  38. t = linspace(0,1,length(x));
  39. N = length(x);
  40. xdft = fft(x);
  41. xdft = xdft(1:N/2+1);
  42. psdx = (1/(Fs*N)).*abs(xdft).^2;
  43. psdx(2:end-1) = 2*psdx(2:end-1);
  44. freq = 0:Fs/length(x):Fs/2;
  45. plot(freq,10*log10(psdx), colorCode); grid on;
  46. title('Periodogram Using FFT');
  47. xlabel('Frequency (Hz)'); ylabel('Power/Frequency (dB/Hz)');