Errors with Neuromag 306 raw data
r.oostenveld at FCDONDERS.RU.NL
Thu Feb 2 21:58:51 CET 2006
On 2-feb-2006, at 20:29, Jon Houck wrote:
> The first error was: ??? Undefined function or variable
> To work around this, I edited fieldtrip-20060131/private/
> trialfun_neuromag.m to replace iscontinuous on line 13 with 1. The
> edited line reads "trigger = read_fcdc_data(cfg.datafile, hdr, 1,
> nsamples, chanindx, 1);"
I think that fif files are continuous by default, but I am not sure.
It matters for filtering and artifact detection, since reading over a
discontinuous trial boundary would result in a weird jump in the signal.
The iscontinuous flag in read_fcdc_data() indicates whether it should
check if the desired data segments extend over trial boundaries. By
default, the check is decided based on the data (if hdr.nTrials==1
then don't check, otherwise do check). It could be that the files are
stored in blocks, like the ctf pseudocontinuous format. For that
case, i.e. the data specifies that it is epoched, but the epochs form
a continuous signal, I have implemented the flag
So I suggest to change line 13 to the following snippet
if ~isfield(cfg, 'datatype') || ~strcmp(cfg.datatype, 'continuous')
% datatype is unknown or not continuous, perform epoch boundary
iscontinuous = 0;
% do not perform epoch boundary check, usefull for pseudo-
iscontinuous = strcmp(cfg.datatype, 'continuous');
read_fcdc_data(cfg.datafile, hdr, 1, nsamples, chanindx,
That ensures decent (=safe) epoch boundary checking if the file
specifies that it is epoched, and it allows you to pass the
cfg.datatype=continuous option in case you know for sure that the
data can be interpreted as continuous. I will change the code to
include the segment that I gave above.
> And the second was: ??? Subscripted assignment dimension mismatch.
> Error in ==> read_fcdc_data at 392
> *hdr.nSamples)) = buf(:,chanindx)';
> To fix this one, I edited fieldtrip-20060131/read_fcdc_data.m to
> replace buf(:,chanindx)' on line 392 with buf(chandindx,:). The
> edited line reads "dat(:,((i-begepoch)*hdr.nSamples+1):((i-begepoch
> +1)*hdr.nSamples)) = buf(chanindx,:);"
You're right, the buf matrix should not be transposed. I'll fix that
in the next release code as well.
> These changes seem to work well on Matlab 7.1(R14) service pack 3
> on Windows XP and Matlab 6.5 (R13) on HP-UX 10.20. If there are
> better workarounds or (equally likely) if I've irreparably broken
> something, please let me know.
Regarding the first bug that you reported, but seperate of that bug:
I suggest to use trialfun_general, instead of trialfun_neuromag. The
trialfun_neuromag is only for backward compatibility with the initial
code, and the trialfun_general is used by default if you use in
definetrial the following
% cfg.trialdef.eventtype = 'string'
% cfg.trialdef.eventvalue = number, string or list with numbers or
% cfg.trialdef.prestim = 0.300 latency in seconds (optional)
% cfg.trialdef.poststim = 0.700 latency in seconds (optional)
alternatively, you can use
% cfg.trialdef.eventtype = '?'
That uses the read_fcdc_event function, which makes your (and our)
code much more portable to other fileformats and allows more complex
trigger sequences. Please read the read_fcdc_event help and code if
you want to know more.
Thanks for your contribution.
More information about the fieldtrip