diff --git a/toolbox/gui/view_leadfields.m b/toolbox/gui/view_leadfields.m
index 07aaea2ad5..3c0daea893 100644
--- a/toolbox/gui/view_leadfields.m
+++ b/toolbox/gui/view_leadfields.m
@@ -148,6 +148,8 @@
'Parent', hFig);
%% ===== DISPLAY LEADFIELD =====
+useLogScale = false;
+useLogScaleLegendMsg = 'Off';
% Current sensor
iChannel = 1;
DrawArrows();
@@ -201,16 +203,26 @@ function KeyPress_Callback(hFig, keyEvent)
if ~isempty(findobj(hAxes, 'Tag', 'allChannel'))
delete(findobj(hAxes, 'Tag', 'allChannel'))
end
+ case 'l'
+ if ismember('shift', keyEvent.Modifier)
+ useLogScale = ~useLogScale;
+ if (useLogScale)
+ useLogScaleLegendMsg = 'On';
+ else
+ useLogScaleLegendMsg = 'Off';
+ end
+ end
case 'h'
java_dialog('msgbox', ['
' ...
- '| Left arrow | Previous channel |
' ....
- '| Right arrow | Next channel |
'....
- '| Page up | Previous 10th channel |
'....
- '| Page down | Next 10th channel |
'....
- '| M | Change the Modality (MEG, EEG, SEEG, ECOG) |
'....
- '| R | Change the Reference electrode |
'....
- '| S | Show/hide the source grid |
'....
- '| E | Show/hide the sensors |
'], 'Keyboard shortcuts');
+ '| Left arrow | Previous channel |
' ...
+ '| Right arrow | Next channel |
'...
+ '| Page up | Previous 10th channel |
'...
+ '| Page down | Next 10th channel |
'...
+ '| M | Change the Modality (MEG, EEG, SEEG, ECOG) |
'...
+ '| R | Change the Reference electrode |
'...
+ '| S | Show/hide the source grid |
'...
+ '| E | Show/hide the sensors |
'...
+ '| Shift + l | Toggle on/off logarithmic scale |
'], 'Keyboard shortcuts');
otherwise
KeyPressFcn_bak(hQuiver, keyEvent);
return;
@@ -255,6 +267,9 @@ function DrawArrows()
end
% Display arrows
LeadField = reshape(LeadField,3,[])'; % each column is a vector
+ if(useLogScale)
+ LeadField = logScaledLeadField(LeadField);
+ end
hQuiver(iLF) = quiver3(...
HeadmodelMat{iLF}.GridLoc(:,1), HeadmodelMat{iLF}.GridLoc(:,2), HeadmodelMat{iLF}.GridLoc(:,3), ...
LeadField(:,1), LeadField(:,2), LeadField(:,3), ...
@@ -299,12 +314,12 @@ function DrawArrows()
end
% Title bar (channel name)
if isAvgRef
- strTitle = sprintf('Channel #%d/%d (%s) | %s ref Channel = AvgRef', iChannel, length(Channels), Channels(iChannel).Name,selectedModality);
+ strTitle = sprintf('Channel #%d/%d (%s) | %s ref Channel = AvgRef | Log. scale %s', iChannel, length(Channels), Channels(iChannel).Name,selectedModality, useLogScaleLegendMsg);
else
- strTitle = sprintf('Channel #%d/%d (%s) | %s ref Channel = %s', iChannel, length(Channels), Channels(iChannel).Name,selectedModality,Channels(iRef).Name);
+ strTitle = sprintf('Channel #%d/%d (%s) | %s ref Channel = %s | Log. scale %s', iChannel, length(Channels), Channels(iChannel).Name,selectedModality,Channels(iRef).Name, useLogScaleLegendMsg);
end
else
- strTitle = sprintf('Channel #%d/%d (%s)', iChannel, length(Channels), Channels(iChannel).Name);
+ strTitle = sprintf('Channel #%d/%d (%s) | Log. scale %s', iChannel, length(Channels), Channels(iChannel).Name, useLogScaleLegendMsg);
end
if (iChannel == 1) && (length(Channels) > 1)
@@ -379,4 +394,17 @@ function DrawArrows()
LF_finale{iLF} = HeadmodelMat{iLF}.Gain(iChannels,:);
end
end
+
+%% ===== LEADFIELD TO LOG SPACE =====
+ function lf_log = logScaledLeadField(lf)
+ lf_2 = lf.^2;
+ r = sqrt(sum(lf_2,2));
+ rho = sqrt(lf_2(:,1) + lf_2(:,2));
+ t = atan2(rho,lf(:,3));
+ f = atan2(lf(:,2),lf(:,1));
+ lf_log = [ log10(r) .* sin(t) .* cos(f) ...
+ log10(r) .* sin(t) .* sin(f) ...
+ log10(r) .* cos(t)];
+ end
+
end