[FieldTrip] Creating a New CTF Ds file

Tom Holroyd tomh at kurage.nimh.nih.gov
Tue Jul 28 22:02:42 CEST 2015

On Tue, 28 Jul 2015 17:03:41 +0000
Luke Bloy <luke.bloy at gmail.com> wrote:

> Is anyone aware of any tools for writing CTF DS files out from
> fieldtrip data structures?

Well, I have Python code. But the usual way to go here is to use an
existing dataset. The CTF .meg4 file is a "flat" file*, so you can read
in a CTF dataset, modify the data, and then easily re-write only
the .meg4 file without changing any of the other files, assuming the
modification doesn't change the trial structure or length of data.

The only thing you need to do is convert the internal floating point
representation (units of Tesla) back into the .meg4 file representation
(32-bit integers) by inverting the gain calculation, using the same
gains stored in the header.

With some trickery, you can even make shorter datasets from existing
ones using the usual newDs tool, and then rewrite the short .meg4 file
with whatever data. Writing CTF datasets from scratch is certainly
possible, but you're still going to be copying things from existing
datasets (such as sensor geometry and gain factors).

* with an 8 byte (constant) header

Dr. Tom
"There are not more than five musical notes,
yet the combinations of these five give rise to
more melodies than can ever be heard." -- Sun Tzu

More information about the fieldtrip mailing list