<div dir="ltr">Thanks for the replies.<div><br></div><div>Jan-Mathijs, I am working on some  preprocessing/artifact correction projects and would like the option to write back to the DS format so that others in my lab, using native ctf tools or besa, can easily incorporate what I am doing into their pipelines. Starting with <span style="font-size:13.1999998092651px;line-height:19.7999992370605px">readCTFds.m and the files in external/ctf is probbaly a good idea. Thanks.</span></div><div><br></div><div>Tom, rewriting the meg4 file would certainly work for what I need to do. Would you be willing to share an example (Python would be fine) of writing out to the meg4 file.</div><div><br></div><div>Best,</div><div>Luke</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 28 Jul 2015 at 16:12 Tom Holroyd <<a href="mailto:tomh@kurage.nimh.nih.gov">tomh@kurage.nimh.nih.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 28 Jul 2015 17:03:41 +0000<br>
Luke Bloy <<a href="mailto:luke.bloy@gmail.com" target="_blank">luke.bloy@gmail.com</a>> wrote:<br>
<br>
> Is anyone aware of any tools for writing CTF DS files out from<br>
> fieldtrip data structures?<br>
<br>
Well, I have Python code. But the usual way to go here is to use an<br>
existing dataset. The CTF .meg4 file is a "flat" file*, so you can read<br>
in a CTF dataset, modify the data, and then easily re-write only<br>
the .meg4 file without changing any of the other files, assuming the<br>
modification doesn't change the trial structure or length of data.<br>
<br>
The only thing you need to do is convert the internal floating point<br>
representation (units of Tesla) back into the .meg4 file representation<br>
(32-bit integers) by inverting the gain calculation, using the same<br>
gains stored in the header.<br>
<br>
With some trickery, you can even make shorter datasets from existing<br>
ones using the usual newDs tool, and then rewrite the short .meg4 file<br>
with whatever data. Writing CTF datasets from scratch is certainly<br>
possible, but you're still going to be copying things from existing<br>
datasets (such as sensor geometry and gain factors).<br>
<br>
* with an 8 byte (constant) header<br>
<br>
--<br>
Dr. Tom<br>
--<br>
"There are not more than five musical notes,<br>
yet the combinations of these five give rise to<br>
more melodies than can ever be heard." -- Sun Tzu<br>
</blockquote></div>