<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello FieldTrippers,<div class=""><br class=""></div><div class="">I am working on an iEEG dataset. As part of our processing pipeline I convert the data to BIDS format, and I would like to use the basic Fieldtrip functions ft_read_data and ft_write_data to read in my data file, split it up in separate runs, and then write the data out again in the same format (.edf), without applying any processing on the data itself.</div><div class=""><br class=""></div><div class="">When I used these functions a few months ago they worked just fine. However, when I use them now I run into a problem. When I read in the original data, edfread throws a warning, but not an error. However, when I read in that data after it has been written out by ft_write_data, it results in an error. This happens even when I read in and write out the exact same file, suggesting there might be something going wrong in the data writing process. </div><div class=""><br class=""></div><div class="">Please see below for example code and data. The same error does not appear when I write the data out to brainvision analyzer format, so I could simply switch that format. But I still would like to understand why writing to .edf is resulting in a problem.</div><div class=""><div class=""><br class=""></div><div class="">Many thanks for your help!</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Iris</div><div class=""><br class=""></div><div class=""><div class=""><div><span style="font-family: Courier; font-size: 10px;" class="">fileName = </span><span style="color: rgb(178, 69, 243); font-family: Courier; font-size: 10px;" class="">'examplerecording.edf’</span><span style="font-family: Courier; font-size: 10px;" class="">;</span></div></div></div></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Courier; font-size: 10px; color: rgb(178, 69, 243); margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal; color: rgb(37, 153, 45);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(37, 153, 45);" class="">% read in the data</div></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class="">data_in = ft_read_data(fileName);</div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff9300" class="">Warning: channels with different sampling rate not supported, selecting subset of 120 channels at 512.000000 Hz </font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class="">hdr_in = ft_read_header(fileName);</div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(255, 147, 0);" class="">Warning: channels with </span><span style="color: rgb(255, 147, 0);" class="">different</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">sampling</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">rate</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">not</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">supported</span><span style="color: rgb(255, 147, 0);" class="">, selecting </span><span style="color: rgb(255, 147, 0);" class="">subset</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">of</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">120</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">channels</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">at</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">512.000000</span><span style="color: rgb(255, 147, 0);" class=""> </span><span style="color: rgb(255, 147, 0);" class="">Hz</span><span style="color: rgb(255, 147, 0);" class=""> </span></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(255, 147, 0);" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal; color: rgb(37, 153, 45);" class="">% write out the data</div><div class=""><font face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">ft_write_data(</font><font color="#be38f3" class=""><font face="Courier" size="1" class="">‘exampledata.edf'</font></font><font face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">, data_in, </font><font color="#d357fe" style="font-family: Courier; font-size: 10px;" class="">'header'</font><font face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">, hdr_in, </font><font color="#d357fe" style="font-family: Courier; font-size: 10px;" class="">'dataformat'</font><font face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">, </font><font color="#d357fe" style="font-family: Courier; font-size: 10px;" class="">'edf</font><font color="#d357fe" face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">’</font><font face="Courier" size="1" style="font-family: Courier; font-size: 10px;" class="">);</font></div></div></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal; color: rgb(37, 153, 45);" class=""><br class=""></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal; color: rgb(37, 153, 45);" class="">% read the data in again</div><div class=""><font face="Courier" size="1" class="">data_out = ft_read_data(</font><font color="#d357fe" class=""><font face="Courier" size="1" class="">‘exampledata.edf</font></font><font face="Courier" size="1" class=""><font color="#d357fe" class="">’</font>);</font></div><div class=""><font face="Courier" size="1" class=""><br class=""></font></div></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Warning OPENEDF: Failing Physical Minimum, taking Digital Minimum instead</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Warning OPENEDF: Failing Physical Maximum, taking Digital Maximum instead</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Index exceeds matrix dimensions.</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Error in read_edf (line 209)</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">    if EDF.Chan_Select(k)</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Error in ft_read_header (line 775)</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">      hdr = read_edf(filename);</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">Error in ft_read_data (line 201)</font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">  hdr = ft_read_header(filename, 'headerformat', headerformat, 'chanindx', chanindx, 'checkmaxfilter', checkmaxfilter); </font></div><div style="font-family: Courier; font-size: 10px; margin: 0px; line-height: normal;" class=""><font color="#ff2600" class="">209     if EDF.Chan_Select(k)</font></div><div style="font-family: Courier; font-size: 10px; color: rgb(178, 69, 243);" class=""><br class=""></div></div></div><div class=""><br class=""></div><div class=""><div class="">Please find the data file from the example above here:</div><div class=""><a href="https://nyu.box.com/s/eleoyaiowyfxutrxl2v1j8as6v985rw7" class="">https://nyu.box.com/s/eleoyaiowyfxutrxl2v1j8as6v985rw7</a></div></div><div class=""><br class=""></div><div class="">Note on these data: One problem seems to be the different sampling rates of the channels as indicated by the first warning. However, this warning was present before and then it didn’t result in an error when reading in the same data after it had been written out: the two channels with deviating sampling rates were simply dropped (as indicated by the warning), resulting in 120 channels instead of the original 122. But it seems that now when reading in the same data results in another channel being dropped, creating a discrepancy between the number of channels in EDF.Chan_Select (119 in this case) and the number of channels listed in EDF.NS (120). So the issue appears to be with the header channel info - should I perhaps adapt the header info in  hdr.orig when writing out the file using ft_write_data? Alternatively, coudl the warning about the physical and digital minima/maxima be an indication of what’s causing this problem? (there is no such warning when reading in the same data after first writing it to brain vision analyzer format).</div><div class=""><br class=""></div><div class="">—</div><div class=""><div class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div><br class=""></div><div>Iris Groen</div><div>Postdoctoral Associate</div><div>New York University</div><div>6 Washington Place</div><div>New York, NY, 10003</div><div><a href="mailto:iris.groen@nyu.edu" class="">iris.groen@nyu.edu</a></div></div><br class="Apple-interchange-newline">
</div>
<br class=""></div></div></div></body></html>