Skip to content

Commit

Permalink
Merge pull request #80 from roemervandermeij/partialrevertfix6c5d55e
Browse files Browse the repository at this point in the history
Partially revert a previous revert
  • Loading branch information
schoffelen committed Feb 10, 2016
2 parents 61f2687 + 692d177 commit 934162f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 25 deletions.
17 changes: 3 additions & 14 deletions ft_electrodeplacement.m
Expand Up @@ -357,8 +357,7 @@
opt.handlesfigure = h;
opt.handlesmarker = [];
opt.quit = false;
opt.ana = dat; % this will be clipped
opt.org = dat; % this will remain unclipped
opt.ana = dat;
opt.update = [1 1 1];
opt.init = true;
opt.tag = 'ik';
Expand Down Expand Up @@ -456,7 +455,7 @@ function cb_redraw(h, eventdata)
str1 = sprintf('voxel %d, index [%d %d %d]', sub2ind(mri.dim(1:3), xi, yi, zi), opt.ijk);

if opt.init
ft_plot_ortho(opt.ana, 'transform', eye(4), 'location', opt.ijk, 'style', 'subplot', 'parents', [h1 h2 h3], 'update', opt.update, 'doscale', false);
ft_plot_ortho(opt.ana, 'transform', eye(4), 'location', opt.ijk, 'style', 'subplot', 'parents', [h1 h2 h3], 'update', opt.update, 'doscale', false,'clim', opt.clim);

opt.anahandles = findobj(opt.handlesfigure, 'type', 'surface')';
parenttag = get(opt.anahandles,'parent');
Expand All @@ -473,7 +472,7 @@ function cb_redraw(h, eventdata)
opt.axis([1 3 5]) = 0.5;
opt.axis([2 4 6]) = size(opt.ana) + 0.5;
else
ft_plot_ortho(opt.ana, 'transform', eye(4), 'location', opt.ijk, 'style', 'subplot', 'surfhandle', opt.anahandles, 'update', opt.update, 'doscale', false);
ft_plot_ortho(opt.ana, 'transform', eye(4), 'location', opt.ijk, 'style', 'subplot', 'surfhandle', opt.anahandles, 'update', opt.update, 'doscale', false,'clim', opt.clim);

if all(round([xi yi zi])<=mri.dim) && all(round([xi yi zi])>0)
fprintf('==================================================================================\n');
Expand Down Expand Up @@ -955,11 +954,6 @@ function cb_minslider(h4, eventdata)
h = getparent(h4);
opt = getappdata(h, 'opt');
opt.clim(1) = newlim;
% re-apply the clipping to the original anatomy
opt.ana = opt.org;
opt.ana(opt.ana<opt.clim(1)) = opt.clim(1);
opt.ana(opt.ana>opt.clim(2)) = opt.clim(2);
opt.ana = opt.ana/(opt.clim(2)-opt.clim(1));
fprintf('contrast limits updated to [%.03f %.03f]\n', opt.clim);
setappdata(h, 'opt', opt);
cb_redraw(h);
Expand All @@ -973,11 +967,6 @@ function cb_maxslider(h5, eventdata)
h = getparent(h5);
opt = getappdata(h, 'opt');
opt.clim(2) = newlim;
% re-apply the clipping to the original anatomy
opt.ana = opt.org;
opt.ana(opt.ana<opt.clim(1)) = opt.clim(1);
opt.ana(opt.ana>opt.clim(2)) = opt.clim(2);
opt.ana = opt.ana/(opt.clim(2)-opt.clim(1));
fprintf('contrast limits updated to [%.03f %.03f]\n', opt.clim);
setappdata(h, 'opt', opt);
cb_redraw(h);
Expand Down
64 changes: 62 additions & 2 deletions ft_volumerealign.m
Expand Up @@ -326,7 +326,7 @@
case 'ortho'
% start building the figure
h = figure;
set(h, 'color', [1 1 1]);
%set(h, 'color', [1 1 1]);
set(h, 'visible', 'on');

% axes settings
Expand Down Expand Up @@ -405,6 +405,36 @@
markerlabel = {};
markercolor = {};

