mellinger wrote: 29 Apr 2024, 09:51
I'm not very proficient in Matlab myself, but this may help (not tested):
Code: Select all
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = size(signal, 1); % Length of signal
t = (0:L-1)*T; % Time vector
X = double(signal),
plot(1000*t,X)
title('EEG signal')
xlabel('t (milliseconds)')
ylabel('X(t)')
Y = fft(X);
plot(Fs/L*(0:L-1),abs(Y),'LineWidth',0.01)
title('Complex Magnitude of fft Spectrum')
xlabel('f (Hz)')
ylabel('|fft(X)|')
Thanks. Using the included testdata.dat in the mex directory using your codes above. It shows FFT output in the following:
The mirror image can be fixed according to the Matlab FFT help page:
https://www.mathworks.com/help/matlab/ref/fft.html
However, when I used my own saved dat file (eegdata.dat) The FFT display is blank using your codes.
Any idea why my saved dat file produced blank FFT and signal that is in the 6600 range instead of the 0 ? I tried 2 saved BCI2000 files with different length (saved with the same gUSBamp). Same blank output. The following is exactly the parameter I used when loading BCI2000 launcher:
Visualize:Property%20Sets matrix VisPropertySets= 0 1 // row titles are properties in the form "SRCD.Left", columns are property sets
System:Version matrix OperatorVersion= { Framework Revision Build Config Protocol } 1 3.6.7385 7385,%202023-05-28T15:26:16Z MSVC-19.33.31629.0-AMD64,%20release,%202023-05-30T17:03:19Z,%20brunnerlab@DESKTOP-3EM2F9K USE_DYNAMIC_CRT:TRUE%20USE_OPENMP:ON%20USE_PRECOMPILED_HEADERS:ON%20USE_ASSERTS_IN_RELEASE_BUILDS:OFF 2.3 // operator module version information (noedit)(readonly)
System:Protocol int AutoConfig= 1 1 0 1 // Use AutoConfig protocol extension (boolean)
System:Protocol int OperatorBackLink= 1 1 0 1 // Send final state and signal information to Operator (boolean)
System:Core%20Connections string OperatorIP= 127.0.0.1 127.0.0.1 % % // the Operator module's IP (noedit)(readonly)
Source:Signal%20Properties int SourceCh= 1 // number of digitized and stored channels (allow_override)
Source:Signal%20Properties int SampleBlockSize= 50 // number of samples transmitted at a time (allow_override)
Source:Signal%20Properties int SamplingRate= 4800 // sampling rate (allow_override)
Source:Signal%20Properties list ChannelNames= 0 // list of channel names (allow_override)
Source:Signal%20Properties list SourceChOffset= 1 0 // Offset for channels in A/D units (allow_override)
Source:Signal%20Properties list SourceChGain= 1 1 // gain for each channel (A/D units per physical unit) (allow_override)
Storage:Data%20Location string DataDirectory= ../data ..\data % % // path to top level data directory (directory)
Storage:Session string SubjectName= test Name % % // subject alias
Storage:Session string SubjectSession= 001 001 % % // three-digit session number
Storage:Session string SubjectRun= 00 00 % % // two-digit run number
Storage:Documentation string ID_System= % // BCI2000 System Code
Storage:Documentation string ID_Amp= % // BCI2000 Amp Code
Storage:Documentation string ID_Montage= % // BCI2000 Cap Montage Code
Visualize:Timing int VisualizeTiming= 1 1 0 1 // visualize system timing (0=no, 1=yes) (boolean)
Visualize:Source%20Signal int VisualizeSource= 1 1 0 1 // visualize raw brain signal (0=no, 1=yes) (boolean)
Visualize:Source%20Signal int VisualizeSourceDecimation= 1 auto % % // decimation factor for raw brain signal
Visualize:Source%20Signal int VisualizeSourceBufferSize= auto auto % % // number of blocks to aggregate before sending to operator
Visualize:Source%20Signal int VisualizeSourceTime= 2s 8s 0 % // how much time in Source visualization
Visualize:Source%20Signal int SourceMin= auto // raw signal vis Min Value
Visualize:Source%20Signal int SourceMax= auto // raw signal vis Max Value
Source:gUSBamp int AcquisitionMode= 0 0 0 2 // data acquisition mode: 0: analog signal acquisition, 1: calibration signal, 2: impedance measurement (enumeration)
Source:gUSBamp int CommonGround= 1 0 0 1 // internally connect GNDs from all blocks: 0: false, 1: true (enumeration)
Source:gUSBamp int CommonReference= 1 0 0 1 // internally connect Refs from all blocks: 0: false, 1: true (enumeration)
Source:gUSBamp int EnableDigitalInput= 0 0 0 1 // enable digital inputs (boolean)
Source:gUSBamp int EnableDigitalOutput= 0 0 0 3 // enable digital output on block acquisition: 0: off, 1: use expressions %28after signal acquisition%29, 2: timing test, 3: use expressions %28before signal acquisition%29 (enumeration)
Source:gUSBamp matrix DigitalOutputEx= 1 1 % // Matrix of Expressions for digital output
Source:gUSBamp int DetectDataLoss= 0 0 0 1 // use gUSBamp counter mode to detect data loss (boolean)
Source:gUSBamp int NumBuffers= 2 5 2 % // IO queue length
Source:Buffering int SourceBufferSize= 2s 2s % % // size of data acquisition ring buffer (in blocks or seconds)
Source:gUSBamp list DeviceIDs= 1 auto // list of USBamps to be used (or auto)
Source:gUSBamp string DeviceIDMaster= auto // deviceID for the device whose SYNC goes to the slaves
Source:gUSBamp intlist SourceChList= 1 auto // list of channels to digitize, in terms of physical inputs numbered across all devices
Source:gUSBamp intlist SourceChDevices= 1 1 // number of digitized channels per device
Source:gUSBamp int FilterEnabled= 1 1 0 1 // Enable pass band filter (0=no, 1=yes)
Source:gUSBamp float FilterHighPass= 0 0.1 0 50 // high pass filter for pass band
Source:gUSBamp float FilterLowPass= 1000 60 0 4000 // low pass filter for pass band
Source:gUSBamp int FilterModelOrder= 8 8 1 12 // filter model order for pass band
Source:gUSBamp int FilterType= 1 1 1 2 // filter type for pass band (1=BUTTERWORTH, 2=CHEBYSHEV)
Source:gUSBamp int NotchEnabled= 1 1 0 1 // Enable notch (0=no, 1=yes)
Source:gUSBamp float NotchHighPass= 58 58 0 70 // high pass filter for notch filter
Source:gUSBamp float NotchLowPass= 62 62 0 4000 // low pass filter for notch filter
Source:gUSBamp int NotchModelOrder= 4 4 1 10 // filter model order for notch filter
Source:gUSBamp int NotchType= 1 1 1 2 // filter type for pass band (1=CHEBYSHEV, 2=BUTTERWORTH)
Storage:BCI2000FileWriter string FileFormat= dat // format of data file (readonly)
Storage:Documentation string StorageTime= % // time of beginning of data storage
Storage:FileSplitting string FileSplittingCondition= % // when to split files, e.g. "1:25:00" or "1.5GB"
Source:Alignment int AlignChannels= 0 0 0 1 // align channels in time (0=no, 1=yes) (boolean)
Source:Alignment floatlist SourceChTimeOffset= 0 0 % % // time offsets for all source channels (may be empty)
Visualize:Processing%20Stages int VisualizeAlignmentFilter= 0 0 0 1 // Visualize AlignmentFilter output (boolean)
Source:Online%20Processing list TransmitChList= 4 1 2 3 4 // list of transmitted channels: Channel names may contain * and ? wildcards, and character ranges enclosed in []; wildcard patterns may be negated by prepending an exclamation mark. Ranges of channels may be specified using : or - to separate begin from end.
Visualize:Processing%20Stages int VisualizeTransmissionFilter= 0 0 0 1 // Visualize TransmissionFilter output (boolean)
Storage:Data%20Location string DataFile= $%7bSubjectName%7d$%7bSubjectSession%7d/$%7bSubjectName%7dS$%7bSubjectSession%7dR$%7bSubjectRun%7d.$%7bFileFormat%7d // name of data file relative to DataDirectory
System:RunManager string DataFileShm= /QWq4d542DnH8SoAC // name of shared memory object holding data file name (readonly)
System:Protocol int EventLink= 1 1 0 1 // Send events from Operator to Source module (boolean)
System:Core%20Connections string OperatorAddress= 127.0.0.1:4002 // (noedit)
System:Core%20Connections string SignalSourceIP= 127.0.0.1 // (readonly)(noedit)
System:Core%20Connections string SignalSourcePort= 64081 // (readonly)(noedit)
System:Version matrix SignalSourceVersion= { Framework Revision Build Config Protocol } 1 3.6.7385 7385,%202023-05-28T15:26:16Z MSVC-19.33.31629.0-AMD64,%20release,%202023-05-30T17:03:19Z,%20brunnerlab@DESKTOP-3EM2F9K USE_DYNAMIC_CRT:TRUE%20USE_OPENMP:ON%20USE_PRECOMPILED_HEADERS:ON%20USE_ASSERTS_IN_RELEASE_BUILDS:OFF 2.3 // SignalSource version information (noedit)(readonly)
System:Configuration matrix SignalSourceFilterChain= 8 { Filter%20Name Position%20String } DataIOFilter 0 gUSBampADC 1 NullFileWriter 1 BCI2000FileWriter 1 EDFFileWriter 1 GDFFileWriter 1 AlignmentFilter 1.1 TransmissionFilter 1.2 // SignalSource filter chain (noedit)(readonly)
System:Configuration matrix Filters= 12 1 /1/DataIOFilter /1/gUSBampADC /1/BCI2000FileWriter /1/AlignmentFilter /1/TransmissionFilter /2/SpatialFilter /2/P3TemporalFilter /2/LinearClassifier /3/ConnectorInput /3/ApplicationBase /3/KeystrokeFilter /3/ConnectorOutput // Filter Directory (noedit)(readonly)
Visualize:Processing%20Stages int VisualizeSpatialFilter= 0 0 0 1 // Visualize SpatialFilter output (boolean)
Filtering:SpatialFilter int SpatialFilterType= 0 0 0 3 // spatial filter type 0: none, 1: full matrix, 2: sparse matrix, 3: common average reference (CAR) (enumeration)
Filtering:SpatialFilter matrix SpatialFilter= 4 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 % % // columns represent input channels, rows represent output channels
Filtering:SpatialFilter intlist SpatialFilterCAROutput= 0 // when using CAR filter type: list of output channels, or empty for all channels
Filtering:SpatialFilter int SpatialFilterMissingChannels= 1 0 0 1 // how to handle missing channels 0: ignore, 1: report error (enumeration)
Filtering:P3TemporalFilter string OnsetExpression= StimulusBegin>0 // Expression that defines stimulus onset
Filtering:P3TemporalFilter int EpochLength= 400ms 500ms 0 % // Length of data epoch from stimulus onset
Filtering:P3TemporalFilter int EpochsToAverage= 2 1 0 % // Number of epochs to average
Filtering:P3TemporalFilter int SingleEpochMode= 0 0 0 1 // Report result after each epoch (boolean)
Visualize:P3TemporalFilter int VisualizeP3TemporalFiltering= 1 0 0 1 // Visualize averaged epochs (0=no 1=yes) (boolean)
Visualize:P3TemporalFilter int TargetERPChannel= 1 1 % % // Input channel for which to display ERP data
Filtering:LinearClassifier matrix Classifier= 2 { input%20channel input%20element%20(bin) output%20channel weight } 1 4 1 1 1 6 2 1 // Linear classification matrix in sparse representation
Visualize:Processing%20Stages int VisualizeLinearClassifier= 0 0 0 1 // Visualize LinearClassifier output (boolean)
System:Core%20Connections string SignalProcessingIP= 127.0.0.1 // (readonly)(noedit)
System:Core%20Connections string SignalProcessingPort= 64118 // (readonly)(noedit)
System:Version matrix SignalProcessingVersion= { Framework Revision Build Config Protocol } 1 3.6.7385 7385,%202023-05-28T15:26:16Z MSVC-19.33.31629.0-AMD64,%20release,%202023-05-30T17:03:19Z,%20brunnerlab@DESKTOP-3EM2F9K USE_DYNAMIC_CRT:TRUE%20USE_OPENMP:ON%20USE_PRECOMPILED_HEADERS:ON%20USE_ASSERTS_IN_RELEASE_BUILDS:OFF 2.3 // SignalProcessing version information (noedit)(readonly)
System:Configuration matrix SignalProcessingFilterChain= 3 { Filter%20Name Position%20String } SpatialFilter 2.A P3TemporalFilter 2.B LinearClassifier 2.C // SignalProcessing filter chain (noedit)(readonly)
Connector:ConnectorInput list ConnectorInputFilter= 0 // list of state names or signal elements to allow, "*" for any, signal elements as in "Signal(1,0)"
Connector:ConnectorInput string ConnectorInputAddress= % localhost:20320 % % // IP address/port to read from, e.g. localhost:20320
Application:Application%20Window int WindowWidth= 640 640 0 % // width of Application window
Application:Application%20Window int WindowHeight= 480 480 0 % // height of Application window
Application:Application%20Window int WindowLeft= 0 0 % % // screen coordinate of Application window's left edge
Application:Application%20Window int WindowTop= 0 0 % % // screen coordinate of Application window's top edge
Application:Application%20Window int WindowFullscreen= 0 0 0 1 // Application window fullscreen mode (boolean)
Application:Application%20Window string WindowBackgroundColor= 0x000000 0x505050 % % // Application window background color (color)(allow_override)
Application:Application%20Window string WindowHideCursor= 1 0 0 1 // hide cursor when mouse is over Application window (boolean)
Application:Application%20Window matrix WindowInfo= 1 1 auto // Application window information (readonly)(noedit)
Visualize:Application%20Window int VisualizeApplicationWindow= 0 0 0 1 // Display miniature copy of Application window (boolean)
Visualize:Application%20Window int AppWindowSpatialDecimation= 8 8 1 % // Application window decimation (shrinking) factor
Visualize:Application%20Window int AppWindowTemporalDecimation= 4 16 1 % // Application window time decimation factor
Application:AudioPlayback int AudioPlaybackOn= auto 0 0 1 // switch audio playback on
Application:AudioPlayback float AudioPlaybackRate= auto // audio playback sampling rate
Application:AudioPlayback int AudioPlaybackChannels= auto // number of playback output channels
Application:AudioPlayback float AudioPlaybackBufferDuration= auto // duration of playback buffer
Visualize:Application%20Log int ShowAppLog= 1 0 0 1 // Show application log window (boolean)
Application:Sequencing float PreRunDuration= 2s 1 0 % // pause preceding first sequence
Application:Sequencing float PostRunDuration= 2s 0 0 % // pause following last sequence
Application:Sequencing float PreSequenceDuration= 1/2s 2s 0 % // pause preceding sequences/sets of intensifications
Application:Sequencing float PostSequenceDuration= 3/4s 2s 0 % // pause following sequences/sets of intensifications
Application:Sequencing float StimulusDuration= 31.25ms 40ms 0 % // stimulus duration
Application:Sequencing string EarlyOffsetExpression= % // abort stimulus if this expression becomes true
Application:Sequencing float ISIMinDuration= 62.5ms 80ms 0 % // minimum duration of inter-stimulus interval
Application:Sequencing float ISIMaxDuration= 62.5ms 80ms 0 % // maximum duration of inter-stimulus interval
Application:Result%20Processing int InterpretMode= 2 0 0 2 // interpretation of results: 0 none, 1 online free mode, 2 copy mode (enumeration)
Application:Result%20Processing int DisplayResults= 1 1 0 1 // display results of copy/free spelling (boolean)
Application:Result%20Processing int AccumulateEvidence= 0 0 0 1 // accumulate evidence until a selection is made (boolean)
Application:Result%20Processing float MinimumEvidence= 0 0 0 % // do not make a selection unless target evidence exceeds this value. For a normalized classifier, MinimumEvidence approximates -2.3*log10(Error Probability)
Application:PhotoDiodePatch int PhotoDiodePatch= 0 1 0 1 // Display photo diode patch (boolean)
Application:PhotoDiodePatch float PhotoDiodePatchHeight= 0.065 1 0 1 // Photo diode patch height in relative coordinates
Application:PhotoDiodePatch float PhotoDiodePatchWidth= 0.05 1 0 1 // Photo diode patch width in relative coordinates
Application:PhotoDiodePatch float PhotoDiodePatchLeft= 0 1 0 1 // Photo diode patch left in relative coordinates
Application:PhotoDiodePatch float PhotoDiodePatchTop= 0.935 1 0 1 // Photo diode patch top in relative coordinates
Application:PhotoDiodePatch int PhotoDiodePatchShape= 1 1 0 1 // Photo diode patch shape: 0 rectangle, 1 ellipse (enumeration)
Application:PhotoDiodePatch int PhotoDiodePatchActiveColor= 0xffffff 0 0 0xffffffff // Photo diode patch color when active (color)
Application:PhotoDiodePatch int PhotoDiodePatchInactiveColor= 0x0 0 0 0xffffffff // Photo diode patch color when inactive, use 0xff000000 for transparent (color)
Application:PhotoDiodePatch string PhotoDiodePatchExpression= StimulusBegin>0 // Photo diode patch expression, evaluates to 1 when active
Application:Sequencing int NumberOfSequences= 2 15 1 % // number of sequences in a set of intensifications
Application:Speller%20Targets matrix TargetDefinitions= 36 { Display Enter Display%20Size Icon%20File Sound%20File } A A 1 % % B B 1 % % C C 1 % % D D 1 % % E E 1 % % F F 1 % % G G 1 % % H H 1 % % I I 1 % % J J 1 % % K K 1 % % L L 1 % % M M 1 % % N N 1 % % O O 1 % % P P 1 % % Q Q 1 % % R R 1 % % S S 1 % % T T 1 % % U U 1 % % V V 1 % % W W 1 % % X X 1 % % Y Y 1 % % Z Z 1 % % 1 1 1 % % 2 2 1 % % 3 3 1 % % 4 4 1 % % 5 5 1 % % 6 6 1 % % 7 7 1 % % 8 8 1 % % 9 9 1 % % _ %20 1 % % // speller target properties
Application:Speller%20Targets intlist NumMatrixColumns= 1 6 6 1 % // display matrices' column number(s)
Application:Speller%20Targets intlist NumMatrixRows= 1 6 6 0 % // display matrices' row number(s)
Application:Audio%20Stimuli int AudioStimuliOn= 0 0 0 1 // Audio Stimuli Mode (0=no, 1=yes) (boolean)
Application:Audio%20Stimuli matrix AudioStimuliRowsFiles= 6 { filename } sounds/1.wav sounds/2.wav sounds/3.wav sounds/4.wav sounds/5.wav sounds/6.wav // audio stimuli rows files
Application:Audio%20Stimuli matrix AudioStimuliColsFiles= 6 { filename } sounds/a.wav sounds/b.wav sounds/c.wav sounds/d.wav sounds/e.wav sounds/f.wav // audio stimuli column files
Application:Speller%20Targets floatlist TargetWidth= 1 16 0 0 100 // target width in percent of screen width
Application:Speller%20Targets floatlist TargetHeight= 1 14 0 0 100 // target height in percent of screen height
Application:Speller%20Targets floatlist TargetTextHeight= 1 12 0 0 100 // height of target labels in percent of screen height
Application:Speller%20Targets stringlist BackgroundColor= 1 0x00000000 0x505050 % % // target background color (color)
Application:Speller%20Targets stringlist TextColor= 1 0x00555555 0x505050 % % // text color (color)
Application:Speller%20Targets stringlist TextColorIntensified= 1 0x00FFFFFF 0x505050 % % // intensified text color (color)
Application:Speller%20Targets intlist IconHighlightMode= 1 1 1 0 4 // icon highlight method 0: Show/Hide, 1: Intensify, 2: Grayscale, 3: Invert, 4: Dim (enumeration)
Application:Speller%20Targets floatlist IconHighlightFactor= 1 0.5 0.5 0 % // scale factor for highlighted icon pixel values
Application:Speller int FirstActiveMenu= 1 1 1 % // Index of first active menu
Application:Speller float StatusBarSize= 10 0 0 100 // size of status bar in percent of screen height
Application:Speller float StatusBarTextHeight= 4 0 0 100 // size of status bar text in percent of screen height
Application:Speller string TextToSpell= SPELLING%20IN%20THE%20RAIN // character or string to spell in offline copy mode
Application:Speller string TextResult= % // user spelling result
Application:Speller int TestMode= 1 0 0 1 // select targets by clicking on their associated stimuli (0=no, 1=yes) (boolean)
Application:Speller string DestinationAddress= % // network address for speller output in IP:port format
Application:Text%20Window int TextWindowEnabled= 0 0 0 1 // Show Text Window (0=no, 1=yes) (boolean)
Application:Text%20Window int TextWindowLeft= 600 0 0 % // Text Window X location
Application:Text%20Window int TextWindowTop= 5 0 0 % // Text Window Y location
Application:Text%20Window int TextWindowWidth= 512 512 0 % // Text Window Width
Application:Text%20Window int TextWindowHeight= 512 512 0 % // Text Window Height
Application:Text%20Window string TextWindowFontName= Courier // Text Window Font Name
Application:Text%20Window int TextWindowFontSize= 10 4 1 % // Text Window Font Size
Application:Text%20Window string TextWindowFilePath= % // Path for Saved Text File (directory)
Application:Human%20Interface%20Devices string KeystrokeStateName= % // State to be translated into keystrokes (0-F), empty for off
Application:Human%20Interface%20Devices string KeystrokeExpression= % // Expression that evaluates to a virtual keycode, empty for off
Application:Human%20Interface%20Devices string KeystrokeExpressionOnStartRun= % // Expression that initializes expression variables on StartRun
Connector:ConnectorOutput string ConnectorOutputAddress= % localhost:20321 % % // one or more IP:Port combinations, e.g. localhost:20321
Application:Localization string Language= Default Default % % // Language for user messages
Application:Localization matrix LocalizedStrings= { German } { TIME%20OUT%20!!! Waiting%20to%20start%20... Sleeping--Select%20SLEEP%20twice%20to%20resume Select%20SLEEP%20once%20more%20to%20resume Paused--Select%20PAUSE%20again%20to%20resume } Zeit%20abgelaufen! Warte%20... Angehalten:%20Zweimal%20SLEEP%20fur%20Weiter Angehalten:%20Noch%20einmal%20SLEEP%20fur%20Weiter Angehalten:%20Noch%20einmal%20PAUSE%20fur%20Weiter // Localized user messages
System:Core%20Connections string ApplicationIP= 127.0.0.1 // (readonly)(noedit)
System:Core%20Connections string ApplicationPort= 64143 // (readonly)(noedit)
System:Version matrix ApplicationVersion= { Framework Revision Build Config Protocol } 1 3.6.7385 7385,%202023-05-28T15:26:16Z MSVC-19.33.31629.0-AMD64,%20release,%202023-05-30T17:03:19Z,%20brunnerlab@DESKTOP-3EM2F9K USE_DYNAMIC_CRT:TRUE%20USE_OPENMP:ON%20USE_PRECOMPILED_HEADERS:ON%20USE_ASSERTS_IN_RELEASE_BUILDS:OFF 2.3 // Application version information (noedit)(readonly)
System:Configuration matrix ApplicationFilterChain= 4 { Filter%20Name Position%20String } ConnectorInput 2.9999 P3SpellerTask 3 KeystrokeFilter 3.1 ConnectorOutput 3.9999 // Application filter chain (noedit)(readonly)
System:Randomization int RandomSeed= 18321 0 % % // seed for the BCI2000 pseudo random number generator (readonly)
System:Randomization int RandomizationWarning= 1 1 0 1 // warn if subsequent Runs have identical RandomSeed value (boolean)
System:State%20Vector int /StateVectorLength= 45 16 % % // length of the state vector in bytes (noedit)(readonly)