Oops, I'm afraid I managed to confuse myself so there is one thing
wrong about what I said:
> 3) To copy the bad flags from one dataset to another:
>
> D1 = badchannels(D1, [], D2.badchannels);
>
That won't work for the reasons that I explained in the rest of the
e-mail. So you'll need to do something slightly more complicated:
D1 = badchannels(D1, [], 0);
if ~isempty(D2.badchannels)
D1 = badchannels(D1, D2.badchannels, 1);
end
Sorry for the confusion,
Vladimir
On Wed, Jun 16, 2010 at 3:33 PM, Vladimir Litvak <[log in to unmask]> wrote:
> Hi Rik,
>
> badchannels is one of those methods that were written at an early
> stage of @meeg development so it has a little weird syntax. On the one
> hand when it's called to set channel status the bad flag should be a
> vector of zeros and ones or just 0 or 1. On the other hand when called
> to get channel status it returns a vector of bad channel indices
> rather than a vector of flags which is what might have confused you.
> So D = badchannels(D, [], []); is not a very meaningful thing to do
> and generates an inconsistent object state. I now added some checks to
> prevent this so it won't happen from now on.
>
> I suspect that the problematic object was already in that state when
> you started with it and that's the source of your problems. Here are
> the proper ways to do what you were trying to do.
>
> 1) To set all channels to good:
>
> D = badchannels(D, [], 0);
>
> 2) To set some channels to bad
>
> D = badchannels(D, badchanind, 1); (you should check that badchanind
> is not empty, otherwise you will set all channels to bad)
>
> If you use this syntax the channels already set as bad stay bad so the
> new assignment appends new bad channels rather than replaces existing
> setting.
>
> 3) To copy the bad flags from one dataset to another:
>
> D1 = badchannels(D1, [], D2.badchannels);
>
>
> If you work with your dataset with an updated SPM from SVN there
> should be no problem any more. Please check.
>
> Best,
>
> Vladimir
>
> On Tue, Jun 15, 2010 at 5:27 PM, Rik Henson
> <[log in to unmask]> wrote:
>>
>> I know I am probably being stupid, but why can’t I set the badchannels in
>> one file (D2) to equal those in a different file (D1) with the following
>> code:
>>
>> D1 =
>> spm_eeg_load('/imaging/pg02/lcnov/S002/new_tw_TF/with_eeg/mtf_cbespm8_rep_1_raw_transUP.mat');
>> badchanind = D1.badchannels
>>
>> badchanind =
>>
>> 307 309 321 331 343 367 373 376
>>
>> D2 =
>> spm_eeg_load('/imaging/pg02/lcnov/S002/new_tw_TF/with_eeg/mtf_cbespm8_rep_1_raw_transDP.mat');
>> D2.badchannels
>> ans =
>>
>> Columns 1 through 15
>>
>> 1 2 3 4 5 6 7 8 9 10 11 12
>> 13 14 15
>>
>> Columns 16 through 26
>>
>> 16 17 18 19 20 21 22 23 24 25 26
>>
>> D2 = badchannels(D2, badchanind, ones(size(badchanind)));
>> D2.badchannels
>>
>> ans =
>>
>> Columns 1 through 15
>>
>> 1 2 3 4 5 6 7 8 9 10 11 12
>> 13 14 15
>>
>> Columns 16 through 30
>>
>> 16 17 18 19 20 21 22 23 24 25 26 27
>> 28 29 30
>>
>>
>> -à I would have thought the final answer for D2.badchannels would be 307
>> 309 321 331 343 367 373 376 ????
>>
>>
>> These files are from a colleague, so I thought they might have been screwed
>> up somehow, but I get a similar weird result if I try on one of my files,
>> which I think is correct (read in latest version of SPM8):
>>
>>>> badchanind =[ 1 5 19];
>>>> D = badchannels(D, badchanind, ones(size(badchanind)));
>>>> D.badchannels
>>
>> ans =
>>
>> 1 5 19
>>
>>
>>>> badchanind = [4 6 8];
>>>> D2 = badchannels(D2, badchanind, ones(size(badchanind)));
>>>> D2.badchannels
>>
>> ans =
>>
>> 1 4 5 6 8 19
>>
>> % ???!!!
>>
>>>> D2 = badchannels(D2, [], []);
>>>> D2 = badchannels(D2, badchanind, ones(size(badchanind)));
>>>> D2.badchannels
>>
>> ans =
>>
>> 1 2 3
>>
>> %%!!!?????!!!!!????!!!!???
>>
>> -------------------------------------------------------
>> Dr Richard Henson
>> Assistant Director, Neuroimaging
>> MRC Cognition & Brain Sciences Unit
>> 15 Chaucer Road
>> Cambridge, CB2 7EF, UK
>>
>> Office: +44 (0)1223 355 294 x522
>> Mob: +44 (0)794 1377 345
>> Fax: +44 (0)1223 359 062
>>
>> http://www.mrc-cbu.cam.ac.uk/people/rik.henson/personal
>> -------------------------------------------------------
>>
>>
>>
>
|