# head position parameter for maxfiltering empty-room recording

**URL:** <https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402>\
**Category:** Support & Discussions\
**Created:** [February 28, 2024, 3:48pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402 "2024-02-28T15:48:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaqing](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yaqing/32/2503_2.png) [@yaqing](https://mne.discourse.group/u/yaqing)\
**Post date:** [February 28, 2024, 3:48pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/1 "2024-02-28T15:48:34Z")

</div>

Dear forum,

I’d like to understand how to best preprocess empty room recording for later source reconstruction. I’m aware that I should apply the same preprocessing to the ER data as my experiment data. However, when maxfiltering my experiment data I always project them onto an average head using the participant’s head position info (from cHPI data) and destination=avg\_head.

My first question is, should I do the same to the ER recording (after applying maxwell\_filter\_prepare\_emptyroom())? Since there is no cHPI recorded during ER, should I just set destination=avg\_head in applying maxfilter to the ER signal? Or does this parameter even matter for ER?

And related to this, when applying maxwell\_filter\_prepare\_emptyroom() to the ER recording, does it matter which raw signal I use? Particularly, the raw signal without any preprocessing, vs. the raw signal after maxfiltering which has been adjusted for the head position?

Thank you,  
Yaqing

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [February 28, 2024, 4:02pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/2 "2024-02-28T16:02:44Z")

</div>

I will add to those questions, how should we handle the difference in length between the ER and the task recording?`

The `head_pos` argument of SSS (applying movement compensation) is dependent on the recording length. Same for the annotations injected by [maxwell\_filter\_prepare\_emptyroom](https://mne.tools/dev/generated/mne.preprocessing.maxwell_filter_prepare_emptyroom.html).

What is the good practice here? @richard @larsoner

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 1, 2024, 4:34pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/3 "2024-03-01T16:34:01Z")

</div>

To make the empty room data most closely match the recording, you should pass the un-maxwell-filtered data to the prepare function. Ideally the calls to `maxwell_filter` would match between the prepared-empty-room and task data. So for example if you use movement compensation, you should pass `head_pos=head_pos` to the `maxwell_filter` calls for _both_ the empty-room and task data. Same thing with `destination`, etc.

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [March 2, 2024, 8:41am UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/4 "2024-03-02T08:41:04Z")

</div>

So the difference in length between the data recording and the empty-room is not an issue, even for `head_pos` of shape `(n_pos, 10)`?

---

<div class="post-metadata">

**Author:** ![yaqing](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yaqing/32/2503_2.png) [@yaqing](https://mne.discourse.group/u/yaqing)\
**Post date:** [March 4, 2024, 7:32am UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/5 "2024-03-04T07:32:53Z")

</div>

Thanks for your answer!

@mscheltienne I tried running maxfilter on my ER data using the head position computed from the experiment data and there was no error… I don’t know how MNE deals with the time mismatch but as I understand from @larsoner this is the way to go? The terminal displayed a message like the following while maxfiltering each chunk of ER recording:  
**“Used 11 head positions for 170.000 - 179.999 s (#18/18)”**

Yaqing

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [March 4, 2024, 10:27am UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/6 "2024-03-04T10:27:14Z")

</div>

How long is your empty-room recording? 3 minutes?  
`Used 11 head positions for 170.000 - 179.999 s (#18/18)` kind of sounds like the correction was only applied for the last 10s of the empty-room recording; maybe the `raw.first_samp` difference also impacts the processing here?

---

<div class="post-metadata">

**Author:** ![yaqing](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yaqing/32/2503_2.png) [@yaqing](https://mne.discourse.group/u/yaqing)\
**Post date:** [March 4, 2024, 10:44am UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/7 "2024-03-04T10:44:29Z")

</div>

Sorry for the confusion. The sentence was copied from just the last “epoch” of the ER maxfiltering. This operation seems to be iterated 18 times for my 3-minute ER recording, each corresponding to 10 seconds, so I assume it applied maxfiltering for the entire duration.

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 4, 2024, 4:56pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/8 "2024-03-04T16:56:20Z")

</div>

Yes in MNE-Python the empty room prep function takes care of differences in `first_samp` to make the empty room data be processed the same way to the extent possible. Basically if you have 3 minutes of empty room data but 10 minutes of task data, you’ll get the first 3 minutes of head positions used to “movement compensate” the empty room data. It’s not perfect but so far seems to work reasonably well for infant data I’ve tested with at least.

It will work incorrectly if the position at the start varies drastically from the position later on, though.

---

<div class="post-metadata">

**Author:** ![yaqing](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yaqing/32/2503_2.png) [@yaqing](https://mne.discourse.group/u/yaqing)\
**Post date:** [March 5, 2024, 11:08am UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/9 "2024-03-05T11:08:34Z")

</div>

Thanks a lot for your explanation! Now I understand how it’s done. I have a follow-up question and hope to get your insight.

After preprocessing my ER (prepare, maxfilter, then bandpass filter and apply ICA in the same way as my experiment recording), I computed the covariance matrix and found they have a pattern quite different from what I see in the tutorial:

 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/1/1ec9518a5393c49a4dcbfd737ae4f02fe5e58dcb.jpeg)

Such a quadratic pattern, instead of a dominating diagonal line, appeared in all four participants’ data that I tested. Does this indicate something was screwed up in the processing, or just reflecting the property of our facility? What would be a good way to diagnose the noise covariance matrix?

Yaqing

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 5, 2024, 2:58pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/10 "2024-03-05T14:58:29Z")

</div>

You get a mostly diagonal noise covariance if your noise term is dominated by independent, individual-sensor noise (like at MGH with a magnetically quiet triple-shielded room). If you have sources of interference (which is very common), you’ll see stronger off-diagonal entries like the ones in your plots.

---

<div class="post-metadata">

**Author:** ![yaqing](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yaqing/32/2503_2.png) [@yaqing](https://mne.discourse.group/u/yaqing)\
**Post date:** [March 5, 2024, 4:44pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/11 "2024-03-05T16:44:38Z")

</div>

Thanks again, that’s very helpful!

Yaqing

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [March 12, 2024, 4:44pm UTC](https://mne.discourse.group/t/head-position-parameter-for-maxfiltering-empty-room-recording/8402/12 "2024-03-12T16:44:50Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
