Back to the main page.

Bug 1412 - For .cnt files, ft_read_header() of different versions produce different nSamples

Status CLOSED FIXED
Reported 2012-04-10 17:09:00 +0200
Modified 2014-02-24 10:56:36 +0100
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: All
Operating System: All
Importance: P3 major
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also: http://bugzilla.fcdonders.nl/show_bug.cgi?id=1490

Paul Chang - 2012-04-10 17:09:01 +0200

dear all, I have found that for a given Neuroscan continuous file, the ft_read_header() of version fieldtrip-20120109 and fieldtrip-20120409 will give different nSample, as follows: (1) fieldtrip-20120109 >> hdr = ft_read_header('Sub1_1.cnt') Loading file Sub1_1.cnt ... Reading data ..... Scaling data ..... Reading Event Table... hdr = Fs: 1000 nChans: 64 nSamples: 1505200 <============================= nSamplesPre: 0 nTrials: 1 label: {64x1 cell} orig: [1x1 struct] chantype: {64x1 cell} chanunit: {64x1 cell} (2) fieldtrip-20120409 >> hdr = ft_read_header('Sub1_1.cnt') Loading file Sub1_1.cnt ... Reading data ..... Scaling data ..... Reading Event Table... hdr = Fs: 1000 nChans: 64 nSamples: 0 <======================================== nSamplesPre: 0 nTrials: 1 label: {64x1 cell} orig: [1x1 struct] chantype: {64x1 cell} chanunit: {64x1 cell} The .cnt file (Sub1_1.cnt) is attached for your reference. I would like to know (a) Is it a new feature in version fieldtrip-20120409? If yes, is there any function call to retrieve nSamples? (b) the ft_read_header() of version fieldtrip-20120409 seems to take much more memory resource than that of version fieldtrip-20120109. I cannot run newer versions on a Windows PC equipped with 3GB RAM, but the same PC can run version fieldtrip-20120109 smoothly. Are there any parameters that I can pass to the newer ft_read_header() to reduce memory usage? Thanks.


Paul Chang - 2012-04-10 17:41:37 +0200

Created attachment 249 The test file to reproduce this case The test file is sized around 100 MB in bzip format. Please visit http://xuyierjing.nccu.edu.tw/xuyi/tmp/Sub1_1.cnt.bz2 to download.


Roemer van der Meij - 2012-05-16 13:39:05 +0200

there has been an update of loadcnt.m somewhere in february, which may point to the cause of the problem. course of action (for the assignee): determine whether the problem(s) are caused by the loadcnt not behaving well, or that the interface to FieldTrip is not behaving well (i.e. suggesting that the way FT deals with the output of loadcnt should change).


Roemer van der Meij - 2012-05-24 16:59:35 +0200

Hi Paul, Thanks for the report. The output of ft_read_header should provide the right output now. In some cases, the orig.header.numsamples = 0, and the output number of samples is wrong. In the previous version of loadcnt.m the orig.header.nums field was used (instead of numsamples). This was changed in r5380 to fix bug 1348. This bug was due to loadcnt.m being updated to the most recent version (from neuroscan), which removed the nums field, in favor of using numsamples. I added a workaround for when numsamples is 0. The reason is unknown to me (it looks like a neuroscan data-file specific bug). I re-added the nums field to loadcnt.m so that it can be used in ft_read_header.m. Robert, I added you to the CC in case I missed something here (you performed r5380). The only reason I can see when the output should actually be 0, is when the datafile is empty, which would result in many other errors, so the workaround should be fine I think.


Robert Oostenveld - 2012-05-25 09:25:46 +0200

(In reply to comment #3) Hi Roemer, thanks for picking this up. The loadcnt function is shared with EEGLAB, or better: we just use the EEGLAB version. Earlier this year Arno informed us that the function was updated in EEGLAB and that therefore we also might want to update our copy So making changes to only our copy of loadcnt is not ideal. I'll CC Arno on this bug... @Arno, could the h.nums be added to the EEGLAB copy of loadcnt as well? Please see http://code.google.com/p/fieldtrip/source/diff?spec=svn5806&r=5806&format=side&path=/trunk/fileio/private/loadcnt.m for the change that Roemer made. Or is there another header field we should use to determine the number of samples. Or (probably better) should the fix be in numsamples? Right now the fieldtrip version of loadcnt returns >> hdr.orig.header.numsamples ans = 0 >> hdr.orig.header.nums ans = 1505200


Robert Oostenveld - 2012-06-05 22:47:27 +0200

Based on the 8 test datasets for bug 1490 it seems that right now header.nums always contains the right value (this is with the modification that Roemer made to loadcnt), whereas numsamples is not always correct.


Robert Oostenveld - 2013-05-24 14:00:32 +0200

there are two bugs related to neuroscan cnt, bug 1412 and bug 1490. My proposed solution (discussed with Vladimir over skype) is to move fieldtirp/fileio/private/loadcnt.m to fieldtrip/external/eeglan and merge it with the "official" eeglab version. That ensures that the flow of teh code and changes ot the code can be better tracked.


Robert Oostenveld - 2013-09-24 17:08:04 +0200

(In reply to comment #6) I have resolved the loadcnt issue as commented. Also see the comment in bug 1490, svn revision 8519 and revision 8526.


Robert Oostenveld - 2014-02-24 10:56:36 +0100

I closed several bugs at once that all have been resolved for some time. If you disagree, please reopen.