Skip to content

Import 4D MagnesWH3600 files to fiff … - #248

Closed
dengemann wants to merge 7 commits into
mne-tools:masterfrom
dengemann:bti2fiff
Closed

dengemann wants to merge 7 commits into
mne-tools:masterfrom
dengemann:bti2fiff

Conversation

@dengemann

Copy link
Copy Markdown
Member
  • this is a WIP please don't merge. Despite it's almost ready some tests are pending.
  • Early / generic feedback is welcome however.

Finally, we are there. Some info for the others:
The script resembles the solaris export_fiff program once available for Solaris workstations. Instead of the hierarchical binary data files it processes the header and ascii files produced by different MSI routines, namely 'export_data' which produces xxx.data (binary: time slices x channels) xxx.hdr and ascii header file, 'sensor_transformer' which writes the general device to head transform into x.transform, and 'dump_hs' wihch writes the digitization points into a x.hs. As a consequence of the ascii export the precision is about 4-5 decimals. The script allows to compensate for a sensor frame misalignment between the default mne MagnesWH3600 settings and some particular Magnes3600WH Systems. Also the default translation can be set.

@agramfort

Copy link
Copy Markdown
Member

can you share a dataset to test?

@dengemann

Copy link
Copy Markdown
Member Author

Sure, how do I do this? I mean, shall we optionally provide a mini data set
or so?

On Mon, Dec 10, 2012 at 11:00 AM, Alexandre Gramfort <
[email protected]> wrote:

can you share a dataset to test?

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/248#issuecomment-11187399.

@agramfort

Copy link
Copy Markdown
Member

Sure, how do I do this? I mean, shall we optionally provide a mini data set
or so?

Maybe so the script can be easily tested not only by you.

@dengemann

Copy link
Copy Markdown
Member Author

I had in mind something like a fiff file exported by the solaris routine
one can use for comparison, and then the other files needed to run this
script. So we could even include a test.

On Mon, Dec 10, 2012 at 11:12 AM, Alexandre Gramfort <
[email protected]> wrote:

Sure, how do I do this? I mean, shall we optionally provide a mini data
set
or so?

Maybe so the script can be easily tested not only by you.

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/248#issuecomment-11187738.

@agramfort

Copy link
Copy Markdown
Member

yes. We need to figure out how to add this to the test suite. Let's keep it
in mind. We should also test the scripts in the bin folder...

@dengemann

Copy link
Copy Markdown
Member Author

I knew there was something, currently we don't test them, right?

On Mon, Dec 10, 2012 at 11:24 AM, Alexandre Gramfort <
[email protected]> wrote:

yes. We need to figure out how to add this to the test suite. Let's keep it
in mind. We should also test the scripts in the bin folder...

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/248#issuecomment-11188074.

@dengemann

Copy link
Copy Markdown
Member Author

TODO

  • some formal testing : compare values to solaris command
  • testing parameter combinations for hidden regressions
  • adding sample data
  • adding overall docs string + comments + example usage

@dengemann

Copy link
Copy Markdown
Member Author

Also NOTE:

  • this procedure is valid for pure MagnesWH3600 magnetometer systems as predominantly operated in Europe. This should be fine for the moment, but we should keep this in mind and add gradiometer support as soon as a users of a mixed sensor type MagnesWH3600 (as used in Minneapolis) shows interest in this.
  • In addition to the solaris procedure this script also puts the reference channels and additional external channels, e.g. accelerometers, eye trackers, into the fiff and already applies the right names to the channels. The mne commands commonly used to augment the fiff files produced by the solaris export_fiff are hence not longer necessary when using this script. This part could however be better tested, that is compared to what mne_insert_4D_comp etc. do.

@dengemann

Copy link
Copy Markdown
Member Author

Reference channels updated.

As far as I can tell for the moment, with regard to reference channels, this script inserts the channels and renames them. However, it currently does not position the compensation channels, nor does it calculate or apply compensation weights. As a result the comp channels are in, but the info is incomplete. Actually completing this should be doable. As far as I know (see #96) mne uses the same routine for ctf and bti systems and mne-python currently already handles the ctf compensations. Adding the ref-channels positions correctly might be non-trivial, depending on whether it is more then just translating and rotating. At least one can tell that the Magnes3600WH .pos file used by mne won't work for the magnetometer systems (see discussion on MNE analysis around june / july this year). My advice would be to currently block the ref channels or add a warning, unless we don't at least support inserting the ref channels correctly so that people could use the other mne commands to complete the ensuing fiff file. Wdyt?

@dengemann

Copy link
Copy Markdown
Member Author

Actually @mshamalainen might help us here. If he could tell us how the mne_4d_insert comp matches the ref channel positions from the ascii file with the helmet channel positions from the fiff file. If it is just about applying the transformations we can easily include this step here.

@dengemann

Copy link
Copy Markdown
Member Author

So it seems I was able to resolve some mysteries about the compensation channels. Besides a warning that it is experimental we should be fine including them and just applying the regular transformations applied to other channels. The user then would not need to use mne_4D_insert_comp. We can then later support compensation handlng.

@dengemann

Copy link
Copy Markdown
Member Author

Just added reference channel support. I will make available a test data set tomorrow in the course of the day.

- this is a WIP please don't merge. Despite it's almost ready some tests are pending.
- Early / generic feedback is welcome however.

Finally, we are there. Some info for the others:
The script resembles the solaris export_fiff program once available for Solaris workstations. Instead of the hierarchical binary data files it processes the header and ascii files produced by different MSI routines, namely 'export_data' which produces xxx.data (binary: time slices x channels) xxx.hdr and ascii header file, 'sensor_transformer' which writes the general device to head transform into x.transform, and 'dump_hs' wihch writes the digitization points into a x.hs. As a consequence of the ascii export the precision is about 4-5 decimals. The script allows to compensate for a sensor frame misalignment between the default mne MagnesWH3600 settings reported for some Systems. Also the default translation can be set.
- Adding tags 4003-4005 to fiff.constants.py (MNE manual pp. 108)
- Adding Magnes reference channels definitions to import script
- Fixing bug about coordinate frame. I now is head if no appropriate transform
  is present and device if it is present.

This should now write a fiff at the same level of completeness as after mne_insert_4D_comp but without 'guessing' the transform from Magnes3600WH.pos;
the locations should actually be more appropriate.
@dengemann

Copy link
Copy Markdown
Member Author

I will close this PR in soon. Current status is still experimental, but promising. The source reconstructions drawn from this routine look valid and after another testing iteration over the geometries, the behavior seems valid.

However, I found a way to read directly from bti binaries, this will presumably allow us to operate on the data in a lossless fashion and take full advantage of the coordinate transforms elaborated here. The script exposed her will move to a gist.

I will continue on this with a new PR focussing on extending our fiff module by a bti submodule.

@dengemann

Copy link
Copy Markdown
Member Author

Despite #385 I'll keep this open, since a script would be handy and the option parser is already there.

@dengemann

Copy link
Copy Markdown
Member Author

Continued on #385

@dengemann dengemann closed this Jan 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants