Forums > MaxMSP

Digital Filters instead of FFT


September 18, 2009 | 5:04 pm

Hello

I would like to ask for some help concerning digital filters. I am using EEG raw data and finding it hard to process it with FFT. Well, data is coming from a serial port, gets separated to two channels, from hex converted to float and at the end scaled (as the EEG seller suggested) to -100 to 100 (microVolt).
I could not find a way to use FFT on this data, so I can see how much power is in delta, theta, alpha and beta. Like in the original software:
http://tedor.info/uploads/ibvascreen.jpg

It was suggested to use digital filters instead of FFT. Now I guess if I want to see what is happening in alpha, I have to put the filter on 8hz to 12hz and than average it (not sure).

Could anyone help to use digital filter on this float, please?

Any help appreciated,
Krisztian

Here is the patcher:

– Pasted Max Patch, click to expand. –
September 23, 2009 | 2:43 am

I’m afraid I don’t have a good answer to your question, but I was wondering if you could tell me where you got your eeg data?

Thanks, and good luck!

M

September 23, 2009 | 5:36 pm

hi,

the data (hex) comes from the serial port, and than I change it into a float, and scale it to -100mV to 100mV (CH1 CH2)

and you might fall asleep on this, or laugh your head of on my English>

http://tedor.info/video/mp_video/%5B4.1%5D%20Max%20Raw%20EEG.mp4

best
K

September 24, 2009 | 10:04 pm

hi,

I’m quite sure I understand your question…but if you want to do a frequency analysis with digital filters you need a parallel bank of bandpass filters.
Maybe you should have a look at the vocoder in max’s example patches (examples/effects/classic-vocoder-folder). You only need the analysis part of it. You will have to adjust the center frequencies of the analysis bands (first argument of the classic-channel patch) to fit your range (0-30Hz maybe?).

BTW, what device are you using? I’ve always dreamed of a kind of meditation machine, where your "state of mind" would be reflected as a sound or visually…

Good Luck!

September 25, 2009 | 2:07 pm

hello mudang
thank you for your attention.

I had a look at the vocoder, it kinda make sense. I was trying to use bandpass filters to see the amplitude (magnitude perhaps?) of a certain frequencies. The only thing is that I am not good at DSP.
The raw EEG data I receive is a float, which float I could not really make into an MSP signal any filer could be connected with.

If there was something like an easy explanation for dummies, I’d like to read it.

The device I am using is an IBVA bluetooth device. 2 channels, also good for coherence monitoring. I am just about to make a new headband, so I can be able to measure other parts of the brain, instead only the frontal lobe.

I received a max object with the device, which has a built in FFT, this is what I used so far for my projects. I implemented a neuro feedback training into the Max/MSP patch where I am rewarding the monitored person with sounds, if he/she can maintain to produce certain braindata (thresholds on brain wave amplitudes). I also use the Arduino here to control some servos linked to a trees branches.

Screenshot of EEG Tree project:
http://tedor.info/uploads/EEG%20tree0.8.jpg

Thank you and all the best
Krisztian

This is the patch I am not sure about, how could I make the float I receive as EEG data into a signal, which can be filtered:

– Pasted Max Patch, click to expand. –
September 25, 2009 | 5:18 pm

hi tedor,

you are on the right track!
sig~ converts messages (floats) to an audio signal. But you have to pay attention to the vector size (changeable in DSP Preferences), because sig~ can only sample one float per vector (this means a smaller vector size will give you a higher samplerate. Overdrive should be on, too).

I’ve stripped down the vocoder example to the analysis part for you. This makes the patch a lot easier to understand Wink
I’ve also attached number boxes to the center freqs for the analysis bands.

Happy brainwave syncing !

PS:
What about modulating for example the harshness of a sound according to the "harshness" of your mind ? It’s really a pitty, those EEGs are so damn expensive!

September 28, 2009 | 9:20 am

hello Mudang

this is cool! I would not say I can understand the "classic-channel" patch, but will have to later on.

This is my default, I did not change anything here so far:

I/O Vector size = 256
Signal Vector size = 64
Scheduler in Overdrive = On
44.1K Hz

http://tedor.info/uploads/max_eeg_reson01.jpg

For me it seems to be much faster than FFT but perhaps this might be good for us. I have heard of some debate going on which (Digital Filter or FFT) to use on EEG, what do you think?

Concerning the EEG amplifier prices. Yes, they are expensive, I bought mine around 2 years ago, still works, IBVA supposed to be a good make. I have seen cheaper ones too and was also thinking about to build one on my own (OpenEEG). Than I had to realize I am under the grass root level at electronics.
Emotive should sell it’s product for a reasonable price, but they do not really want to give out all secrets on the protocols:

Interesting:
http://www.emotiv.com/forum/viewtopic.php?f=2&t=7

Someone wrote, this is going to be the future. Well, a lot of water has to float down the river I reckon. But I think it is a nice thing to experiment with.

