Repository navigation
WIP: extract head position pos from CTF data - #4088
Conversation
|
Travis says your new test does not pass. Do you know any CTF folks who could test this? I might actually have some CTF data with HPI information encoded, but couldn't really verify its quality beyond making sure the resulting positions/rotations look not terrible. |
|
Yeah, the test fails to enforce that the I add a regression test once we are convinced that its working. The regression test can use existing CTF data in the testing sample but I want to confirm its working on a bigger test set. then I'll remove the assert_true(False) at the end of the test. That will also fix the flake warning of an unused variable. Unfortunately I don't know any CTF users who also are mne-python users. I am going to try to acquire a phantom run today but that will be a somewhat qualitative test. IE I start moving the phantom +z at 2 sec and start to rotate around 5 sec. Other than that I'm not sure what I can do. One thing that might be important is that the pick_channel_regex matches the right channels on all CTF machines. I think only the numbers after the - change in the channel names but I don't really know. |
That would be great. If you can try to make the recording short but still usable, we could add it to the
I think that getting it to work with your data is the right first step. Then we can wait to hear from others if it doesn't work, and iterate. At the very least I can check the data that I have, which I think are from Montreal. |
|
@Eric89GXL How do you want to handle mne-test-data pulls? do you want separate PRs for each mne-python PR? |
|
Yeah ideally the PRs will match, makes checking things a bit easier. |
|
ok testing data for this PR is in mne-tools/mne-testing-data#21 |
|
@Eric89GXL however it will make the artemis reader tests fail because those tests are looking for data that was removed in release 32? Thoughts on how to deal with that. |
|
Once both your PRs are merged we should be good, right? If so, I assume those will be fixed in your other PR. We can let them fail here for now, and merge your other PR first. Then we are only merging with green CIs. Sound good? |
|
works for me. |
Codecov Report
@@ Coverage Diff @@
## master #4088 +/- ##
==========================================
+ Coverage 88.05% 88.05% +<.01%
==========================================
Files 356 356
Lines 65140 65192 +52
Branches 11105 11112 +7
==========================================
+ Hits 57358 57408 +50
- Misses 4958 4959 +1
- Partials 2824 2825 +1 |
larsoner
left a comment
There was a problem hiding this comment.
In your testing, does this work well?
Where does ctf_chpi_pos_fname come from? Can we take it as some sort of ground truth to compare to?
Otherwise LGTM
| return(apply_trans(trans, pts, move=move)) | ||
|
|
||
|
|
||
| def extract_head_pos_ctf(raw, gof_limit=0.98): |
There was a problem hiding this comment.
Probably calculate because we're actually doing some computation/estimation here, not just extracting values (that's the trivial part).
There was a problem hiding this comment.
... and we've probably talked about this before, but maybe we should just have one calculate_head_positions(raw) function. If you pass a CTF raw, it uses this code. If you pass Neuromag raw, it uses the Neuromag code. WDYT?
If you think we should do it, but do it in a separate PR, then let's make this function private for now.
There was a problem hiding this comment.
I'll change the name to _calculate_head_pos_ctf and make it private.
I like the idea of having a single method eventually. I had been hoping to evaluate the mne chpi fitting by feeding it CTF data, but it seems that ctf filters out the cHPI frequencies so that doesn't work.
I would suggest that we use this a little while and then make a new PR where we make calculate_head_positions a public method and at that time we think through how to unify things.
| hpi_picks = [] | ||
| for i in [2, 1, 3]: | ||
| hpi_picks.extend(pick_channels_regexp(raw.info['ch_names'], | ||
| 'HLC00%d[123]-.*' % i)) |
There was a problem hiding this comment.
I don't see any checking that pick_channels_regexp actually gives you channels in the right order.
You might just want to pick channels with a single regex, then check that you actually have the correct channels while doing the necessary reordering.
| ----- | ||
| CTF continuous head monitoring stores the x,y,z location (m) of each chpi | ||
| coil as separate channels in the dataset. | ||
| HLC001[123]-* - nasion |
There was a problem hiding this comment.
These * will probably cause Sphinx to complain. You can either escape them with \ (since it's in a string it should actually be \\ or use an r'' string) or change the nomenclature.
|
|
||
|
|
||
| def extract_head_pos_ctf(raw, gof_limit=0.98): | ||
| """Extract MaxFilter-formatted head position parameters from ctf dataset. |
There was a problem hiding this comment.
We don't need to call them MaxFilter-formatted in the title. (You can do it in the notes if you want.) I think we're probably going to standardize around using the (N, 10) ndarray format. If we always labeled whose format it was (derived from) in the title, we'd have some long names...
There was a problem hiding this comment.
I was just following the pattern from the other methods.
I do find this pos/quat nomenclature a bit confusing.
For instance the method _apply_quat should really be in mne.transforms but the quat isn't quite a quaternion so I left it in chpi.
I guess I could refactor it into taking a real quaternion and a translation and then put it in mne.transforms ,what do you think?
|
For private functions it's not too big a deal. Being able to directly pass
the 6 necessary elements is really convenient when using these functions
(it's a nice compact representation) so I lean toward unifying based on
that somehow. Perhaps for another PR then.
|
|
So the unfortunately the numbers in I did visualize the changes in head locations, and it did match what was expected. Which now as i sit on the train forget what was, but i think its an p -> A translation |
|
Sounds good. When this is good to go from your end please set the title to MRG and ping me to have a look |
|
I am happy that this is working on our ctf data. |
|
I'm not sure if any CTF users have done movement tracking stuff. @christianbrodbeck do you have any experience with this? |
|
What's holding up this one? |
|
3rd party confirmation?
I think my concern was that other systems (different electronics etc) might
have different channel names for the nasion/lpa/rpa. Although it would also
be a good sanity check to have another CTF site give this a test.
…On Fri, Oct 20, 2017 at 11:27 AM jona-sassenhagen ***@***.***> wrote:
What's holding up this one?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#4088 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU7nQj0iIhMeSnn7mnqi2EaiwkGf6AIks5suLvkgaJpZM4MnTnr>
.
|
|
I can send you a CTF file from our site if that helps, but I sadly don’t know anything about head position.
|
|
If you know that it has continuous HPI turned on I can certainly check it
out.
…On Fri, Oct 20, 2017 at 1:38 PM jona-sassenhagen ***@***.***> wrote:
I can send you a CTF file from our site if that helps, but I sadly don’t
know anything about head position.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#4088 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU7nXjE6W9C9PAj-aUSXo6fQIBX1K2Hks5suNqmgaJpZM4MnTnr>
.
|
|
@jona-sassenhagen do you have any with continuous HPI turned on during the recording? If not, is it easy to get some (preferably with some known movements forward/back, rotations, etc.) |
|
How can I check if it’s turned on in the files I have?
|
|
To be honest I'm not sure how to check if a ds has CHPI on or not.
You could run headMotionDetect which will mark periods and trials as bad if
the head motion exceeds the defined threshold. presumably it would error or
give some message if CHPI wasn't on.
…On Fri, Oct 20, 2017 at 2:50 PM jona-sassenhagen ***@***.***> wrote:
How can I check if it’s turned on in the files I have?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#4088 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU7nXnvAi1NHs8JVpisBbkYT97pIq1Rks5suOuQgaJpZM4MnTnr>
.
|
|
Couldn't you use this PR's branch and run |
|
@jona-sassenhagen can you check some CTF data for head position information when you get a chance? See a couple of posts above. |
|
ed.: redacted I'm dropboxing an evoked CTF file, does that help? |
|
Evoked probably not. I think this will need raw data. |
|
... and it sounds like Luke's suggestion requires running something at the CTF acquisition machine, "headMotionDetect"? |
|
Ok, here is a 1s Raw fif file then :) Or do we need the unconverted CTF files? Cause they're huge. |
|
Rebasing to latest I get: If I comment out the GOF check (not a great idea) it at least runs and gives: The positions are reasonable but the quaternions are probably too large (unless the head was very tilted). @bloyl I take it this file does not have actually cHPI on? Do you see some way to detect this from the header to tell people cHPI was not on, rather than telling them that the coil fit was bad? If not, even in the bad-coil-fit case the Neuromag head pos calculation will use the last known position and move on to the next time point. The CTF code should probably also use this strategy in case there is a large artifact that disrupts cHPI or something. |
Could we reverse the polarity of the neutron flow? |
|
So this took some digging.... but cHPI does seem to be on for test file. However the fif file is bad. I'm not sure when or how it was created but it seem like the ident codes for the NAS and RPA fids/coils are switched. Running the following returns Which has NAS and RPA switched. |
|
This sounds like independent confirmation that your code works, then, given we fix the encoding of LPA/RPA/Nasion elsewhere. Can you rebase and we can see if the CIs pass? If so we can probably merge this. |
|
Rebased and tests are passing. |
|
Great, thanks @bloyl ! |
* ENH: extract pos from ctf * Fix Flake8 * FIX: added regression test and test data * Fix:Method Name Change * FIX: spelling :) * Fix: Resp to reviews
|
@bloyl thanks for that contribution, seems to work great. |
|
any usability PR is welcome |
|
When using This check is in accordance with Also events.average_movements (L. 2852) assumes the t in pos to be rel. 0. --> The time vector calculated in I this time made a 1-line-PR for that ;) |

This is in need of a regression test and more importantly some other CTF users who have some cHPI data to evaluate it.