Back to the main page.
Bug 2414 - Neuralynx headers include unicode characters, which can crash ft_read_neuralynx_interp
Status | CLOSED FIXED |
Reported | 2013-12-05 17:22:00 +0100 |
Modified | 2014-02-24 10:56:34 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Linux |
Importance: | P3 critical |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Jason Locklin - 2013-12-05 17:22:01 +0100
## System: System Locale: en_CA.UTF-8 System: Linux 3.8_amd64 Matlab: 8.2.0.701 (R2013b) Using either: Java: version "1.7.0_25" OpenJDK Runtime Environment (IcedTea 2.3.10) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) or: Java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) ## Problem: When I use `ft_read_neuralynx_interp()`, I get the following error: > Invalid field name: 'DspFilterDelay_µ'. > > Error in setfield (line 34) > s.(deblank(strField)) = varargin{end}; > > Error in neuralynx_getheader (line 76) > hdr = setfield(hdr, key, val); > > Error in read_neuralynx_ncs (line 37) > hdr = neuralynx_getheader(filename); > > Error in ft_read_header (line 1196) > ncs = read_neuralynx_ncs(filename, 1, 0); > > Error in ft_read_neuralynx_interp (line 32) > orig(i) = ft_read_header(fname{i}); It turns out that Matlab is trying to set a keyname in a struct based on input from the neuralynx data headers, and one of those names is `DspFilterDelay_µ`. For some reason, my instance of matlab is happy with unicode characters pasted into the console or editor, and I can set strings containing unicode characters, but I can't use unicode in identifiers: >>> '?' > ans = > ? works fine, while the following fails: >>> ? = 1 > ? = 1 > | > Error: The input character is not valid in MATLAB statements or expressions. ## Solution: I replaced the line: hdr = setfield(hdr, key, val); in `neuralynx_getheader.m` with these lines: try hdr = setfield(hdr, key, val); catch fprintf('Key contains unallowed characters: %s, stripping...',key); key = regexprep(key,'[^a-zA-Z]',''); hdr = setfield(hdr, key, val); end This solves the problem on my system, but won't result in any changes on systems supporting fully unicode characters. Regards, Jason Locklin, University of Waterloo, Canada
Martin Vinck - 2013-12-18 16:01:59 +0100
hi Robert, neuralynx_getheader shows a crash for the newer system because of unicode chars in the header. Do you agree with the proposed solution?
Martin Vinck - 2013-12-21 21:30:34 +0100
The original fix here was not correct - as it was char(181) causing problems. I put the right comparison with char(181) in there now. Jason's solution would work as well although numbers would have to be added. But it would leave us blind to the information being removed - therefore I'd prefer to solve one by one.