Page 4 of 9

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 29 Apr 2024, 09:51
by mellinger
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)|')

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 29 Apr 2024, 14:10
by whwilbur
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:

Image

Image

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.

Image

Image

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)

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 29 Apr 2024, 14:46
by whwilbur
see the added signal plots in above message (edited) before the FFT.

I think the reason my data didn't show in the FFT is because of the huge offset. When one uses GDF, the EEGlab may be able to remove the offset. But it can't handle BCI2000 file. So using BCI2000 dat file. How do you adjust the offset in the file to make it 0 so it will show in the FFT (noting SampleChOffset is always 0 so you can't adjust it even in the file)? Note even in electrodes that are put property. There is still some offset. My electrode impedance as measured with impedance meter is 10K or less (5k) as typical.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 30 Apr 2024, 09:24
by whwilbur
It seems load_bcidat can load data if there is not so much offset. I wonder what range of offset it can still read the data (if the question makes sense).

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 30 Apr 2024, 10:04
by whwilbur
I chose gUSBampSource, DummySignalProcessing, DummyApplication, BCI2000Command with the parameter loaded up (same as shared 3 messages before). in the following menu. Is BCI2000Command correct or should it be others? If it is not correct, why does it save with no warning of wrong entries?

Image

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 30 Apr 2024, 12:11
by mellinger
The large offset in your file will appear at frequency zero in your FFT. Just set that to 0 and you will see FFT details.

Also, you should be aware that Matlab commands without a terminating ";" will print their output to the Matlab console. This is not a malfunction of the command.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 30 Apr 2024, 19:58
by whwilbur
mellinger wrote: 30 Apr 2024, 12:11 The large offset in your file will appear at frequency zero in your FFT. Just set that to 0 and you will see FFT details.

Also, you should be aware that Matlab commands without a terminating ";" will print their output to the Matlab console. This is not a malfunction of the command.
Thanks, it works now. My high pass filter at Source was set to 0. by setting it to 5Hz, it takes care of the DC offset. Didn't know setting it to 0 will still include the DC.

I used BCI2000Viewer to view the waveforms and saw the offset. There is option there to save in ASCII. By saving it in ASCII and loading in Sigview. The results appear to be better than directly in Matlab using the simple codes.

Also, when there is offset, the mex load_bcidat can't read the data at all as if it's only reading a range near the baseline, isn't it?

Thanks for everything and the patience :)

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 02 May 2024, 11:24
by mellinger
Also, when there is offset, the mex load_bcidat can't read the data at all as if it's only reading a range near the baseline, isn't it?
Basically, load_bcidat can read all files that are correct in the sense of adhering to the BCI2000 dat file format. It doesn't care about which signal values the files contain, it just forwards those to Matlab.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 02 May 2024, 22:52
by whwilbur
mellinger wrote: 02 May 2024, 11:24
Also, when there is offset, the mex load_bcidat can't read the data at all as if it's only reading a range near the baseline, isn't it?
Basically, load_bcidat can read all files that are correct in the sense of adhering to the BCI2000 dat file format. It doesn't care about which signal values the files contain, it just forwards those to Matlab.
You are right. I tested it again. The reason I couldn't notice it has the same contents was because BCI2000Viewer couldn't show the entire output zoomed out. It always stopped after 3 minutes of any file. I tried 5 minutes. But it can't zoom it out.. I'll illustrate. Using Matlab. I loaded a 5 minute EEG file up I have in BCI2000 *.dat.

Image

Looking at the signal data. It is increasing in value. I thought it couldn't read huge offset data. But then. I loaded the *.dat file directly in BCI2000Viewer. but couldn't zoom out like the above. Here is near the end of the 5 minute file:

Image

When I tried to zoom out in BCI2000Viewer to see the entire signal from 0 to 5 minutes. It stops at 3 minutes with cut display or data:

Image

This was the reason I thought the load_bcidat loaded in Matlab doesn't have same file as the as BCI2000 dat. I thought it was because of the huge upset. But then I exported the same *.dat file in BCI2000 to ascii file. I then loaded the ascii file in Sigview and the entire output from 0 to 5 minutes shows up:

Image

So load_bcidat can load up even file with huge upset.

Why does the display cuts at 3 mnutes at BCI2000Viewer? I tried another file without offset and it also cuts at 3 minutes. It would be useful to have the entire 5 minutes or more displayed at BCI2000Viewer zoomed out. Pls try this same file I used when you have time at google drive so you can share how to view the entire 5 minutes at BCI2000Viewer zoomed out or it really cuts at 3 minutes. Why cut at 3 minutes?

Matlab, Sigview can show the entire 5 minute display in one screen. why can't BCI2000viewer without cutting at 3 minutes?

https://drive.google.com/file/d/1wF5QLr ... sp=sharing

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 03 May 2024, 04:37
by mellinger
Thank you for providing the data file.
When using BCI2000Viewer with your file, I can zoom out until the entire 5 minute range is displayed.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 03 May 2024, 06:13
by whwilbur
mellinger wrote: 03 May 2024, 04:37 Thank you for providing the data file.
When using BCI2000Viewer with your file, I can zoom out until the entire 5 minute range is displayed.
Please see the following video shot at youtube I just made now. I found out when I make the screen smaller, the 5 mins can fit. As the screen gets bigger, the feed gets cut. When it's full screen, it's cut at 3 mins. I always used full screen. What do you think cause it?

