Skip to content
Snippets Groups Projects
Commit 64474cce authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Figure creation: removed code duplication

parent 93dd6f9e
No related branches found
No related tags found
No related merge requests found
......@@ -21,24 +21,14 @@ function gtFigureCreatePhase6D( phase_mat, phase_id, varargin )
% 'extras', [] );
conf = struct( ...
'lims_u', [], ...
'lims_v', [], ...
'ipf_axis', [], ...
'use_dmvol', true, ...
'abs_vol', [], ...
'abs_mask', [], ...
'filename', '', ...
'plane', 'xy', ...
'flip_ud', false, ...
'flip_lr', false, ...
'transpose', true, ...
'slice', 1, ...
'clims', [], ...
'pixel_to_cm', 0.05, ...
'borders', false, ...
'colorbar', false, ...
'extras', [] );
conf = parse_pv_pairs(conf, varargin);
'slice', 1 );
[conf, extra_pars] = parse_pv_pairs(conf, varargin);
extra_pars = [extra_pars, {'borders', false, 'colorbar', false}];
slice_ids = gtVolumeGetSlice(phase_mat.vol, conf.plane, conf.slice);
slice_size = size(slice_ids);
......@@ -93,63 +83,8 @@ function gtFigureCreatePhase6D( phase_mat, phase_id, varargin )
end
end
if (~isempty(conf.lims_u))
% Note the inversion between x/y because of matlab's transpose problem
slice_R = slice_R(conf.lims_u(1):conf.lims_u(2), :, :);
slice_G = slice_G(conf.lims_u(1):conf.lims_u(2), :, :);
slice_B = slice_B(conf.lims_u(1):conf.lims_u(2), :, :);
end
if (~isempty(conf.lims_v))
% Note the inversion between x/y because of matlab's transpose problem
slice_R = slice_R(:, conf.lims_v(1):conf.lims_v(2), :);
slice_G = slice_G(:, conf.lims_v(1):conf.lims_v(2), :);
slice_B = slice_B(:, conf.lims_v(1):conf.lims_v(2), :);
end
% Note the inversion between lr/up because of matlab's transpose problem
if (conf.flip_lr)
slice_R = fliplr(slice_R);
slice_G = fliplr(slice_G);
slice_B = fliplr(slice_B);
end
if (conf.flip_ud)
slice_R = flipud(slice_R);
slice_G = flipud(slice_G);
slice_B = flipud(slice_B);
end
if (conf.transpose)
slice_R = permute(slice_R, [2 1 3]);
slice_G = permute(slice_G, [2 1 3]);
slice_B = permute(slice_B, [2 1 3]);
end
final_slice_RGB = cat(3, slice_R, slice_G, slice_B);
img_size = [size(final_slice_RGB, 2), size(final_slice_RGB, 1)];
f = figure();
ax = axes('Parent', f);
imagesc(final_slice_RGB, 'Parent', ax);
if (~isempty(conf.clims))
set(ax, 'CLim', conf.clims)
end
if (~isempty(conf.extras))
p = gtLoadParameters();
im_props = struct( ...
'pixel_size', p.recgeo.voxsize * 1e3, ...
'size', img_size );
gtFigureAddExtras(ax, im_props, conf.extras);
end
gtFigureSetSize(f, ax, conf, img_size)
drawnow();
if (~isempty(conf.filename))
gtFigureSaveToFile(f, conf.filename);
end
gtFigureCreateFromPicture(final_slice_RGB, [], extra_pars{:});
end
function cmap = get_cmap(r_vecs, phase_id, ipf_axis)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment