@@ -562,7 +562,8 @@ void EGIAmpClient::readPacketFormat2() {
562562 // Create LSL outlet for EEG (+ Physio if connected)
563563 std::string streamName = " EGI NetAmp " + std::to_string (header.ampID );
564564 streamer_.createOutlet (streamName, nChannels, physioChannelCount,
565- config_.sampleRate , config_.serverAddress , details_);
565+ config_.sampleRate , config_.serverAddress , details_,
566+ config_.nativeFormat );
566567
567568 // Create LSL outlet for impedance if enabled
568569 if (config_.impedance ) {
@@ -633,7 +634,8 @@ void EGIAmpClient::readPacketFormat2() {
633634 int physioChCount = (physioConnectionStatus_ == 3 ) ? 32 :
634635 (physioConnectionStatus_ > 0 ) ? 16 : 0 ;
635636 streamer_.createOutlet (streamName, nChannels, physioChCount,
636- config_.sampleRate , config_.serverAddress , details_);
637+ config_.sampleRate , config_.serverAddress , details_,
638+ config_.nativeFormat );
637639
638640 // Recreate impedance outlet if enabled
639641 if (config_.impedance ) {
@@ -663,43 +665,72 @@ void EGIAmpClient::readPacketFormat2() {
663665 lastPacketCounterWithTimeStamp_ = packet.packetCounter ;
664666 }
665667
666- // Convert and push sample to EEG stream (PacketFormat2 is little endian natively)
667- std::vector<float > eegSamples;
668+ // Push sample to EEG stream (PacketFormat2 is little endian natively)
668669 int physioChannels = (physioConnectionStatus_ == 3 ) ? 32 :
669670 (physioConnectionStatus_ > 0 ) ? 16 : 0 ;
670- eegSamples.reserve (nChannels + physioChannels);
671- for (int ch = 0 ; ch < nChannels; ch++) {
672- eegSamples.push_back (static_cast <float >(packet.eegData [ch]) *
673- details_.scalingFactor );
674- }
675671
676- // Add PIB1 channels (if port 1 connected: status 1 or 3)
677- // Channels 1-8 use negative scaling, 9-16 use positive scaling
678- if (physioConnectionStatus_ & 0x01 ) {
679- for (int ch = 0 ; ch < 8 ; ch++) {
680- eegSamples.push_back (static_cast <float >(packet.pib1_Data [ch]) *
681- PHYSIO_SCALING_1_8);
672+ if (config_.nativeFormat ) {
673+ // Native format: push raw int32 ADC counts
674+ std::vector<int32_t > rawSamples;
675+ rawSamples.reserve (nChannels + physioChannels);
676+
677+ for (int ch = 0 ; ch < nChannels; ch++) {
678+ rawSamples.push_back (packet.eegData [ch]);
682679 }
683- for (int ch = 8 ; ch < 16 ; ch++) {
684- eegSamples.push_back (static_cast <float >(packet.pib1_Data [ch]) *
685- PHYSIO_SCALING_9_16);
680+
681+ // Add PIB1 channels (if port 1 connected: status 1 or 3)
682+ if (physioConnectionStatus_ & 0x01 ) {
683+ for (int ch = 0 ; ch < 16 ; ch++) {
684+ rawSamples.push_back (packet.pib1_Data [ch]);
685+ }
686686 }
687- }
688687
689- // Add PIB2 channels (if port 2 connected: status 2 or 3)
690- // Channels 1-8 use negative scaling, 9-16 use positive scaling
691- if (physioConnectionStatus_ & 0x02 ) {
692- for (int ch = 0 ; ch < 8 ; ch++) {
693- eegSamples.push_back (static_cast <float >(packet.pib2_Data [ch]) *
694- PHYSIO_SCALING_1_8);
688+ // Add PIB2 channels (if port 2 connected: status 2 or 3)
689+ if (physioConnectionStatus_ & 0x02 ) {
690+ for (int ch = 0 ; ch < 16 ; ch++) {
691+ rawSamples.push_back (packet.pib2_Data [ch]);
692+ }
695693 }
696- for (int ch = 8 ; ch < 16 ; ch++) {
697- eegSamples.push_back (static_cast <float >(packet.pib2_Data [ch]) *
698- PHYSIO_SCALING_9_16);
694+
695+ streamer_.pushSampleInt32 (rawSamples);
696+ } else {
697+ // Default: convert to float microvolts
698+ std::vector<float > eegSamples;
699+ eegSamples.reserve (nChannels + physioChannels);
700+
701+ for (int ch = 0 ; ch < nChannels; ch++) {
702+ eegSamples.push_back (static_cast <float >(packet.eegData [ch]) *
703+ details_.scalingFactor );
699704 }
700- }
701705
702- streamer_.pushSample (eegSamples);
706+ // Add PIB1 channels (if port 1 connected: status 1 or 3)
707+ // Channels 1-8 use negative scaling, 9-16 use positive scaling
708+ if (physioConnectionStatus_ & 0x01 ) {
709+ for (int ch = 0 ; ch < 8 ; ch++) {
710+ eegSamples.push_back (static_cast <float >(packet.pib1_Data [ch]) *
711+ PHYSIO_SCALING_1_8);
712+ }
713+ for (int ch = 8 ; ch < 16 ; ch++) {
714+ eegSamples.push_back (static_cast <float >(packet.pib1_Data [ch]) *
715+ PHYSIO_SCALING_9_16);
716+ }
717+ }
718+
719+ // Add PIB2 channels (if port 2 connected: status 2 or 3)
720+ // Channels 1-8 use negative scaling, 9-16 use positive scaling
721+ if (physioConnectionStatus_ & 0x02 ) {
722+ for (int ch = 0 ; ch < 8 ; ch++) {
723+ eegSamples.push_back (static_cast <float >(packet.pib2_Data [ch]) *
724+ PHYSIO_SCALING_1_8);
725+ }
726+ for (int ch = 8 ; ch < 16 ; ch++) {
727+ eegSamples.push_back (static_cast <float >(packet.pib2_Data [ch]) *
728+ PHYSIO_SCALING_9_16);
729+ }
730+ }
731+
732+ streamer_.pushSample (eegSamples);
733+ }
703734
704735 // Push impedance data if in impedance mode and current is injecting
705736 if (config_.impedance && impedanceStreamer_.hasOutlet ()) {
@@ -777,9 +808,12 @@ void EGIAmpClient::readPacketFormat1() {
777808 emitChannelCount (nChannels);
778809
779810 // Create LSL outlet (no Physio16 support for PacketFormat1)
811+ // Note: PacketFormat1 (NA300) already provides float data, so nativeFormat
812+ // doesn't apply - we always use float for Format1
780813 std::string streamName = " EGI NetAmp " + std::to_string (header.ampID );
781814 streamer_.createOutlet (streamName, nChannels, 0 ,
782- config_.sampleRate , config_.serverAddress , details_);
815+ config_.sampleRate , config_.serverAddress , details_,
816+ false ); // Format1 is always float
783817 }
784818
785819 // Convert endianness and push sample
0 commit comments