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:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  2006

SPM 2006

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

converting EEG in Analyzer format to SPM

From:

Yael Weisberger <[log in to unmask]>

Reply-To:

Yael Weisberger <[log in to unmask]>

Date:

Tue, 21 Feb 2006 11:45:21 +0000

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (265 lines)

Hello Sally,
I did manage to over come the problem.
I added this line to the script:
D.events.types=[1];
 I don't know if/ what is the fundamental difference between :
D.events.types and D.events.type. Perhaps they have the same function and
it's just a typo?

I added several more things to the script:
D.data=[]
D.events.blinks = zeros(1, D.events.Ntypes);
D.events.repl=150;

 Also note that although the number of samples (D.Nsamples) is X,
the total: D.events.start+ D.events.stop, should add up to X-1.

D.Nsamples = 154;
D.events.start = 25
D.events.stop = 128; %154-25-1

And another important thing: EOG channels should always be at the end of
the converted data file.

-I didn't export additional EXG channels (like nose, mastoids), I think
additional modifications are needed for this.

I am sending the script I use, I wrote 'CHANGE' by the lines I added or
changed.
The script receives a directory containing all the .dat , .vhdr files
created by Analyzer. Each analyzer data-file is an average of 1 condition
for 1 subject.

Good luck,
Yael.

----------------
Hello Yael,

My name is Sally, I'm a PhD student at Nottingham University, UK. I read
your email from the spm archive regarding the use of the averaged EEG data
by Analyzer software in spm5. We managed to convert the averaged data to
SPM (.mat and .dat files) but it gives us the same error you got when using
the 2D interpolation.

??? Reference to non-existent field 'types'.

Error in ==> spm_eeg_convertmat2ana at 78
        Itrials = find(D{k}.events.code == D{k}.events.types(i) & ~D
{k}.events.reject);

Error in ==> spm_eeg_TF_images at 206
    spm_eeg_convertmat2ana(S);

??? Error while evaluating uicontrol Callback.

 I wonder if you made any further progress in this (since I saw you had
questions on later steps in the processing on the mail list).

Sorry for any inconvenience. Thank you very much for any help.

Regards,
Sally




