Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneous EEG / PPG and zipping samples #56

Open
TijeOortwijnThales opened this issue Mar 22, 2022 · 2 comments
Open

Simultaneous EEG / PPG and zipping samples #56

TijeOortwijnThales opened this issue Mar 22, 2022 · 2 comments

Comments

@TijeOortwijnThales
Copy link

TijeOortwijnThales commented Mar 22, 2022

I run into some strange behaviour trying to plot EEG and PPG simultaneously. I'm using a Muse-S.

Below I added the basic code to reproduce the behaviour. Connect to the muse and then subscribe to both the zipped Observables.

try {         
         this.muse.enablePpg = true;
         await this.muse.connect();
         await this.muse.start();     
         await this.muse.deviceInfo();  
         zipSamples(this.muse.eegReadings).subscribe(console.log); 
         zipSamplesPpg(this.muse.ppgReadings).subscribe(console.log);     
        } catch (err) {
         window.alert(err.toString());
         this.connectionError.next('Connection failed: ' + err.toString());  
       } finally {
         this.connecting.next(false);
       }    
  • This logs the zipped eegSamples to the console, but it does not print out the zipped ppg values. It only prints out 6 of the zipped ppgSamples on disconnection.
  • When not subscribing to eeg, but only to ppg, it does print the zipped ppgSamples to console like expected.
  • The zipped EegSamples always get printed to the console, regardless of the subscription to the ppg observable.
  • When not zipping any of the sample Observables with the zipSamples / zipSamplesPpg pipe, it does print the readings (unzipped) for both.

I hope the issue is clear, it's quite hard to describe. I suspect a bug in the zipSamplesPpg, but I can't seem to figure out how to fix it.

@TijeOortwijnThales
Copy link
Author

I found out the timestamp isn't changing for PPG readings when I subscribe to both the eegReadings and the ppgReadings. The zipSamplesPPG never gets passed the first mergeMap call.

mergeMap((reading) => {        
       // NEVER GETS PASSED THIS CALL, reading.timestamp doesnt update properly
         if (reading.timestamp !== lastTimestamp) {
             lastTimestamp = reading.timestamp;   
             if (buffer.length) {                 
                 const result = from([[...buffer]]);
                 buffer.splice(0, buffer.length, reading);
                 return result;
             }
         }         
         buffer.push(reading);         
         return from([]);
     }),     

@henrisuurorg
Copy link

@TijeOortwijnThales did you ever find a solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants