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  January 2009

SPM January 2009

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: SPM8b - MEEG: reading 4D-148 sensors problem

From:

Vladimir Litvak <[log in to unmask]>

Reply-To:

Vladimir Litvak <[log in to unmask]>

Date:

Wed, 28 Jan 2009 18:36:30 +0000

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (208 lines) , read_headshape.m (1 lines)

Dear Don and Andrej,

This is quite simple. I added '4d' type where Don suggested and the
fix will propagate to SPM8 release within a few days.

@ Andrej, put the attached function in spm8/external/fileio/private
and see if it resolves your problem with fiducials. The issue of
additional channels is still not clear. If you only select 'MEG'
channels when you convert, do you get the right number. I tend to
agree with Don that those extra channels must really be there.
Otherwise SPM would probably crash and not finish the conversion.

@Don, if there any other fixes like this, it'd be very helpful.

Vladimir


On Wed, Jan 28, 2009 at 6:25 PM, Rojas Don <[log in to unmask]> wrote:
> To all:
>
> Sorry about an error in my last message.  The headshape does have the
> fiducials. Rather, there is a small error in the spm read_headshape.m
> function that prevents the relevant code block from executing when the file
> being read is a native 4D file.  Change line 88 to read:
>
> case {'4d_xyz', '4d_m4d', '4d_hs', '4d'}
>
> I added the case '4d', since that is what is the case with our data when I
> set a breakpoint in the file and read the fileformat variable.  I think the
> first two cases are for files converted using pdf2set.  The third case I'm
> not sure of and maybe it doesn't need to be there.
>
> Best,
>
> Don
>
> On 1/28/09 10:29 AM, "Vladimir Litvak" <[log in to unmask]> wrote:
>
>> Dear Don,
>>
>> If you have code for reading fiducials from a config file, send it to
>> me and I'll integrate it in read_headshape. We'd be very interested in
>> solving the other issues you have with SPM8 converters, possibly using
>> parts of your code,  because then other users will also benefit from
>> your experience.
>>
>> Best,
>>
>> Vladimir
>>
>> On Wed, Jan 28, 2009 at 5:09 PM, Rojas Don <[log in to unmask]> wrote:
>>> Dear Andrej,
>>>
>>> I think the issue you mention with respect to the fiducials is a general
>>> problem with the conversion process, as it also affects our site, which has
>>> a 248-channel 4D system.  In looking at the SPM code for reading the native
>>> 4D data, In looking at the function, it seems to me that it assumes the
>>> fiducials will be in the headshape file.  In the 4D format, they are in the
>>> config file, however.  You can always manually input them into the resulting
>>> D structure (in the .mat file output from spm_eeg_convert.m.
>>>
>>> As to the number of channels you have, the SPM routines automatically import
>>> all channels in the dataset.  Are you absolutely certain that only the MEG
>>> and reference channels are in your datasets (also, by default, there may be
>>> a Trigger channel, Response Channel and a UACurrent Channel for the coils on
>>> head)?  You can confirm this by looking at one of your datasets or at the
>>> template file you used for acquisition. On your system, there are a number
>>> of external inputs available (e.g., for EEG) that might be turned on (96 of
>>> them on our system).  When we import using the spm_eeg_convert function, we
>>> get the correct number of channels on our system.  Have you tried selecting
>>> MEG only during the import? There are numerous other problems for us, but
>>> that one is correct.  The file format for the 148 and 248 channel systems is
>>> the same, so that shouldn't be an issue.
>>>
>>> Feel free to contact me off-list if you like.  We've analyzed a lot of 4D
>>> datasets using spm5 and now spm8.  Generally we've been using our own
>>> converters because of the difficulties we've had using the spm conversion
>>> routines.
>>>
>>> Best,
>>>
>>> Don
>>>
>>>
>>> On 1/28/09 4:14 AM, "Vladimir Litvak" <[log in to unmask]> wrote:
>>>
>>>> Dear Andrej,
>>>>
>>>> The message is actually quite informative about the problem. SPM uses
>>>> routines for reading BTi data developed by Jan-Mathijs Schoffelen from
>>>> Glasgow. As said in the message there might be problem having to do
>>>> with the fact that your BTi sytem is different from his. It looks like
>>>> the conversion proceeds to the end but as you say the results are
>>>> incorrect. SPMs messages except for Jan-Mathijs's warnings are normal
>>>> and do not indicate a problem.  I suggest that you get in touch with
>>>> Jan-Mathijs ([log in to unmask]) and ask for his help in
>>>> resolving the problem. Also if there are other BTi users on the list
>>>> who can help with resolving this problem I suggest that they contact
>>>> Jan-Mathijs with their suggestions.
>>>>
>>>> Best,
>>>>
>>>> Vladimir
>>>>
>>>> On Wed, Jan 28, 2009 at 10:49 AM, Andrej Stancak
>>>> <[log in to unmask]> wrote:
>>>>> Dear SPM experts,
>>>>>
>>>>>  I have tried to load our 4D MEG data set, that has 148 MEG sensors and 17
>>>>> non-MEG signals (=165), into SPM8b. After calling Convert from the GUI, I
>>>>> get a lengthy message (below) but what is worse, the number of channels
>>>>> read
>>>>> is wrong - it is 290 instead of the correct number 165. Also fiducials are
>>>>> not read (however, they are available in the header), and other information
>>>>> seems to be missing as well. I would be grateful for adjusting the reading
>>>>> of MEG data for 4D-148 sensors machine, if possible.
>>>>>
>>>>> Best regards
>>>>> Andrej Stancak
>>>>>
>>>>>
>>>>> Here is the message I get by calling Convert in SPM8b:
>>>>>
>>>>> Warning: reading in weight table: no warranty that this is correct. it
>>>>> seems
>>>>> to work for the
>>>>> Glasgow 248-magnetometer system. if you have some code yourself, and/or
>>>>> would like to test it
>>>>> on your own data, please contact Jan-Mathijs
>>>>>> In fileio\private\read_4d_hdr at 252
>>>>>  In fileio\private\read_header at 474
>>>>>  In fileio_read_header at 11
>>>>>  In spm_eeg_convert at 73
>>>>>  In spm_eeg_convert_ui at 81
>>>>> Warning: reading in weight table: no warranty that this is correct. it
>>>>> seems
>>>>> to work for the
>>>>> Glasgow 248-magnetometer system. if you have some code yourself, and/or
>>>>> would like to test it
>>>>> on your own data, please contact Jan-Mathijs
>>>>>> In fileio\private\read_4d_hdr at 252
>>>>>  In fileio\private\read_header at 474
>>>>>  In fileio\private\read_event at 426
>>>>>  In fileio_read_event at 11
>>>>>  In spm_eeg_convert at 95
>>>>>  In spm_eeg_convert_ui at 81
>>>>> converting units from 'm' to 'mm'
>>>>> Warning: reading in weight table: no warranty that this is correct. it
>>>>> seems
>>>>> to work for
>>>>> the Glasgow 248-magnetometer system. if you have some code yourself, and/or
>>>>> would like to
>>>>> test it on your own data, please contact Jan-Mathijs
>>>>>> In fileio\private\read_4d_hdr at 252
>>>>>  In fileio\private\read_header at 474
>>>>>  In fileio\private\read_sens at 146
>>>>>  In fileio\private\read_headshape at 144
>>>>>  In fileio_read_headshape at 11
>>>>>  In spm_eeg_convert at 398
>>>>>  In spm_eeg_convert_ui at 81
>>>>> Warning: Could not obtain fiducials automatically.
>>>>>> In spm_eeg_convert at 400
>>>>>  In spm_eeg_convert_ui at 81
>>>>> 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.grad
>>>>> creating layout for bti148 system
>>>>>
>>>
>>> --
>>> Donald C. Rojas, Ph.D.
>>> Associate Professor of Psychiatry and Neuroscience
>>> Director, Magnetoencephalography Laboratory
>>> University of Colorado Denver
>>> Department of Psychiatry, Mail Stop F-546
>>> Anschutz Medical Campus, Building 500 N2224G
>>> 13001 E 17th Place
>>> PO Box 6508
>>> Aurora CO 80045-0508
>>> 303-724-4994
>>> [log in to unmask]
>>>
>>> Please note: My email address has changed from [log in to unmask] to
>>> [log in to unmask]  Please update your records.
>>>
>
> --
> Donald C. Rojas, Ph.D.
> Associate Professor of Psychiatry and Neuroscience
> Director, Magnetoencephalography Laboratory
> University of Colorado Denver
> Department of Psychiatry, Mail Stop F-546
> Anschutz Medical Campus, Building 500 N2224G
> 13001 E 17th Place
> PO Box 6508
> Aurora CO 80045-0508
> 303-724-4994
> [log in to unmask]
>
> Please note: My email address has changed from [log in to unmask] to
> [log in to unmask]  Please update your records.
>
>



function [shape] = read_headshape(filename, varargin) % READ_HEADSHAPE reads the fiducials and/or the measured headshape % from a variety of files (like CTF and Polhemus). The headshape and % fiducials can for example be used for coregistration. % % Use as % [shape] = read_headshape(filename) % % See also READ_VOL, READ_SENS % Copyright (C) 2008, Robert Oostenveld % % $Log: read_headshape.m,v $ % Revision 1.8 2009/01/28 18:29:07 vlalit % Added '4d' type to BTi case % % Revision 1.7 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.6 2008/10/07 16:22:32 roboos % added option to specify coordinates to be obtained from ctf hc file % % Revision 1.5 2008/05/22 14:33:18 vlalit % Changes related to generalization of fiducials' handling in SPM. % % Revision 1.4 2008/05/11 16:30:30 vlalit % Improved the support of 4d and neuromag % % Revision 1.3 2008/04/16 08:04:03 roboos % allow headshape to be extracted from BEM volume conduction model % % Revision 1.2 2008/04/14 20:52:11 roboos % ensure consistent output for all file formats (thanks to Vladimir) % added convert_units % % Revision 1.1 2008/04/11 12:04:55 roboos % new impoementation, required for clean interface towards SPM % % test whether the file exists if ~exist(filename) error(sprintf('file ''%s'' does not exist', filename)); end % get the options fileformat = keyval('fileformat', varargin); coordinates = keyval('coordinates', varargin); if isempty(coordinates), coordinates = 'head'; end if isempty(fileformat) fileformat = filetype(filename); end % start with an empty structure shape = []; shape.pnt = []; shape.fid.pnt = []; shape.fid.label = {}; switch fileformat case {'ctf_ds', 'ctf_hc', 'ctf_meg4', 'ctf_res4'} [p, f, x] = fileparts(filename); if strcmp(fileformat, 'ctf_ds') filename = fullfile(p, [f x], [f '.hc']); elseif strcmp(fileformat, 'ctf_meg4') filename = fullfile(p, [f '.hc']); elseif strcmp(fileformat, 'ctf_res4') filename = fullfile(p, [f '.hc']); end orig = read_ctf_hc(filename); switch coordinates case 'head' shape.fid.pnt = cell2mat(struct2cell(orig.head)); case 'dewar' shape.fid.pnt = cell2mat(struct2cell(orig.dewar)); otherwise error('incorrect coordinates specified'); end shape.fid.label = fieldnames(orig.head); case 'ctf_shape' orig = read_ctf_shape(filename); shape.pnt = orig.pnt; shape.fid.label = {'NASION', 'LEFT_EAR', 'RIGHT_EAR'}; for i = 1:numel(shape.fid.label) shape.fid.pnt = cat(1, shape.fid.pnt, ... getfield(orig.MRI_Info, shape.fid.label{i})); end case {'4d_xyz', '4d_m4d', '4d_hs', '4d'} [p, f, x] = fileparts(filename); if ~strcmp(fileformat, '4d_hs') filename = fullfile(p, 'hs_file'); end [shape.pnt, fid] = read_bti_hs(filename); % I'm making some assumptions here % which I'm not sure will work on all 4D systems fid = fid(1:3, :); [junk, NZ] = max(fid(:,1)); [junk, L] = max(fid(:,2)); [junk, R] = min(fid(:,2)); shape.fid.pnt = fid([NZ L R], :); shape.fid.label = {'NZ', 'L', 'R'}; case 'neuromag_fif' [co,ki,nu] = hpipoints(filename); fid = co(:,find(ki==1))'; [junk, NZ] = max(fid(:,2)); [junk, L] = min(fid(:,1)); [junk, R] = max(fid(:,1)); shape.fid.pnt = fid([NZ L R], :); shape.fid.label = {'NZ', 'L', 'R'}; case 'neuromag_mne' hdr = read_header(filename,'headerformat','neuromag_mne'); nFid = size(hdr.orig.dig,2); %work out number of fiducials switch coordinates case 'head' % digitiser points should be stored in head coordinates by default fidN=1; pntN=1; for i=1:nFid %loop over fiducials %check this point is in head coordinates: if hdr.orig.dig(i).coord_frame~=4 % 4 is MNE constant for head coordinates error(['Digitiser point (' num2str(i) ') not stored in head coordinates!']); end switch hdr.orig.dig(i).kind % constants defined in MNE - see p.215 of MNE manual case 1 % Cardinal point (nasion, LPA or RPA) %get location of fiducial: shape.fid.pnt(fidN,1:3) = hdr.orig.dig(i).r*100; %multiply by 100 to convert to cm switch hdr.orig.dig(i).ident case 1 % LPA shape.fid.label{fidN} = 'LPA'; case 2 % nasion shape.fid.label{fidN} = 'Nasion'; case 3 % RPA shape.fid.label{fidN} = 'RPA'; otherwise error('Unidentified cardinal point in file!'); end fidN = fidN + 1; case 2 % HPI coil shape.pnt(pntN,1:3) = hdr.orig.dig(i).r*100; pntN = pntN + 1; case 3 % EEG electrode location (or ECG) shape.pnt(pntN,1:3) = hdr.orig.dig(i).r*100; pntN = pntN + 1; case 4 % Additional head point shape.pnt(pntN,1:3) = hdr.orig.dig(i).r*100; pntN = pntN + 1; otherwise warning('Unidentified digitiser point in file!'); end end shape.fid.label=shape.fid.label'; case 'dewar' error('Dewar coordinates not supported for headshape yet (MNE toolbox)'); otherwise error('Incorrect coordinates specified'); end case 'polhemus_fil' [shape.fid.pnt, shape.pnt, shape.fid.label] = read_polhemus_fil(filename, 0); case 'spmeeg_mat' tmp = load(filename); if isfield(tmp.D, 'fiducials') && ~isempty(tmp.D.fiducials) shape = tmp.D.fiducials; else error('no headshape found in SPM EEG file'); end case 'matlab' tmp = load(filename); if isfield(tmp, 'shape') shape = tmp.shape; elseif isfield(tmp, 'elec') shape.fid.pnt = tmp.elec.pnt; shape.fid.label = tmp.elec.label; else error('no headshape found in Matlab file'); end otherwise success = 0; if ~success % try reading it as electrode positions % and treat those as fiducials try elec = read_sens(filename); if ~senstype(elec, 'eeg') error('headshape information can not be read from MEG gradiometer file'); else shape.fid.pnt = elec.pnt; shape.fid.label = elec.label; success = 1; end end end if ~success % try reading it as volume conductor % and treat the skin surface as headshape try vol = read_vol(filename); if ~voltype(vol, 'bem') error('skin surface can only be extracted from boundary element model'); else if ~isfield(vol, 'skin') vol.skin = find_outermost_boundary(vol.bnd); end shape.pnt = vol.bnd(vol.skin).pnt; shape.tri = vol.bnd(vol.skin).tri; % also return the triangulation success = 1; end end end if ~success error('unknown fileformat for head shape information'); end end % this will add the units to the head shape shape = convert_units(shape);

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
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

For help and support help@jisc.ac.uk

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