I fixed read_eeglabdata (see attached). For the other error I really
need the example because my line numbers are different from the
version you have.
Thanks,
Vladimir
On Wed, Jul 1, 2009 at 4:32 PM, Jakob Scherer<[log in to unmask]> wrote:
> sorry, i messed it up, it should read (read_eeglabdata.m, line 75ff)
>
> try
> pathstr = fileparts(filename);
> % assuming the .dat and .set files are located in the same directory
> fid = fopen([ pathstr filesep header.orig.data]);
> catch
> fid = fopen([ header.orig.filepath filesep header.orig.data ]);
> end
>
> Then the next error encountered is:
> -----------------------------------------------------------------------
> Running job #1
> -----------------------------------------------------------------------
> Running 'M/EEG Conversion'
>
> SPM8: spm_eeg_channelselection (v2866) 17:28:17 - 01/07/2009
> ========================================================================
> Warning: Could not obtain fiducials automatically.
>> In spm_eeg_convert at 410
> In spm_cfg_eeg_convert>eeg_convert at 231
> In matlabbatch\private\cfg_run_cm at 29
> In cfg_util>local_runcj at 1363
> In cfg_util at 699
> In cfg_ui>MenuFileRun_Callback at 1139
> In gui_mainfcn at 96
> In cfg_ui at 53
> checkmeeg: no channel type, assigning default
> checkmeeg: no units, assigning default
> checkmeeg: transform type missing, assigning default
> checkmeeg: data scale missing, assigning default
> checkmeeg: data type is missing or incorrect, assigning default
> creating layout from cfg.elec
> creating layout for ext1020 system
> Failed 'M/EEG Conversion'
> Index exceeds matrix dimensions.
> In file "P:\Science\Matlab\spm8\external\fieldtrip\private\prepare_layout.m"
> (???), function "prepare_layout" at line 608.
> In file "P:\Science\Matlab\spm8\external\fieldtrip\ft_prepare_layout.m"
> (???), function "ft_prepare_layout" at line 11.
> In file "P:\Science\Matlab\spm8\spm_eeg_project3D.m" (v3005), function
> "spm_eeg_project3D" at line 22.
> In file "P:\Science\Matlab\spm8\spm_eeg_prep.m" (v3005), function
> "spm_eeg_prep" at line 94.
> In file "P:\Science\Matlab\spm8\spm_eeg_convert.m" (v3088), function
> "spm_eeg_convert" at line 461.
> In file "P:\Science\Matlab\spm8\config\spm_cfg_eeg_convert.m" (v3059),
> function "eeg_convert" at line 231.
>
> The following modules did not run:
> Failed: M/EEG Conversion
> =======================================================================================
>
> i'll load up the dataset to reproduce the error
> thanks,
> jakob
>
>
> On Wed, Jul 1, 2009 at 5:13 PM, Jakob Scherer<[log in to unmask]> wrote:
>> dear vladimir,
>>
>> in read_eeglabdata.m, line 75:
>>
>> fid = fopen(header.orig.data);
>>
>> assumes that the files to be read in are located in the current matlab
>> directory.
>> one could change this into
>>
>> pathstr = fileparts(filename); % assuming the .dat and .set files are
>> located in the same directory
>> try
>> fid = fopen([ pathstr filesep header.orig.data]);
>> catch
>> fid = fopen([ header.orig.filepath filesep header.orig.data ]); %
>> which i personally find less intuitive, but more consistent with
>> eeglab
>> end
>>
>> to avoid this.
>>
>>
>> On Fri, Jun 26, 2009 at 7:08 PM, Vladimir
>> Litvak<[log in to unmask]> wrote:
>>> Dear Jakob,
>>>
>>> Could you send me the error message and the problematic dataset? You
>>> can use yousendit.com if it's too large.
>>>
>>> Best,
>>>
>>> Vladimir
>>>
>>> On Fri, Jun 19, 2009 at 3:08 PM, Jakob Scherer<[log in to unmask]> wrote:
>>>> hi,
>>>>
>>>> it seems to me that in
>>>>
>>>> spm_cfg_eeg_convert.m, line 37 should read:
>>>> usetrials.val = {1}; % instead of usetrials.val = {0},
>>>>
>>>> to match the default value defined in spm_eeg_convert.m
>>>> (from the help text:
>>>> % S.usetrials - 1 - take the trials as defined in the data [default]
>>>> % 0 - use trial definition file even though the data is
>>>> % already epoched)
>>>>
>>>>
>>>> Then, having corrected that, i get the following error:
>>>>
>>>> SPM8: spm_eeg_channelselection (v2866) 15:22:55 - 19/06/2009
>>>> ========================================================================
>>>> Failed 'M/EEG Conversion'
>>>> Invalid MEX-file
>>>> 'P:\Science\Matlab\spm8\@file_array\private\mat2file.mexw64': Invalid
>>>> access to memory location.
>>>>
>>>> .
>>>> In file "P:\Science\Matlab\spm8\@file_array\subsasgn.m" (v1355),
>>>> function "subfun" at line 132.
>>>> In file "P:\Science\Matlab\spm8\@file_array\subsasgn.m" (v1355),
>>>> function "subsasgn" at line 73.
>>>> In file "P:\Science\Matlab\spm8\spm_eeg_convert.m" (v3088), function
>>>> "spm_eeg_convert" at line 346.
>>>> In file "P:\Science\Matlab\spm8\config\spm_cfg_eeg_convert.m" (v3059),
>>>> function "eeg_convert" at line 231.
>>>>
>>>> The following modules did not run:
>>>> Failed: M/EEG Conversion
>>>>
>>>>
>>>> Thanks for any help,
>>>> regards, jakob
>>>>
>>>
>>
>
% read_eeglabdata() - import EEGLAB dataset files
%
% Usage:
% >> dat = read_eeglabdata(filename);
%
% Inputs:
% filename - [string] file name
%
% Optional inputs:
% 'begtrial' - [integer] first trial to read
% 'endtrial' - [integer] last trial to read
% 'chanindx' - [integer] list with channel indices to read
% 'header' - FILEIO structure header
%
% Outputs:
% dat - data over the specified range
%
% Author: Arnaud Delorme, SCCN, INC, UCSD, 2008-
%123456789012345678901234567890123456789012345678901234567890123456789012
% Copyright (C) 2008 Arnaud Delorme, SCCN, INC, UCSD, [log in to unmask]
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
% $Log: read_eeglabdata.m,v $
% Revision 1.3 2009/07/01 15:35:19 vlalit
% Try several different ways of looking for the data file
% before giving up (fix suggested by Jakob Scherer)
%
% Revision 1.2 2009/02/27 12:03:09 vlalit
% Arno's fix for a bug reported by Antanas Spokas
%
% Revision 1.1 2009/01/30 04:01:19 arno
% *** empty log message ***
%
% Revision 1.2 2008/04/21 18:45:23 roboos
% fixed bug due to sample/trial selection mixup
% only read the selected trials
%
% Revision 1.1 2008/04/18 14:04:48 roboos
% new implementation by Arno, shoudl be tested
%
function dat = read_eeglabdata(filename, varargin);
if nargin < 1
help read_eeglabdata;
return;
end;
header = keyval('header', varargin);
begsample = keyval('begsample', varargin);
endsample = keyval('endsample', varargin);
begtrial = keyval('begtrial', varargin);
endtrial = keyval('endtrial', varargin);
chanindx = keyval('chanindx', varargin);
if isempty(header)
header = read_eeglabheader(filename);
end;
if ischar(header.orig.data)
if strcmpi(header.orig.data(end-2:end), 'set'),
header.ori = load('-mat', filename);
else
% assuming that the data file is in the current directory
fid = fopen(header.orig.data);
% assuming the .dat and .set files are located in the same directory
if fid == -1
pathstr = fileparts(filename);
fid = fopen(fullfile(pathstr, header.orig.data));
end
if fid == -1
fid = fopen(fullfile(header.orig.filepath, header.orig.data)); %
end
if fid == -1, error('Cannot not find data file'); end;
% only read the desired trials
if strcmpi(header.orig.data(end-2:end), 'dat')
dat = fread(fid,[header.nSamples*header.nTrials header.nChans],'float32')';
else
dat = fread(fid,[header.nChans header.nSamples*header.nTrials],'float32')';
end;
dat = reshape(dat, header.nChans, header.nSamples, header.nTrials);
fclose(fid);
end;
else
dat = header.orig.data;
dat = reshape(dat, header.nChans, header.nSamples, header.nTrials);
end;
if isempty(begtrial), begtrial = 1; end;
if isempty(endtrial), endtrial = header.nTrials; end;
if isempty(begsample), begsample = 1; end;
if isempty(endsample), endsample = header.nSamples; end;
dat = dat(:,begsample:endsample,begtrial:endtrial);
if ~isempty(chanindx)
% select the desired channels
dat = dat(chanindx,:,:);
end
|