<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body
        {margin-left:10px;
        margin-right:10px;
        margin-top:10px;
        margin-bottom:10px}
-->
</style><style type="text/css" id="owaParaStyle">
<!--
-->
</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi Neils, 
<div><br>
</div>
<div>I use the ft_preprocessing function to load  both of my fif files into memory, then use the horzcat command to concatenate the matrices together. From there I create my trialdefs and use ft_redefinetrial to create the condition epochs. </div>
<div><br>
</div>
<div>I haven't had a problem with dropped triggers / incorrect trial lengths etc. </div>
<div><br>
</div>
<div>Please find the code I use below (and excuse any clunkiness):</div>
<div><br>
</div>
<div>As for your second question re: <font size="2"><font style="text-align:justify">cfg.detectflank = 'up', the ft_read_event function is the one you want to look at. If your system is anything like a typical neuromag, an event can be characterised by both
 the up and down edges of your digital trigger channel. By specifying cfg.detectflank = 'up' in the read_even function, it will search for jumps in the channel where samples change from 0 to > 0 and classify that as an event, ignoring the down edge.  </font></font></div>
<div><font size="2"><font style="text-align:justify"><br>
</font></font></div>
<div>
<div>Hope the above (and below) helps and happy MEGing, </div>
<div><br>
</div>
<div>Peter.</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>%%</div>
<div>%Read data into matlab</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.dataset = megdata1; %first fif file</div>
<div>cfg.channel = 'MEG';</div>
<div>d1 = ft_preprocessing(cfg);</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.dataset = megdata2; <span style="font-size:10pt">%second fif file</span></div>
<div>cfg.channel = 'MEG';</div>
<div>d2 = ft_preprocessing(cfg);</div>
<div><br>
</div>
<div>%%</div>
<div>%concatenate data</div>
<div><br>
</div>
<div>dfull = d1;</div>
<div>dfull.trial{1,1} = zeros(306,length(d1.trial{1,1}) + length(d2.trial{1,1}));
<b>NOTE: The 306 refers to channels (MEG only). If you have more channels (eg. EOG, ECG) change accordingly. </b></div>
<div>dfull.trial{1,1} = horzcat(d1.trial{1,1}, d2.trial{1,1});</div>
<div>dfull.sampleinfo = [1 length(dfull.trial{1,1})];</div>
<div><br>
</div>
<div>for i = 2:length(dfull.time{1,1}); <b>NOTE: Loop assumes data has yet to be downsampled and is at the base SR of 1000Hz.</b></div>
<div>dfull.time{1,1}(1,i) = (i - 1)*.001; <b>%Change .001 to match SR. </b></div>
<div>i = i + 1;</div>
<div>end  <br>
<div><br>
</div>
<div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div><font size="2">__________________________</font></div>
<div><font size="2">Peter Goodin,  </font>
<div>
<div>
<div>BSc (Hons), Ph.D Candidate.</div>
<div><br>
</div>
<div><font size="2">Brain and Psychological Sciences Research Centre (BPsych)</font></div>
<div>Swinburne University, </div>
<div>Hawthorn, Vic, 3122</div>
</div>
<div><br>
</div>
<div><font size="2">Monash Alfred Psychiatry Research Centre (MAPrc)</font></div>
Level 4, 607 St Kilda Road, <br>
Melbourne 3004</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="divRpF898036" style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b> fieldtrip-bounces@science.ru.nl [fieldtrip-bounces@science.ru.nl] on behalf of Niels Trusbak Haumann [aestnth@hum.au.dk]<br>
<b>Sent:</b> Friday, 1 November 2013 3:16 AM<br>
<b>To:</b> fieldtrip@science.ru.nl<br>
<b>Subject:</b> [FieldTrip] Reading data and trigger events from Neuromag fif dataset splitted into 2 files<br>
</font><br>
</div>
<div></div>
<div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Dear FieldTrip community.
</font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000"><b>Is it possible to read the data and trial events from a single continuous Neuromag fif dataset, which was automatically
 split into two separate fif files during recording, because it exceeeded the standard 2 GB file size limitation?</b></font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">The second of the two splitted fif files contains relevant information showing that the second file continues at
 the time in seconds at which the first file ended. However, if the two fif files are read separately into Field Trip format this information seems to be lost.
</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">FieldTrip seems to support reading in CTF datasets, which have been split into more files due to the 2 GB file size
 limitation, but I don't know whether there is a method for handling this problem with Neuromag fif data.
</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">(
</font><a href="http://fieldtrip.fcdonders.nl/getting_started/ctf?s[]=ctf" target="_blank"><font face="Times New Roman" size="+0" style="font-family:Times New Roman; font-size:12pt">http://fieldtrip.fcdonders.nl/getting_started/ctf?s[]=ctf</font></a><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">
 )</font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">I presume that it is a general problem that Neuromag fif datasets with 306 channel data sampled at 1 kHz 32 bit floats
 are splitted into more files, since only ca. 16-18 minutes raw data can be recorded before it is automatically splitted into two files.
</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">The large file size is not a problem after applying MaxFilter procedures to remove high frequency cHPI signals...,
 etc., and thereafter downsampling e.g. to 16 bit integers sampled at 250 Hz. I see from a previous discussion in another forum that it is not possible to merge (or append) the splitted files with the MaxFilter software.
</font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">When reading triggers from splitted fif files there is usually one trial, which starts in the end of the first file
 and ends in the start of the second file, which cannot be correctly recognized, if the files are treated separately. This is however just a minor problem of loosing a single trial.  </font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000"><b>I have a few wrong detections, probably because a few trials are both defined by up-going signals and down-going
 signals. Would </b><i><b>ft_preprocessing</b></i><b> (and the sub-routines that it calls) take this into consideration, if you e.g. specificy
</b><i><b>cfg.detectflank = 'up' </b></i><b>?</b></font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">I'm looking forward to hear any comments, suggestions or solutions.
</font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Greetings</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Niels.</font></div>
<br>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Niels Trusbak Haumann</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">M.A. / PhD student</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Department of Aesthetic Studies / Center of Functionally Integrative Neuroscience</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Aarhus University / Aarhus University Hospital</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">Denmark</font></div>
<div align="left" style="text-align:left"><font face="Arial" size="+1" color="#000000" style="font-family:Arial; font-size:14pt; color:#000000">E-mail:
<a href="mailto:aestnth@hum.au.dk" target="_blank">aestnth@hum.au.dk</a></font></div>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>