--1:-?Dc8(7XUlfFi.bFkj+SC.TIDqS3wGDB+ZQ-qyyQ-BWQymjUzRt(b7ijVZ?z,:+-Gaq)
Content-Transfer-Encoding: 7bit
Content-Type: TEXT/PLAIN;
 name="meeg_read_data_Analyzer.m"

% This is an example script to convert epoched and averaged data (ERP/ERF)
% to SPM format. Please adapt to your needs.

%The script receives a directory containing all the .dat , .vhdr files
%created by Analyzer and converts them to SPM format.
%Modified by Yael Weisberger HCNL-HUJI

clear all

%-----------------------------------
% part 1: information about the data
%-----------------------------------
% change the following values according to your data
%to make life easier evrey variable you need to change will be marked by
%[*UPDATE_VAR*]

%%[*UPDATE_VAR*]- the name of the directory containing all the .dat , .vhdr files
INPUT_DIRECTORY_NAME='L:\Methodology\SPM\testing_tool\Yael\try\MMN_Dyslexia_data\Data';


                                                                                                
%--------------------------------------------------------------------------



INPUT_DIR = dir([INPUT_DIRECTORY_NAME,'\*.dat']);
    for i = 1: length(INPUT_DIR)
     DATA_FILE=INPUT_DIR(i).name ;
     
     
% %[*UPDATE_VAR*]- sampling rate in Hz (usually 256)
D.Radc = 256;

% %[*UPDATE_VAR*] -Number of time bins in peri-stimulus time
D.Nsamples = 154; %header says 154 but SPM read 155

%%[*UPDATE_VAR*]- Number of ERPs (if you export avraged data, this is 1)
D.Nevents = 1;

% %[*UPDATE_VAR*]- channel template file
D.channels.ctf = 'biosemi_only32.mat'; %from:K:\CommonResources\Tools\Matlab_Tools\spm5\EEGtemplates

%%[*UPDATE_VAR*]- Names of channels in order of the data in analyzer, EOG
%%should always be at the end
D.channels.name = { 'Fp1', 'AF3', 'F7', 'F3', 'FC1', 'FC5', 'T7', 'C3', 'CP1', 'CP5', 'P7' , 'P3', 'Pz', 'PO3', 'O1' , 'Oz' , 'O2' , 'PO4', 'P4', 'P8' , 'CP6' , 'CP2', 'C4' , 'T8' , 'FC6' , 'FC2', 'F4' , 'F8' , 'AF4' , 'Fp2' , 'Fz' , 'Cz','VEOG', 'HEOG'};
Analyzer_EOG_Order_FLAG= 1; %if the EOG channels in the Analyzer foramt ( .dat) are are at the
                                                                                                    % begining of the list flag=1, if at the end flag=0
D.Nchannels = length(D.channels.name);
%D.Nchannels.exg=[36 37]; %CHANGE: 23.1.06
% %[*UPDATE_VAR*]index vector of bad channels
D.channels.Bad = [];

% %[*UPDATE_VAR*]- nr of time bins before stimulus onset (this excludes the time bin at
% zero)
D.events.start = 25;% 100/3.9 %change from:26 to 25, since I get an error in the display- no match between num of events and data. I can also do the change in spm_eeg_display_ui

% %[*UPDATE_VAR*]- nr of time bins after stimulus onset (this excludes the time bin at
% zero)
D.events.stop = 128; %154-26


% name of SPM mat file

D.fname = [strtok(DATA_FILE,'.'),'_SPM.mat'];


D.modality = 'EEG';
D.units = '\muV';
D.data=[]; % CHANGE 23.1.06




%-------------------------------------
% Don't change these
D.channels.reference = 0;
D.channels.ref_name = 'none';
%D.channels.exg=[ 35 36 37];%CHANGE: 23.1.06: m2,m1


D.events.type = [1:D.Nevents];
D.events.Ntypes = length(D.events.type);
D.events.code = [1:D.Nevents];
D.events.reject = zeros(1, D.events.Ntypes);
D.events.blinks = zeros(1, D.events.Ntypes); %CHANGE: 23.1.06
D.events.time=[];
D.events.types=[1];
AveragedSegments_DEFAULT=150; %CHANGE: 23.1.06
 D.events.repl=AveragedSegments_DEFAULT; %CHANGE number of segments avreged together
 
%finding AveragedSegments field in vhdr file, for D.events.repl %ADDED
%13.2.06
header_file=[ INPUT_DIRECTORY_NAME,'\',strtok(DATA_FILE,'.') , '.vhdr'];
file_lines=textread(char(header_file),'%s','delimiter','\n','whitespace','');
       
         i=1;
             while ( isempty(strfind(file_lines{i},'AveragedSegments')) ) & (length(file_lines)>i)
                 i=i+1;
             end
               if ~isempty(strfind(file_lines{i},'AveragedSegments'))
                [tmp,num_seg] = strtok(file_lines{i},'=');
                num_seg=num_seg(2:length(num_seg));
               D.events.repl=[str2num(num_seg)];
               else
                   warning('no AveragedSegments field in file');
                   end
               





D.path = fileparts(D.fname); % Q: 23.1.06- why is this field empty? which path should it contain?
D.fname = spm_str_manip(D.fname, 't');
D.fnamedat = [spm_str_manip(D.fname, 'r') '.dat'];

%----------------------------------------------------
% part 2: read data: adapt this to read your own data
%----------------------------------------------------


%data = randn(D.Nchannels, D.Nsamples, D.Nevents);
data=load([INPUT_DIRECTORY_NAME,'\',DATA_FILE]);
if Analyzer_EOG_Order_FLAG==1
    data=circshift(data, [-2, 0]); % CHANGE 31.1.06- SPM assumes EEG data is in the begining, and EOG,exg at the end- this shifts the heog, veog to the end
end
%-----------------------------------
% part 3: write data, don't change
%-----------------------------------
Csetup = load(fullfile(spm('dir'), 'EEGtemplates', D.channels.ctf));

% Map name of channels (EEG only) to channel order specified in channel
% template file.
D.channels.heog = find(strncmpi('HEOG', D.channels.name, 4));
if isempty(D.channels.heog)
    warning(sprintf('No HEOG channel found.'));
    D.channels.heog = 0;
else
    D.channels.heog = D.channels.heog(1) ;
end

D.channels.veog = find(strncmpi('VEOG', D.channels.name, 4));
if isempty(D.channels.veog)
    warning(sprintf('No VEOG channel found.'));
    D.channels.veog = 0;
else
    D.channels.veog = D.channels.veog(1);
end

D.channels.eeg = setdiff([1:D.Nchannels], [D.channels.veog D.channels.heog ]);%D.channels.exg ]); %CHANGE 23.1.06: what about exg channels? (33 34 35)

for i = D.channels.eeg
index = [];
for j = 1:Csetup.Nchannels
if ~isempty(find(strcmpi(D.channels.name{i}, Csetup.Cnames{j})))
index = [index j];
end
end
    
if isempty(index)
warning(sprintf('No channel named %s found in channel template file.', D.channels.name{i}));
else
% take only the first found channel descriptor
D.channels.order(i) =index(1);
end

end
 %D.channels.order(33) =33;%CHANGE 31.1.06
 %D.channels.order(34) =34;%CHANGE 31.1.06


D.scale = ones(D.Nchannels, 1);
D.datatype = 'float32';

fpd = fopen(fullfile(D.path, D.fnamedat), 'w');

D.scale(:, 1) =spm_eeg_write(fpd, data, 2, D.datatype); %was in a comment -check!!!


fclose(fpd);

if str2num(version('-release'))>=14
    save(fullfile(D.path, D.fname), '-V6', 'D');
else
    save(fullfile(D.path, D.fname), 'D');
end

spm('Pointer', 'Arrow');

    end


--1:-?Dc8(7XUlfFi.bFkj+SC.TIDqS3wGDB+ZQ-qyyQ-BWQymjUzRt(b7ijVZ?z,:+-Gaq)--

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

May 2024
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