JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for SPM Archives


SPM Archives

SPM Archives


SPM@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  July 2009

SPM July 2009

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: bug report: spm8 convert epoched eeglab file

From:

Vladimir Litvak <[log in to unmask]>

Reply-To:

Vladimir Litvak <[log in to unmask]>

Date:

Thu, 2 Jul 2009 11:33:09 +0100

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (210 lines) , read_sens.m (1 lines)

Dear Jakob,

You can put the attached file in /external/fileio/private to remove
that warning and slightly improve the handling of your dataset. The
warning has to do with the fact that your EEGLAB dataset does not
contain fiducials which SPM needs to do proper coregistration. It is
possible to use electrode locations as fiducials if you can find the
corresponding points at the structural scan. That's what the attached
code will do. However, if the electrode locations you had in EEGLAB
are just standard locations, you should just assign default sensor
locations using the 'Prepare' interface. That will make things
somewhat more straightforward. Also if you have individually measured
electrode locations you can load them to SPM using for instance .sfp
format (see the manual).

Best,

Vladimir


On Thu, Jul 2, 2009 at 11:07 AM, Jakob Scherer<[log in to unmask]> wrote:
> Dear Vladimir,
> the conversion runs successfully on my workstation too, now.
> btw i still get the following warnings. but i think it's a minor
> issue, i'll get back to it later
> -----------------------------------------------------------------------
> Running job #1
> -----------------------------------------------------------------------
> Running 'M/EEG Conversion'
>
> SPM8: spm_eeg_channelselection (v2866)             12:01:28 - 02/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
> Done    'M/EEG Conversion'
> Done
>
>
> thanks a lot,
> jakob
>
> On Wed, Jul 1, 2009 at 6:06 PM, Vladimir
> Litvak<[log in to unmask]> wrote:
>> Dear Jakob,
>>
>> I could reproduce the error. It comes down to Arno's bug in
>> read_eeglabheader. I fixed the bug and the conversions completes
>> successfully. Put the attached file in /external/fileio/private. Let
>> me know if you have any additional problems.
>>
>> Best,
>>
>> 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
>>>>>>
>>>>>
>>>>
>>>
>>
>



function [sens] = read_sens(filename, varargin) % READ_SENS read sensor positions from various manufacturer specific files. % Currently supported are ASA, BESA, Polhemus and Matlab for EEG % electrodes and CTF and Neuromag for MEG gradiometers. % % Use as % grad = read_sens(filename, ...) % for gradiometers % elec = read_sens(filename, ...) % for electrodes % % Additional options should be specified in key-value pairs and can be % 'fileformat' string % % An electrode definition contain the following fields % elec.pnt Nx3 matrix with carthesian (x,y,z) coordinates of each electrodes % elec.label cell-array of length N with the label of each electrode % % A gradiometer definition generally consists of multiple coils per % channel, e.g.two coils for a 1st order gradiometer in which the % orientation of the coils is opposite. Each coil is described % separately and a large "tra" matrix (can be sparse) has to be % given that defines how the forward computed field is combined over % the coils to generate the output of each channel. The gradiometer % definition constsis of the following fields % grad.pnt Mx3 matrix with the position of each coil % grad.ori Mx3 matrix with the orientation of each coil % grad.tra NxM matrix with the weight of each coil into each channel % grad.label cell-array of length N with the label of each of the channels % % See also TRANSFORM_SENS, PREPARE_VOL_SENS, COMPUTE_LEADFIELD % Copyright (C) 2005-2008, Robert Oostenveld % % $Log: read_sens.m,v $ % Revision 1.13 2009/06/03 09:52:15 roboos % added zebris_sfp % % Revision 1.12 2009/02/02 16:10:15 vlalit % Provide the 'headertype' argument to the internal read_header call. % % Revision 1.11 2009/01/23 10:32:55 vlalit % New reader for Neuromag fif format using the MNE toolbox (http://www.nmr.mgh.harvard.edu/martinos/userInfo/data/sofMNE.php) implemented by Laurence Hunt. % % Revision 1.10 2008/09/18 10:38:33 vlalit % Added 4D formats to be recognized by read_sens % % Revision 1.9 2008/05/22 14:33:18 vlalit % Changes related to generalization of fiducials' handling in SPM. % % Revision 1.8 2008/04/14 20:51:36 roboos % added convert_units % % Revision 1.7 2008/04/11 16:17:22 roboos % added polhemus_fil % % Revision 1.6 2008/03/20 13:43:14 roboos % added support for besa_pos % % Revision 1.5 2008/03/18 12:34:30 roboos % fixed bug: added varargin to input arguments, thanks to Juan % % Revision 1.4 2008/03/06 09:27:54 roboos % updated documentation % % Revision 1.3 2008/03/05 11:06:11 roboos % test the presence of the fileio toolbox, needed when this function is included in forwinv % % Revision 1.2 2008/03/05 10:54:05 roboos % added optional argument for fileformat % some documentation changes % % Revision 1.1 2008/01/28 20:10:11 roboos % new functions based on existing fieldtrip code % % test whether the file exists if ~exist(filename) error(sprintf('file ''%s'' does not exist', filename)); end % get the options fileformat = keyval('fileformat', varargin); % determine the filetype if isempty(fileformat) fileformat = filetype(filename); end switch fileformat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % read the content from various files that contain EEG electrode positions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'asa_elc' sens = read_asa_elc(filename); case 'polhemus_pos' sens = read_brainvision_pos(filename); case 'besa_pos' tmp = importdata(filename); if ~isnumeric(tmp) error('unexpected file format for fileformat=besa_pos') end [nchan,nrow] = size(tmp); if nrow==3 sens.pnt = tmp; elseif nrow==9 pnt1 = tmp(:,1:3); % bottom coil pnt2 = tmp(:,4:6); % top coil ori = tmp(:,7:9); % orientation of bottom coil sens.pnt = [pnt1; pnt2]; sens.ori = [ori; ori]; sens.tra = [eye(nchan) -eye(nchan)]; else error('unexpected file format for fileformat=besa_pos') end [p, f, x] = fileparts(filename); elpfile = fullfile(p, [f '.elp']); elafile = fullfile(p, [f '.ela']); if exist(elpfile, 'file') warning(sprintf('reading channel labels from %s', elpfile)); % read the channel names from the accompanying ELP file lbl = importdata(elpfile); sens.label = strrep(lbl.textdata(:,2) ,'''', ''); elseif exist(elafile, 'file') warning(sprintf('reading channel labels from %s', elafile)); % read the channel names from the accompanying ELA file lbl = importdata(elafile); lbl = strrep(lbl, 'MEG ', ''); % remove the channel type lbl = strrep(lbl, 'EEG ', ''); % remove the channel type sens.label = lbl; else % the file does not have channel labels in it warning('creating fake channel names for besa_pos'); for i=1:nchan sens.label{i} = sprintf('%03d', i); end end case 'besa_sfp' fid = fopen(filename); tmp = textscan(fid, ' %[^ \t]%n%n%n'); fclose(fid); sens.label = tmp{1}; sens.pnt = [tmp{2:4}]; case 'neuromag_mne' hastoolbox('fileio'); hdr = read_header(filename,'headerformat','neuromag_mne'); sens = hdr.elec; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % gradiometer information is always stored in the header of the MEG dataset % hence uses the standard fieldtrip/fileio read_header function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ctf_ds', 'ctf_res4', 'neuromag_fif', '4d', '4d_pdf', '4d_m4d', '4d_xyz', 'yokogawa_ave', 'yokogawa_con', 'yokogawa_raw'} % check the availability of the required low-level toolbox % this is required because the read_sens function is also on itself included in the forwinv toolbox hastoolbox('fileio'); hdr = read_header(filename, 'headerformat', fileformat); sens = hdr.grad; case 'neuromag_mne_grad' hastoolbox('fileio'); hdr = read_header(filename,'headerformat','neuromag_mne'); sens = hdr.grad; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This is for EEG formats where electrode positions can be stored with the data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'spmeeg_mat', 'eeglab_set'} % check the availability of the required low-level toolbox % this is required because the read_sens function is also on itself included in the forwinv toolbox hastoolbox('fileio'); hdr = read_header(filename); if isfield(hdr, 'grad') sens = hdr.grad; elseif isfield(hdr, 'elec') sens = hdr.elec; else error('no electrodes or gradiometers found in the file') end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % these are created at the FIL in London with a polhemus tracker %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'polhemus_fil' [sens.fid, sens.pnt] = read_polhemus_fil(filename, 0); % the file does not have channel labels in it warning('no channel names in polhemus file, using numbers instead'); for i=1:size(sens.pnt, 1) sens.label{i} = sprintf('%03d', i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % matlab files can contain either electrodes or gradiometers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'matlab' matfile = filename; % this solves a problem with the matlab compiler v3 warning('off', 'MATLAB:load:variableNotFound'); tmp = load(matfile, 'elec', 'grad', 'sens', 'elc'); warning('on', 'MATLAB:load:variableNotFound'); if isfield(tmp, 'grad') sens = getfield(tmp, 'grad'); elseif isfield(tmp, 'elec') sens = getfield(tmp, 'elec'); elseif isfield(tmp, 'sens') sens = getfield(tmp, 'sens'); elseif isfield(tmp, 'elc') sens = getfield(tmp, 'elc'); else error('no electrodes or gradiometers found in Matlab file'); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % these are created by a Zebris tracker, at CRC in Liege at least. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case 'zebris_sfp' [sens.fid, sens.pnt, sens.fid_label, sens.label] = read_zebris(filename, 0); otherwise error('unknown fileformat for electrodes or gradiometers'); end if senstype(sens, 'eeg') % only keep positions and labels in case of EEG electrodes dum = sens; sens = []; sens.pnt = dum.pnt; sens.label = dum.label; end % this will add the units to the sensor array sens = convert_units(sens);

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager