Back to the main page.

Bug 2219 - reading 4D header with empty label

Status CLOSED WORKSFORME
Reported 2013-07-10 15:10:00 +0200
Modified 2013-07-16 21:39:26 +0200
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P3 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on: 2027
Blocks:
See also:

Yuval - 2013-07-10 15:10:05 +0200

When reading a 4D header with digitized electrodes I often get an error. I tracked it to the loop in read_4D_hdr.m, line 370. for k = 1:Npoints tmp = fread(fid, 16, 'uchar'); tmplabel = char(tmp(tmp>0)');... what happens is that for the last Npoint its tmplabel is an empty matrix. therefore the elseif line fails. I overcame it by adding the lines: if isempty(tmplabel) tmplabel=' '; end here is the whole loop for k = 1:Npoints tmp = fread(fid, 16, 'uchar'); tmplabel = char(tmp(tmp>0)'); if isempty(tmplabel) tmplabel=' '; end if strmatch('Coil', tmplabel), label{k} = tmplabel(1:5); elseif ismember(tmplabel(1), {'L' 'R' 'C' 'N' 'I'}), label{k} = tmplabel(1); else label{k} = ''; end tmp = fread(fid, 3, 'double'); pnt(k,:) = tmp(:)'; end


Yuval - 2013-07-10 15:11:51 +0200

Hi I found this bug with unusual digitization data. I didn't attach data as I don't have trimmed data handy. if necessary I'll prepare some. thanks, Yuval


Jan-Mathijs Schoffelen - 2013-07-15 11:12:39 +0200

Hi Yuval, Thanks for reporting this. I'll include your suggested fix. Sorry for the inconvenience. JM


Jan-Mathijs Schoffelen - 2013-07-15 11:36:59 +0200

Hi Yuval, Are you by any chance using a very old version of the code? I don't find the lines you mentioned in a more recent version. I may have encountered this issue before, and changed it already. Could you confirm the outdated version and try with the most recent one?


Jan-Mathijs Schoffelen - 2013-07-16 21:39:12 +0200

user error: SPM8 higher on the path caused an old version of the function to be used. current version seems fine.