Dear Jeremy,
On Fri, Apr 30, 2010 at 4:30 AM, Jeremy Nelson <[log in to unmask]> wrote:
> Hi Vladimir,
>
> Thanks for your patience with me as I try to delve into the SPM world!
>
> I just realized that by stripping the headers in my files and
> converting them into SPM format, I lose the bad channel information.
> Do you think passing the data through the spm_eeg_artefact after the
> conversion function would be a good approach? If so, how do you
> suggest I add that into my EEG_batch_script? I've attached my
> attempt, which doesn't quite do the auto-artefact detection and
> marking I was hoping for (it brings up the window asking for an input
> file), so I commented it out.
>
> One thing that concerned me about trying this approach was when I
> attempted to use the artefact function on one of the data files I
> created this error appeared:
>
> ??? Reference to non-existent field 'methods'.
>
> Error in ==> spm_eeg_artefact at 88
> for i = 1:numel(S.methods)
>
I suggest that once you convert your data to SPM format (which seems
to be already working) you spend some time using the GUI and getting
familiar with it before trying to write a script that will solve all
your problems. SPM M/EEG functions are configured in a particular way,
using a configuration struct S. So just writing spm_eeg_artefact(data)
will not work. A very convenient way to get started with writing
scripts is to do what you need with the GUI and then use the 'Save as
script' functionality (accessible from the reviewing tool) to generate
a corresponding script and modify it. Perhaps you should go over the
'Multimodal face-evoked responses' chapter in the manual which shows
some examples of that.
In your particular case the spm_eeg_artefact function will not help
because that function works with epoched data whereas what you have
are ERPs. I think the easiest thing for you to do is just to reject
the channels in the GUI for each subject (with the reviewing tool). If
you can with your script get the indices of the rejected channels from
your original data and put them into the variable 'ind', you can do:
D = spm_eeg_load('filename.mat');
if ~isempty(ind)
D = badchannels(D, ind, 1);
end
save(D)
> Also, just an off-topic question about this, does the overloading
> approach mean you're essentially overwriting MATLAB's save function?
> Could you have called it something like meegsave? Sorry, I'm not
> really familiar with object-oriented programming, but I appreciate
> your explanations as I learn! I took a class in Ada a long time ago
> (which I guess is object-oriented --- and obsolete?) but I don't
> remember any of that anymore.
>
You overwrite Matlab's save function but only in particular context,
when it's called with the @meeg object as the first argument. Under
other circumstances a different version of the function is called as
you found out yourself. This is more elegant than inventing a
different name for functions that do the same thing depending on their
input. In Matlab itself many functions are already overloaded and
exist in multiple instances for different objects they operate on.
Best,
Vladimir
|