Can anyone tell the accelerometer data format muse data file, I find 3 columns of accelerometer data after convert it to *.mat file, which column is x, which column is y and which column is z?

# Accelerometer Data Format

Hi.

You can find a detailed explanation at the documentation about the OSC Paths, here:

HTH, Eduardo

**Enigma644**#4

If you’re trying to calculate pitch and roll, this might help:

```
float X = data.get(Accelerometer.LEFT_RIGHT.ordinal()).floatValue()/1000;
float Y = data.get(Accelerometer.FORWARD_BACKWARD.ordinal()).floatValue()/1000;
float Z = data.get(Accelerometer.UP_DOWN.ordinal()).floatValue()/1000;
float musePitch = (float) (Math.atan2(Y, Z) * 180/Math.PI);
float museYaw = (float) (Math.atan2(X, Math.sqrt(Y*Y + Z*Z)) * 180/Math.PI);
```

**Enigma644**#6

Tom, during my tests I’ve noticed at the placement of the accelerometer must be just at the rear of the right ear sensor.

As the band curves around the head, my calculations above for pitch and roll are off slightly.

For example. When viewed from the rear the left and right sensors when on the head are tilted slightly.

Like this: —/, but my calculations above assume they are like this |----|.

Do you know the proper maths to correct for this offset? I can just subtract a bit off the yaw after calculations, but I’d like to calculate both pitch and yaw as correctly and accurately as possible.

**tom**#7

Hey,

Yes, the accelerometer is on the right side of the head. More specifically the axes are oriented like so (approximately):

+ve x points backward from the head (behind the wearer)

+ve y points up into the sky

+ve z points into the ear/head

I don’t think your calculations above assume that the accelerometer is straight. When you wear it on your head, the axes won’t necessarily be oriented exactly in line with gravity, but that shouldn’t matter. You calculations should indicate that, when stationary on the head, the accelerometer is slightly tilted, which is the truth. So the pitch/roll/yaw calculations should reflect a slight deflection.

For example, if I wear Muse on my head and look at the accelerometer x, y, and z values, I see that it is pretty close to being in a standard orientation, x = ~0mG, y = ~1000mG, z = ~0mG, with z being somewhat farther from zero than x. Which is what one would expect given the way the headband hugs the head as you’ve described.

I don’t believe there is another way to account for the slight offsets that are inherent to wearing the headband. You just need to measure them and subtract them, if you want it to behave like it is oriented straight in the centre of the wearer’s head.

**chiasischi**#8

Hello Engima644 and Tom,

Where in the docs can I find the pitch, yaw and roll?

I have some data that I would like to run by this formula you mentioned above but could I get a little more explanation on what the code is doing? Mainly in the part for “Accelerometer.LEFT_RIGHT.ordinal()” is that what you are naming your column in excel? Any help will do as I am learning Matlab as I go!

Thank you!

**Enigma644**#9

Accelerometer.LEFT_RIGHT.ordinal() is received when requesting MuseDataPacketType ACCELEROMETER. My code above is Android Java, not MatLab.