Code to remove gravity from accelerometer data?

Does anyone have Igor code that they are willing to share to implement a Madwick filter or other method to remove the gravity component from accelerometer data? The data is from IMUs in wearable movement sensors that also have gyroscopes. One of the two sets of sensors also have magnetometer data.