https://youtu.be/A2cRAqXDGMw

My full screen is sized 2736x1824 using Microsoft Surface 2017 with Windows 10. When I changed it to 1024x768 display size. It can display full screen. What is your full screen resolution? It can display full in your high resolution full screen?
Is this the same BCI2000Viewer version you are using?

Image

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 03 May 2024, 11:52
by mellinger
My maximum resolution is 1920x1080, and the viewer is working at that resolution, i.e. it displays your example file correctly.
The viewer version is 3.6.8104, somewhat newer than yours, but I have never heard of an issue similar to yours.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 03 May 2024, 22:06
by whwilbur
mellinger wrote: 03 May 2024, 11:52 My maximum resolution is 1920x1080, and the viewer is working at that resolution, i.e. it displays your example file correctly.
The viewer version is 3.6.8104, somewhat newer than yours, but I have never heard of an issue similar to yours.
My Microsoft Surface 2017 used this display chipset:

Image

I wonder if only this chipset has issues with BCI2000Viewer. These are the resolutions available:

Image

I used the "recommended" 2736 x 1824. I noticed that as I lower the resolution one by one, the waveforms pass 3 minutes are displayed more and more until it reached the 5 mins at resolution of 1680 x 1050. In the 1920 x 1024 resolution that you also used. It is cut at 4:40min in my system. See screenshot below.

Image

So your 1920 x 1024 is almost showing the full 5mins.. only 20 seconds missing. I wonder if it shows full 5 minutes in your time mark at bottom?

This is a more dramatic youtube video showing the original cut at 3 mins and showing the rest when the viewer window box is made narrower:

https://youtu.be/2T76cueXjU4

With less than 3 mins or recording in other files. It can display full output. If the recording is 15 mins. It can get cut too. One may not notice it immediately if the signal is at baseline and uniform and not going up. Btw.. I tried waveforms at baseline without offset. And it is also cut at 3 mins for 5 mins recording like above.

Maybe it is just issues with the particular Intel HD Graphics 620. And the solution may be to upgrade to new PC. Besides, Not many looks at entire output at once except maybe to check for bad connections so it is not so important and not urgent issue.

Speaking of upgrade. I am thinking whether my g.USBamp is defective. I bought it used for only $1300. Original price is $17500. I kept wondering if there is a catch for it to be sold cheap. Then I found a consistent noise at 958Hz that shows at the FFT whether the input is opened, shorted, with signal generator, or elecrodes on skin connected to it. The noise looks like this:

Image

It occurs whether only battery is used, or ac adaptor. The sampling is 4800Hz. Low pass is 1000Hz. High pass is 5 hz. 8 order Butterworth with Notch filter at 58 to 62Hz. Gtec technical support has been offline for more than a week. And I am not using their $5000 software to record. So a favor pls. Can you please let any person you know with g.USBamp and Matlab to test it. He can record even less than a minute without any inputs at one channel say channel one. Then record it to BCI2000 *.dat. And use the following Matlab code to plot it FFT (I used this code to plot the above). Just change the filename:

[ signal, states, parameters, total_samples, file_samples ] = load_bcidat ('testS001R58.dat');
Fs = 4800; % 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)');
X = X - mean(X);
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs/L*(0:(L/2));
plot(f,P1,'LineWidth',0.5);
title('Single-Sided Amplitude Spectrum of X(t)');
xlabel('f (Hz)');
ylabel('|P1(f)|');

You see. I asked electronic engineers at other forums. They are not sure why and told me to try another computer bec it may be USB error but I don't have another computer and no one would let me try installing unknown software in their computer to test it. They said it could either be the USB port, or defective circuit, or maybe factory flaw. Or maybe BCI2000 recording bug specific to the g.USBamp? Right now. I don't know anyone with a $17500 g.USBamp. It's not like getting a Scarlett that is only $200. So I can't ask anyone. Gtec technical support used their $5000 g.recorder. So please kindly ask your friend with g.USBamp to try the above and share the FFT screenshot.

If my g.USBamp is defective. I may no longer use it. But if the defect is only 958Hz peaks and not affecting other frequencies. I may use it and the first thing to calibrate it is to control a cursor with my brain waves so I need to do full fledge BCI2000 thing to control cursor or peripherals just to test if my unit is working properly.

Thank you very much for helping.

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 04 May 2024, 05:18
by mellinger
Upon a second thought, I actually found a possible numeric overflow that could have caused the problem you describe.
You are welcome to try with this updated version of BCI2000Viewer:
http://bci2000.org/tmp/BCI2000Viewer.zip

Thanks for reporting the issue!

Re: running g.USBamp with BCI2000 using Windows 11

Posted: 04 May 2024, 05:27
by mellinger
Regarding the gUSBamp issue: did you record with all inputs being short-circuited and connected to ground? Otherwise, you might pick up a signal from some electric/electronic device nearby. EEG amplifiers are extremely sensitive to all sorts of noise when run with unconnected (open) inputs.

Also, the low frequency peaks might suggest that you have a signal that is so strong that it exceeds the amplifier's linear range, or leads to numeric issues in the digital filters. You might try running the gUSBamp without digital filters, and see what the spectrum looks like.