I would like to have the same patch in Supercollider. Now as you helped me to get to know some more details on filters, I might jump into it, but of course I will be trying to develop this patch as well. Harshness of sound, very good idea! I have tried FM with the FFT object, will have to get a faster computer to synthesize more.

Only one more thing I’d like to ask you:
Is there any particular reason to use a resonant bandpass filter (reson~) or would it be working with other bandpass filters as well?

Thank you very much for your help, appreciated!
best
Krisztian

September 29, 2009 | 12:03 pm

you’re welcome. Being able to help others always make me happy Smile

Quote:
this is cool! I would not say I can understand the "classic-channel" patch, but will have to later on.

In the "classic-channel" patch, the signal gets bandpass filtered throught two reson~ in series. The filtered signal is then averaged over time (in this case, every 20ms from the metro) to get the "strength" of the signal rather than its waveform (Amplitude Follower). Finally the values are smoothed out by a linear ramp over 100ms with the line object.

Quote:
I/O Vector size = 256
Signal Vector size = 64
Scheduler in Overdrive = On
44.1K Hz

You can do some simple math here:
There are 44100 samples per second in the signal domain. One signal vector (dsp-block) has 64 samples. So you end up with samplerate/vectorsize (44100/64 = ca. 690) = "maximum messages per second". Apply nyquist (sr/2), so you should (in theory!) be able to represent frequencies up to 345Hz with a "pseudo signal" message stream.
Someone please correct me, if i’m wrong here!
Note, that max’s message system (scheduler based) works totally different than the (msp) signal system (block based).
This is really the guts of max/msp, so don’t worry if you get confused by this.
Just remember, that you might run into trouble with the message rate. But as you’re dealing with rather low frequencies, this shouldn’t be a problem.

Quote:
For me it seems to be much faster than FFT but perhaps this might be good for us. I have heard of some debate going on which (Digital Filter or FFT) to use on EEG, what do you think?

I’m no dsp- or filter-guru and have only seen eeg data on the tv, but…

In this case i would prefer the filter method, because you can fine-tune it to your needs.
With FFT there are always two major problems:
1. Time vs. Frequency resolution
2. The "picket-fence" effect. (Computation of the spectrum is limited to integer multiples of the fundamental frequency F (reciprocal of the sample length)

If you use FFT, be sure to downsample the signal! In a standard FFT (say 44.1HZ SR and 2048 window size), the frequency bins will be (sr/windowsize) 21Hz apart!
You can downsample with the poly~ object.

On the other hand, with FFT you’ll also get phase information. (might be interesting for hemisphere-coherence ?)

Quote:
Is there any particular reason to use a resonant bandpass filter (reson~) or would it be working with other bandpass filters as well?

Any bandpass filter will do. With resonant filters you can adjust the filter-slope (e.g. the bandwidth) via the Q-factor.

Now, I’ve got a question myself:
What’s your opinion on the NeuroSky Mindset ?
This seems to be the most affordable device delivering raw eeg-data.
Is its quality good enough for analysing brainwave states?
I’m mostly interested in detecting relaxation/meditation/concentration.

This topic really turns my brain on Wink
Lots of ideas come popping up…if you like we could discuss them off-list.

cheers & good luck,
jan.

September 29, 2009 | 12:05 pm
Quote:
http://tedor.info/uploads/max_eeg_reson01.jpg

wow, was your left hemisphere in deep sleep, while taking the screenshot?

Wink Wink

October 2, 2009 | 7:37 am

Hello Jan

Loads of information. Thank you. If most of them as you wrote is the guts of Max/MSP, I will try to sweat less while trying to understand it. Smile

NeuroSky. Unfortunately none of who I know use it. For me it looks quite easy and convenient to use. And the price is excellent! The forum on the NeuroSky page is not really used, maybe because it is new. But could find other good info about it on their Facebook group. More and more people started using this kind of technology. Soon it is going to be common sense.
Of course it will not be a good idea to buy if you want to experiment a bit deeper like: hemisphere coherence, other parts of the brain with external electrodes, …
I think if you are good at DSP and Electronic (as I guess you are) I think you could learn a lot about EEg while making one.

Quote:
This seems to be the most affordable device delivering raw eeg-data.
Is its quality good enough for analysing brainwave states?
I’m mostly interested in detecting relaxation/meditation/concentration.

After them (Neurosky), NeuroSky should be good enough for detecting them!

Offline sound good to me as well:
tedor2@googlemail.com

Alles Gute and nochmals Danke für die Hilfe:)
Krisztian


azs
March 30, 2010 | 7:15 pm

I know this thread is old, but I am curious about what you ended up doing to process the EEG data. I am just starting an EEG project in Max and am confused about how to process the raw microvolt data. Do you need to average each electrode over a certain period of time and subtract the average, or something like that? Also, I have been testing with a program that uses FFT and it’s not very helpful. I was wondering if the filtering worked better.

Viewing 11 posts - 1 through 11 (of 11 total)

Forums > MaxMSP