Back to the main page.

Bug 578 - Incorrect load from cnt neuroscan file when with segmentation

Status CLOSED FIXED
Reported 2011-04-11 21:58:00 +0200
Modified 2011-06-06 10:18:48 +0200
Product: FieldTrip
Component: preproc
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P1 normal
Assigned to: Robert Oostenveld
URL: bugs (file://OLGA-THINK/Users/Olga/Dropbox/bugs)
Tags:
Depends on:
Blocks:
See also:

Olga - 2011-04-11 21:58:33 +0200

I have a cnt file from neuroscan 32 system. It has triggers of different values (0,1,2). I'm uploading the data into fieldtrip using my script. But unfortunately although now mistakes appeared the data seems to be wrong - the last several trials are identical, although they are different in the original file. The other problems are also possible. Can you help me? My script function S1_loaddata_cnt %load single sbj data innameend = '.cnt'; path_input = 'D:\CONSTANTINO\Simon_analysis\ART_REJ\'; path_output = 'C:\Matlab_programs\Fieldtrip\My_Fieldtrip\HindiData\SIMON_ART_REJ\'; subnames = { %14 sbj/10 '90011' }; for s = 1:length(subnames(:,1)), % try cfg = []; sbj = char(subnames (s,:)); FILENAME_INPUT = [path_input, sbj, '_mmn2_rej', innameend] cfg.dataset = FILENAME_INPUT; cfg.d = FILENAME_INPUT; cfg.trialdef.prestim = 1; cfg.trialdef.poststim = 2; cfg.trialdef.eventtype = 'trigger'; cfg.dataformat = 'ns_cnt32'; [cfg] = ft_definetrial(cfg); %%% indentify the manually artefacts marked region clear artefacts_index artefact_start artefact_end artefact_start = 0; artefact_end = 0; artefacts_index = find(cfg.trl(:,4)==0); if mod(length(artefacts_index),2)==0 for i=1:2:length(artefacts_index); artefact_start((i+1)/2) = cfg.trl(artefacts_index(i),1); artefact_end((i+1)/2) = cfg.trl(artefacts_index(i+1),2); end else for i=1:2:(length(artefacts_index)-1); artefact_start((i+1)/2) = cfg.trl(artefacts_index(i),1); artefact_end((i+1)/2) = cfg.trl(artefacts_index(i+1),2); end i=length(artefacts_index) artefact_start((i+1)/2) = cfg.trl(artefacts_index(i),1); artefact_end((i+1)/2) = cfg.trl(artefacts_index(i),2); end; %%% separate stimuli types cfg.trl(1,5) = cfg.trl(1,4); for i=2:length(cfg.trl(:,4)); if cfg.trl(i,4)==2; cfg.trl(i-1,5) = 3; %std before the dvn cfg.trl(i,5) = 2; elseif cfg.trl(i,4)==1 & cfg.trl(i-1,4)==2 ; cfg.trl(i,5) = 4; %std after the dvn else cfg.trl(i,5) = cfg.trl(i,4); end; end; %%%artefacts marking for i=1:length(cfg.trl(:,4)); if artefact_fun(cfg.trl(i,:), artefact_start, artefact_end); cfg.trl(i,5) = 100 ; end; end; cfg.bpfilter = 'yes'; % apply lowpass filter cfg.bpfreq = [1:30]; % lowpass at 35 Hz. FILENAME_OUTPUT = [path_output, sbj, '.mat']; cfg.outputfile = FILENAME_OUTPUT'; [data] = ft_preprocessing(cfg); %catch %end; end;


Olga - 2011-04-11 22:02:31 +0200

I've uploaded the file in my dropbox and shared the directory.


Robert Oostenveld - 2011-04-12 11:22:02 +0200

(In reply to comment #1) > I've uploaded the file in my dropbox and shared the directory. If the file is in your dropbox public directory, can you send me the public link?


Robert Oostenveld - 2011-04-12 11:42:45 +0200

I just committed the changes we made in St Louis to the official ft_read_event release version. See attached. Does that already solve it?


Robert Oostenveld - 2011-04-12 11:44:28 +0200

Created attachment 42 latest version (revision 3330)


Robert Oostenveld - 2011-05-27 10:44:22 +0200

hdr16 = ft_read_header('90011_mmn2_rej.cnt', 'headerformat', 'ns_cnt16'); hdr32 = ft_read_header('90011_mmn2_rej.cnt', 'headerformat', 'ns_cnt32'); show the different interpretations of the file (the 16 bit version is incorrect), note the number of samples being halved. If I do cfg = []; cfg.dataset = '90011_mmn2_rej.cnt'; cfg.trialdef.prestim = 1; cfg.trialdef.poststim = 2; cfg.trialdef.eventtype = 'trigger'; cfg.dataformat = 'ns_cnt32'; cfg.headerformat = 'ns_cnt32'; % !!!!!!!!!! cfg.eventformat = 'ns_cnt32'; % !!!!!!!!!! [cfg] = ft_definetrial(cfg); cfg.bpfilter = 'yes'; % apply lowpass filter cfg.bpfreq = [1:30]; [data] = ft_preprocessing(cfg); then it works fine. Without the headerformat and eventformat specification the header and event table are read assuming 16 bit values, which causes problems in the cfg.trl definition since the sample numbers are incorrect. The consequence was that the low-level reading function loadcnt would try to jump to a position in the file that could not be reached, not notice the error and consequently read the incorrect piece of data. I have made a change to loadcnt to detect the error if it cannot reach the requested sample number. Please upgrade to the fieldtrip version of this evening. Specifying ns_cnt32 remains required for header, data and event.


Robert Oostenveld - 2011-06-06 10:18:48 +0200

closed several bugs at once