Print

Print


Dear Shingo,

Normally you would have all the conditions for each subject in the
same file. One slight problem is that condition labels are not
converted from EEGLAB to SPM but the order is preserved so you can
relabel your conditions after conversion either in the reviewing tool
(info/trials) paste the label list e.g. from Excel and then press
'update' and 'save'. Or you can do it in code:

D = spm_eeg_load(filename)
D = conditions(D, ':', {'label1', 'label2', ....'labelN'});
save(D);

To convert many files in a loop you could do:

files = {'file1.set', ...'fileN.set'};

for i = 1:numel(files)
   D = spm_eeg_convert(files{i});
end

or if you want to use batch you could do:

matlabbatch = {};
matlabbatch{1}.spm.meeg.convert.mode.epoched.usetrials = 1;
matlabbatch{1}.spm.meeg.convert.channels{1}.type = 'EEG';
matlabbatch{1}.spm.meeg.convert.eventpadding = 0;
matlabbatch{1}.spm.meeg.convert.blocksize = 100;
matlabbatch{1}.spm.meeg.convert.checkboundary = 1;
matlabbatch{1}.spm.meeg.convert.saveorigheader = 1;
matlabbatch{1}.spm.meeg.convert.inputformat = 'autodetect';

for i = 1:numel(files)
   matlabbatch{1}.spm.meeg.convert.dataset = files(i);
   matlabbatch{1}.spm.meeg.convert.outfile = 'outfile_name';
    spm_jobman('run', matlabbatch);
end

Best.

Vladimir
On Wed, Jun 13, 2018 at 1:17 AM 時本真吾 <[log in to unmask]> wrote:
>
> Dear SPM Experts,
>
> I am a beginner of SPM. I am trying to apply DCM to my EEG data, and I would like to ask you about the batch script to convert EEG data files preprocessed by EEGLAB to SPM data files.
>
> I understand that SPM data files must be independently divided to multiple data files corresponding to each experimental condition. My EEG data files of 31 participants include 6 event markers corresponding to 3 experimental conditions (2 event markers for 1 condition). I have thus made 93 EEG data files. I could convert each EEG data file to SPM data file on Batch Editor of SPM12. However,  I cannot specify multiple EEG files on Batch Editor. I would like to avoid the manual repetitions of convert process. Can I write a batch script for conversion of multiple EEG data files? The description of m files are given below. I really appreciate any comments and suggestions. Thank you in advance.
>
> ---------------------------------------
> % List of open inputs
> nrun = X; % enter the number of runs here
> jobfile = {'/Users/Warehouse/Document2/inference2018/forSPM/eeglab_convert_spm_job.m'};
> jobs = repmat(jobfile, 1, nrun);
> inputs = cell(0, nrun);
> for crun = 1:nrun
> end
> spm('defaults', 'EEG');
> spm_jobman('run', jobs, inputs{:});
>
> %-----------------------------------------------------------------------
> % Job saved on 12-Jun-2018 22:34:56 by cfg_util (rev $Rev: 6942 $)
> % spm SPM - SPM12 (7219)
> % cfg_basicio BasicIO - Unknown
> %-----------------------------------------------------------------------
> matlabbatch{1}.spm.meeg.convert.dataset = {'/Users/Warehouse/Document2/inference2018/forSPM/control/Adachi_M_control.set'};
> matlabbatch{1}.spm.meeg.convert.mode.epoched.usetrials = 1;
> matlabbatch{1}.spm.meeg.convert.channels{1}.type = 'EEG';
> matlabbatch{1}.spm.meeg.convert.outfile = 'adachi_m_control';
> matlabbatch{1}.spm.meeg.convert.eventpadding = 0;
> matlabbatch{1}.spm.meeg.convert.blocksize = 100;
> matlabbatch{1}.spm.meeg.convert.checkboundary = 1;
> matlabbatch{1}.spm.meeg.convert.saveorigheader = 1;
> matlabbatch{1}.spm.meeg.convert.inputformat = 'autodetect';
> ——————
>
> Sincerely,
>
> ******************************************
> Shingo Tokimoto, Ph.D.
> in Linguistics and Psychology
> Department of Foreign Languages
> Mejiro University
> 4-31-1, Naka-Ochiai, Shinjuku, Tokyo,
> 161-8539, Japan
> [log in to unmask]
> ******************************************