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

Fixed some figure creation functions

parent 48bb1cda
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,8 @@ function gtFigureCreateClusterIPF(cluster, cluster_rec, varargin)
'rotation_angle', zeros(0, 1), ...
'borders', false, ...
'colorbar', false, ...
'pixel_size', [], ...
'tight', [], ...
'extras', [] );
conf = parse_pv_pairs(conf, varargin);
......@@ -91,8 +93,8 @@ function gtFigureCreateClusterIPF(cluster, cluster_rec, varargin)
slice_B(slice_seg(:)) = cmap(:, 3);
int_vol = gtCrop(cluster_rec.ODF6D.intensity, seg_vol_bb) .* seg_vol;
slice_int_vol = gtVolumeGetSlice(int_vol, conf.plane, conf.slice, true);
slice_dm_vol = gtVolumeGetSlice(dm_vol, conf.plane, conf.slice, true);
slice_int_vol = gtVolumeGetSlice(int_vol, conf.plane, conf.slice, false);
slice_dm_vol = gtVolumeGetSlice(dm_vol, conf.plane, conf.slice, false);
% needed for the high anglular boundaries
[slice_kam, slice_gam] = gtDefComputeKernelAverageMisorientation(slice_dm_vol, slice_int_vol);
......@@ -101,8 +103,7 @@ function gtFigureCreateClusterIPF(cluster, cluster_rec, varargin)
%
% Note the inversion between lr/up because of matlab's transpose problem
if (conf.flip_ud)
if (conf.flip_lr)
slice_R = fliplr(slice_R);
slice_G = fliplr(slice_G);
slice_B = fliplr(slice_B);
......@@ -110,7 +111,7 @@ function gtFigureCreateClusterIPF(cluster, cluster_rec, varargin)
slice_seg = fliplr(slice_seg);
slice_kam = fliplr(slice_kam);
end
if (conf.flip_lr)
if (conf.flip_ud)
slice_R = flipud(slice_R);
slice_G = flipud(slice_G);
slice_B = flipud(slice_B);
......@@ -136,6 +137,33 @@ function gtFigureCreateClusterIPF(cluster, cluster_rec, varargin)
slice_skel(slice_kam_skel) = 0.5;
slice_skel(slice_kam_skel_high) = 0;
if (~isempty(conf.tight))
first_ind_1 = find(sum(slice_seg, 2), 1, 'first');
last_ind_1 = find(sum(slice_seg, 2), 1, 'last');
first_ind_2 = find(sum(slice_seg, 1), 1, 'first');
last_ind_2 = find(sum(slice_seg, 1), 1, 'last');
slice_img = slice_img(first_ind_1:last_ind_1, first_ind_2:last_ind_2, :);
slice_skel = slice_skel(first_ind_1:last_ind_1, first_ind_2:last_ind_2);
slice_seg = slice_seg(first_ind_1:last_ind_1, first_ind_2:last_ind_2);
if (numel(conf.tight) == 1)
conf.tight = conf.tight([1 1; 1 1]);
elseif (size(conf.tight, 1) == 1)
conf.tight = conf.tight([1 1], :);
elseif (size(conf.tight, 2) == 1)
conf.tight = conf.tight(:, [1 1]);
end
slice_img = padarray(slice_img, conf.tight(:, 1), 0, 'pre');
slice_skel = padarray(slice_skel, conf.tight(:, 1), 1, 'pre');
slice_seg = padarray(slice_seg, conf.tight(:, 1), false, 'pre');
slice_img = padarray(slice_img, conf.tight(:, 2), 0, 'post');
slice_skel = padarray(slice_skel, conf.tight(:, 2), 1, 'post');
slice_seg = padarray(slice_seg, conf.tight(:, 2), false, 'post');
end
f = figure();
ax = axes('parent', f);
imagesc(slice_img, 'parent', ax, ...
......
......@@ -29,12 +29,14 @@ function gtFigureCreateClusterKAM(cl, cl_rec, grs, varargin)
'slice', 1, ...
'clims', [0 1], ...
'show_labels', false, ...
'label', [], ...
'pixel_to_cm', 0.1, ...
'rotation_axes', [0 0 1], ...
'rotation_angles', zeros(0, 1), ...
'use_slice_R_vector', false, ...
'borders', true, ...
'colorbar', true, ...
'tight', [], ...
'extras', [] );
conf = parse_pv_pairs(conf, varargin);
......@@ -113,13 +115,12 @@ function gtFigureCreateClusterKAM(cl, cl_rec, grs, varargin)
slice_igm = slice_igm(vert_lims(1):vert_lims(2), horz_lims(1):horz_lims(2));
slice_seg = slice_seg(vert_lims(1):vert_lims(2), horz_lims(1):horz_lims(2));
% Note the inversion between lr/up because of matlab's transpose problem
if (conf.flip_ud)
if (conf.flip_lr)
slice_kam = fliplr(slice_kam);
slice_igm = fliplr(slice_igm);
slice_seg = fliplr(slice_seg);
end
if (conf.flip_lr)
if (conf.flip_ud)
slice_kam = flipud(slice_kam);
slice_igm = flipud(slice_igm);
slice_seg = flipud(slice_seg);
......@@ -132,14 +133,30 @@ function gtFigureCreateClusterKAM(cl, cl_rec, grs, varargin)
%
if (~isempty(conf.tight))
if (numel(conf.tight) == 1)
conf.tight = conf.tight([1 1; 1 1]);
elseif (size(conf.tight, 1) == 1)
conf.tight = conf.tight([1 1], :);
elseif (size(conf.tight, 2) == 1)
conf.tight = conf.tight(:, [1 1]);
end
slice_kam = padarray(slice_kam, conf.tight(:, 1), 0, 'pre');
slice_igm = padarray(slice_igm, conf.tight(:, 1), 0, 'pre');
slice_seg = padarray(slice_seg, conf.tight(:, 1), false, 'pre');
slice_kam = padarray(slice_kam, conf.tight(:, 2), 0, 'post');
slice_igm = padarray(slice_igm, conf.tight(:, 2), 0, 'post');
slice_seg = padarray(slice_seg, conf.tight(:, 2), false, 'post');
end
img_size = [size(slice_seg, 2), size(slice_seg, 1)];
clims_kam = [conf.clims(1), min(conf.clims(2), max(slice_kam(:)))];
f = figure();
ax = axes('parent', f);
imagesc(slice_kam', 'parent', ax, ...
'AlphaDataMapping', 'scaled', 'AlphaData', slice_seg', ...
imagesc(slice_kam, 'parent', ax, ...
'AlphaDataMapping', 'scaled', 'AlphaData', slice_seg, ...
clims_kam );
colormap(ax, jet)
......@@ -167,8 +184,8 @@ function gtFigureCreateClusterKAM(cl, cl_rec, grs, varargin)
f = figure();
ax = axes('parent', f);
imagesc(slice_igm', 'parent', ax, ...
'AlphaDataMapping', 'scaled', 'AlphaData', slice_seg', ...
imagesc(slice_igm, 'parent', ax, ...
'AlphaDataMapping', 'scaled', 'AlphaData', slice_seg, ...
clims_igm );
colormap(ax, jet);
......
function slice = gtVolumeGetSlice(vol, plane, slice_idx)
function slice = gtVolumeGetSlice(vol, plane, slice_idx, do_squeeze)
switch (lower(plane))
case 'xy'
slice = vol(:, :, slice_idx, :);
case 'yx'
slice = permute(vol(:, :, slice_idx, :), [2 1 3 4]);
case 'yz'
slice = squeeze(vol(slice_idx, :, :, :));
slice = vol(slice_idx, :, :, :);
case 'zy'
slice = permute(squeeze(vol(slice_idx, :, :, :)), [2 1 3 4]);
slice = permute(vol(slice_idx, :, :, :), [2 1 3 4]);
case 'xz'
slice = squeeze(vol(:, slice_idx, :, :));
slice = vol(:, slice_idx, :, :);
case 'zx'
slice = permute(squeeze(vol(:, slice_idx, :, :)), [2 1 3 4]);
slice = permute(vol(:, slice_idx, :, :), [2 1 3 4]);
end
if (~exist('do_squeeze', 'var') || isempty(do_squeeze) || do_squeeze)
slice = squeeze(slice);
end
end
\ No newline at end of file
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