% determine clim if empty (setting to [0 1] could be done at the top, but not sure yet if it interacts with the other visualizations -roevdmei)
if isempty(cfg.clim)
cfg.clim = [min(dat(:)) min([.5 max(dat(:))])]; %
end

% intensity range sliders
h45text = uicontrol('Style', 'text',...
'String','Intensity',...
'Units', 'normalized', ...
'Position',[2*h1size(1)+0.03 h3size(2)+0.03 h1size(1)/4 0.04],...
'HandleVisibility','on');

h4 = uicontrol('Style', 'slider', ...
'Parent', h, ...
'Min', 0, 'Max', 1, ...
'Value', cfg.clim(1), ...
'Units', 'normalized', ...
'Position', [2*h1size(1)+0.02 0.10+h3size(2)/3 0.05 h3size(2)/2], ...
'Callback', @cb_minslider);

h5 = uicontrol('Style', 'slider', ...
'Parent', h, ...
'Min', 0, 'Max', 1, ...
'Value', cfg.clim(2), ...
'Units', 'normalized', ...
'Position', [2*h1size(1)+0.07 0.10+h3size(2)/3 0.05 h3size(2)/2], ...
'Callback', @cb_maxslider);


% instructions to the user
fprintf(strcat(...
'1. To change the slice viewed in one plane, either:\n',...
' a. click (left mouse) in the image on a different plane. Eg, to view a more\n',...
Expand All @@ -431,7 +461,7 @@
opt.handlesaxes = [h1 h2 h3];
opt.handlesfigure = h;
opt.quit = false;
opt.ana = dat;
opt.ana = dat;
opt.update = [1 1 1];
opt.init = true;
opt.tag = 'ik';
Expand Down Expand Up @@ -1495,3 +1525,33 @@ function cb_cleanup(h, eventdata)
if ~isempty(eventdata.Modifier)
key = [eventdata.Modifier{1} '+' key];
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function cb_minslider(h4, eventdata)

newlim = get(h4, 'value');
h = getparent(h4);
opt = getappdata(h, 'opt');
opt.clim(1) = newlim;
fprintf('contrast limits updated to [%.03f %.03f]\n', opt.clim);
setappdata(h, 'opt', opt);
cb_redraw(h);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function cb_maxslider(h5, eventdata)

newlim = get(h5, 'value');
h = getparent(h5);
opt = getappdata(h, 'opt');
opt.clim(2) = newlim;
fprintf('contrast limits updated to [%.03f %.03f]\n', opt.clim);
setappdata(h, 'opt', opt);
cb_redraw(h);



11 changes: 3 additions & 8 deletions plotting/ft_plot_ortho.m
Expand Up @@ -74,11 +74,6 @@
dat = cast(dat, 'double');
end

if ~isempty(clim)
% clip the data between the color limits
dat(dat<clim(1)) = clim(1);
dat(dat>clim(2)) = clim(2);
end

% determine the orientation key-value pair
keys = varargin(sellist(1:2:end));
Expand Down Expand Up @@ -158,13 +153,13 @@
hold on
end

varargin{sel+1} = ori(1,:);
varargin{2*sel} = ori(1,:);
hx = ft_plot_slice(dat, varargin{:});

varargin{sel+1} = ori(2,:);
varargin{2*sel} = ori(2,:);
hy = ft_plot_slice(dat, varargin{:});

varargin{sel+1} = ori(3,:);
varargin{2*sel} = ori(3,:);
hz = ft_plot_slice(dat, varargin{:});
axis equal; axis tight; axis off;axis vis3d
view(3);
Expand Down
2 changes: 1 addition & 1 deletion plotting/ft_plot_slice.m
Expand Up @@ -23,7 +23,7 @@
% 'interpmethod' = string specifying the method for the interpolation, see INTERPN (default = 'nearest')
% 'style' = string, 'flat' or '3D'
% 'colormap' = string, see COLORMAP
% 'colorlim' = 1x2 vector specifying the min and max for the colorscale
% 'clim' = 1x2 vector specifying the min and max for the colorscale
%
% See also FT_PLOT_ORTHO, FT_PLOT_MONTAGE, FT_SOURCEPLOT

Expand Down

0 comments on commit 934162f

Please sign in to comment.