Back to the main page.

Bug 980 - ft_prepare_vol_sens loses vol.unit along the way

Status CLOSED WORKSFORME
Reported 2011-09-22 13:58:00 +0200
Modified 2011-11-11 11:19:54 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P1 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2011-09-22 13:58:11 +0200

This is the case at least for the multisphere model. This causes problems later on when the units are assumed to exist -check whether this is also the case for the other volume conductor models -fix it


Jan-Mathijs Schoffelen - 2011-11-11 09:05:48 +0100

John suggested this: ==== git diff git-svn...HEAD -- forward/ft_prepare_vol_sens.m diff --git a/forward/ft_prepare_vol_sens.m b/forward/ft_prepare_vol_sens.m @@ -165,7 +165,8 @@ elseif ismeg % use the original sensor array instead of the one with a subset of % channels, because we need the complete mapping of coils to channels - sens = sens_orig; + %sens = sens_orig; %***JRI*** this breaks using cfg.channel to fit a + %subset of channels % remove the coils that do not contribute to any channel output % since these do not have a corresponding sphere @@ -189,7 +190,10 @@ elseif ismeg % the coil-specific spheres in the volume conductor should not have a label % because the label is already specified for the coils in the % sensor array - vol = rmfield(vol, 'label'); + % *** JRI ***: vol.label is used below, so don't remove it! + % FIXME something's wrong with the logic: should below + % use sens.label, since they are identical? + %vol = rmfield(vol, 'label'); end return end @@ -235,9 +239,16 @@ elseif ismeg chanindex = strmatch(coillabel, vol.label, 'exact'); % what is the index of this channel in the list of local spheres multisphere.r(i,:) = vol.r(chanindex); multisphere.o(i,:) = vol.o(chanindex,:); + multisphere.label{i} = vol.label{chanindex}; % *** JRI *** end - vol = multisphere; + %vol = multisphere; % *** JRI *** wrong, this clobbers other necessary fields of vol, + % so use original and only replace what has changed + vol.r = multisphere.r; + vol.o = multisphere.o; + vol.label = multisphere.label; + % *** JRI *** + % finally do the selection of channels and coils % order them according to the users specification [selchan, selsens] = match_str(channel, sens.label); @@ -253,6 +264,7 @@ elseif ismeg % make the same selection of coils in the multisphere model vol.r = vol.r(selcoil); vol.o = vol.o(selcoil,:); + vol.label = vol.label(selcoil); % *** JRI *** case 'nolte' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Jan-Mathijs Schoffelen - 2011-11-11 09:35:37 +0100

Hi John, I finally found some time to look into the issue in ft_prepare_vol_sens you reported. If I understand you correctly, the function did not behave appropriately when requesting only a subset of channels. I tried to reproduce it, but it seems to work with the present code. I did the following (using Subject01 from the ftp-server) vol = ft_read_vol('default.hdm'); %this is in Subject01.ds hdr = ft_read_header('Subject01.res4'); sens = hdr.grad; [vol2,sens2]=ft_prepare_vol_sens(vol,sens,'channel', sens.label(1:10)); Could you verify for yourself whether it works for you with the current code? Thanks. Thanks for thinking along and the suggested patch. BW, JM


Robert Oostenveld - 2011-11-11 11:19:54 +0100

I closed all bugs that were recently resolved.