Commit 26d1cb5d authored by Mark van Turnhout's avatar Mark van Turnhout
Browse files

added option for setting and getting basil data root directory

parent ddc2863e
......@@ -16,7 +16,7 @@ function bas_buildFEM(basil,param)
%
% As of yet, the following options (= default) are supported:
% param.basilhome = '~/tue/WillekeBasil/'; root folder for
% basil<xxxxxx>/data
% <basilid>/<data>
% param.seed = 1; mesh seed size [mm]
% param.elOrder = 2; 1: linear elements, 2: quadratic elements (default)
% param.ri = 1.5; indenter radius
......@@ -53,7 +53,7 @@ function bas_buildFEM(basil,param)
if nargin == 1, param.default = 1; end
% set defaults
if ~isfield(param,'basilhome'); param.basilhome = '/home/mark/tue/WillekeBasil'; end % root folder for basil<xxxxxx>/data
if ~isfield(param,'basilhome'); param.basilhome = bas_getDataRoot; end % root folder for <basilid>/<data>
if ~isfield(param,'seed'), param.seed = 1; end % mesh seed size in mm
if ~isfield(param,'elOrder'), param.elOrder = 2; end % 1: linear, 2: quadratic
if ~isfield(param,'ri'), param.ri = 1.5; end % indenter radius
......
function present = bas_checkVsize(basil)
function present = bas_checkVsize(basil, basilhome)
%
% present = bas_checkVsize(basil)
% present = bas_checkVsize(basil, basilhome)
%
% Loads
% <basilid>/contour_bone_loading.mat
% <basilid>/contour_bone_preload.mat
% <basilid>/contour_bone_postload.mat
% <basilid>/contour_skin_loading.mat
% <basilid>/contour_skin_preload.mat
% <basilhome>/<basilid>/contour_bone_loading.mat
% <basilhome>/<basilid>/contour_bone_preload.mat
% <basilhome>/<basilid>/contour_bone_postload.mat
% <basilhome>/<basilid>/contour_skin_loading.mat
% <basilhome>/<basilid>/contour_skin_preload.mat
% and checks if there are contours missing in these sets. If any contour in
% these set is missing, it is deleted from all 5 sets.
% The (updated) contours are written to <basilid>/<contour_...>-ncc.mat
% The (updated) contours are written to
% <basilhome>/<basilid>/<contour_...>-ncc.mat
%
% Needs output from bas_segmentMRI(basil,[1:4, 6])
% If basilhome is empty, data will be sought in the root-folder defined by
% bas_getDataRoot
% Needs output from bas_segmentMRI(basil,[1:4, 6]) in
% <basilhome>/<basilid>/
%
% See also bas_segmentMRI, bas_mapBone, bas_prepFEM
% See also bas_segmentMRI, bas_mapBone, bas_prepFEM, bas_getDataRoot
if nargin == 1, basilhome = bas_getDataRoot; end
for b = 1:numel(basil)
present = zeros(20,5);
load(sprintf('%i/contour_bone_loading.mat',basil(b)));
load(sprintf('%s/%i/contour_bone_loading.mat',basilhome, basil(b)));
[vbload, present(:,1)] = delEmptyWires(Vcs);
load(sprintf('%i/contour_bone_postload.mat',basil(b)));
load(sprintf('%s/%i/contour_bone_postload.mat',basilhome, basil(b)));
[vbpost, present(:,2)] = delEmptyWires(Vcs);
load(sprintf('%i/contour_bone_preload.mat',basil(b)));
load(sprintf('%s/%i/contour_bone_preload.mat',basilhome, basil(b)));
[vbpre, present(:,3)] = delEmptyWires(Vcs);
load(sprintf('%i/contour_skin_loading.mat',basil(b)));
load(sprintf('%s/%i/contour_skin_loading.mat',basilhome, basil(b)));
[vsload, present(:,4)] = delEmptyWires(Vcs);
load(sprintf('%i/contour_skin_preload.mat',basil(b)));
load(sprintf('%s/%i/contour_skin_preload.mat',basilhome, basil(b)));
[vspre, present(:,5)] = delEmptyWires(Vcs);
Vcs = vbload; Vcs(:,sum(present,2) < 5) = []; %#ok<NASGU>
save(fullfile(num2str(basil(b)),'contour_bone_loading-ncc.mat'),'Vcs');
save(fullfile(basilhome, num2str(basil(b)),'contour_bone_loading-ncc.mat'),'Vcs');
Vcs = vbpre; Vcs(:,sum(present,2) < 5) = []; %#ok<NASGU>
save(fullfile(num2str(basil(b)),'contour_bone_preload-ncc.mat'),'Vcs');
save(fullfile(basilhome, num2str(basil(b)),'contour_bone_preload-ncc.mat'),'Vcs');
Vcs = vbpost; Vcs(:,sum(present,2) < 5) = []; %#ok<NASGU>
save(fullfile(num2str(basil(b)),'contour_bone_postload-ncc.mat'),'Vcs');
save(fullfile(basilhome, num2str(basil(b)),'contour_bone_postload-ncc.mat'),'Vcs');
Vcs = vsload; Vcs(:,sum(present,2) < 5) = []; %#ok<NASGU>
save(fullfile(num2str(basil(b)),'contour_skin_loading-ncc.mat'),'Vcs');
save(fullfile(basilhome, num2str(basil(b)),'contour_skin_loading-ncc.mat'),'Vcs');
Vcs = vspre; Vcs(:,sum(present,2) < 5) = [];
save(fullfile(num2str(basil(b)),'contour_skin_preload-ncc.mat'),'Vcs');
save(fullfile(basilhome, num2str(basil(b)),'contour_skin_preload-ncc.mat'),'Vcs');
end
......
......@@ -3,7 +3,7 @@ function [tipNR, Li] = bas_estCylPos(basil, param)
%
% tipNR: [indenter tip position;
% indenter rotation matrix]
% written to HD as <basil>/Indenter_tipNR.txt
% written to HD as <param.basilhome>/<basil>/Indenter_tipNR.txt
%
% The indenter rotation matrix rotates the indenter from [0, 0, 1] to the
% determined direction.
......@@ -11,28 +11,29 @@ function [tipNR, Li] = bas_estCylPos(basil, param)
% Li: 3D logical (size(slices)) of vertices inside fitted cylinder
% written to HD as <basil>/Indenter_Lc.mat
if nargin == 1, param.figs = 0; end
if nargin == 1, param.figs = 0; param.basilhome = bas_getDataRoot; end
% set defaults
if ~isfield(param,'figs'), param.figs = 0; end % no figures
if ~isfield(param,'flash'), param.flash = 0; end % else: use flash data
if ~isfield(param,'ithres'), param.ithres = 0.2; end % indenter threshold
if ~isfield(param,'ri'), param.ri = 1.5; end % indenter threshold
if ~isfield(param,'basilhome'), param.basilhome = bas_getDataRoot; end % data root directory
for b = 1:numel(basil)
if param.flash
load(fullfile(num2str(basil(b)),'MRI_slices_flash.mat')); % image data
v = load(fullfile(num2str(basil(b)),'MRI_voxel_flash.txt'));
load(fullfile(param.basilhome, num2str(basil(b)),'MRI_slices_flash.mat')); % image data
v = load(fullfile(param.basilhome, num2str(basil(b)),'MRI_voxel_flash.txt'));
else
load(fullfile(num2str(basil(b)),'MRI_slices_loading.mat')); % image data
v = load(fullfile(num2str(basil(b)),'MRI_voxel_loading.txt'));
load(fullfile(param.basilhome, num2str(basil(b)),'MRI_slices_loading.mat')); % image data
v = load(fullfile(param.basilhome, num2str(basil(b)),'MRI_voxel_loading.txt'));
end
% Normalizing the image data
M = dataNorm(slices,1);
% load deformed skin contours
load(fullfile(num2str(basil(b)),'contour_skin_loading.mat'));
load(fullfile(param.basilhome, num2str(basil(b)),'contour_skin_loading.mat'));
Vs = bas_cylSurfPatch(Vcs,150);
Vs = Vs(~isnan(Vs(:,1)),:);
% grid for vertices
......@@ -146,11 +147,11 @@ for b = 1:numel(basil)
end
if param.flash
save(fullfile(num2str(basil(b)), 'Indenter_tipNR_flash.txt'),'tipNR', '-ascii');
save(fullfile(num2str(basil(b)), 'Indenter_Lc_flash.mat'),'Li');
save(fullfile(param.basilhome, num2str(basil(b)), 'Indenter_tipNR_flash.txt'),'tipNR', '-ascii');
save(fullfile(param.basilhome, num2str(basil(b)), 'Indenter_Lc_flash.mat'),'Li');
else
save(fullfile(num2str(basil(b)), 'Indenter_tipNR.txt'),'tipNR', '-ascii');
save(fullfile(num2str(basil(b)), 'Indenter_Lc.mat'),'Li');
save(fullfile(param.basilhome, num2str(basil(b)), 'Indenter_tipNR.txt'),'tipNR', '-ascii');
save(fullfile(param.basilhome, num2str(basil(b)), 'Indenter_Lc.mat'),'Li');
end
end
\ No newline at end of file
......@@ -5,31 +5,32 @@ function indSE = bas_estIndDisp(basil, param)
%
% output: a 2 by 3 matrix with indenter start (first row) and end (second
% row) positions.
% Output is saved to HD as <basil>/Indenter_StartEnd.txt
% Output is saved to HD as <param.basilhome>/<basil>/Indenter_StartEnd.txt
% Needs the output from bas_estCylPos and bas_segmentMRI(basil,[1 3])
%
% See also bas_estCylPos, bas_estIndStart, bas_estIndEnd, bas_segmentMRI,
% bas_prepFEM
% bas_prepFEM, bas_getDataRoot
% set defaults
if nargin == 1, param.default = 1; end
if nargin == 1, param.default = 1; param.basilhome = bas_getDataRoot; end
if ~isfield(param,'figs'), param.figs = 0; end % no figures
if ~isfield(param,'ri'), param.ri = 1.5; end % indenter radius
if ~isfield(param,'basilhome'), param.basilhome = bas_getDataRoot; end % root data directory
indSE = zeros(2,3);
for b = 1:numel(basil)
tipNR = load(fullfile(num2str(basil(b)),strcat('Indenter_tipNR.txt')));
tipNR = load(fullfile(param.basilhome, num2str(basil(b)),strcat('Indenter_tipNR.txt')));
tip = tipNR(1,:); % indenter centre of mass
R = tipNR(2:4,:); % indenter rotation matrix
idir = -R(3,:)'; % indenter long axis orientation
% load undeformed skin data
load(fullfile(num2str(basil(b)),'contour_skin_preload-ncc.mat'));
load(fullfile(param.basilhome, num2str(basil(b)),'contour_skin_preload-ncc.mat'));
% create patch data
Vs = bas_cylSurfPatch(Vcs,150);
% load deformed skin data
load(fullfile(num2str(basil(b)),'contour_skin_loading-ncc.mat'));
load(fullfile(param.basilhome, num2str(basil(b)),'contour_skin_loading-ncc.mat'));
% create patch data
Vd = bas_cylSurfPatch(Vcs,150);
......@@ -62,7 +63,7 @@ for b = 1:numel(basil)
% set indenter end position
indSE(2,1:3) = tip + D*idir';
save(fullfile(num2str(basil(b)),strcat('Indenter_StartEnd.txt')),'indSE', '-ascii');
save(fullfile(param.basilhome, num2str(basil(b)),strcat('Indenter_StartEnd.txt')),'indSE', '-ascii');
if param.figs % some graphical feedback...
......
......@@ -43,7 +43,7 @@ function bas_extractAbaPlot(basil,param)
if nargin == 1, param.default = 1; end
% set defaults
if ~isfield(param,'basilhome'); param.basilhome = '/home/mark/tue/WillekeBasil'; end % root folder for basil<xxxxxx>/data
if ~isfield(param,'basilhome'); param.basilhome = bas_getDataRoot; end % root folder for basil<xxxxxx>/data
if ~isfield(param,'prange'), param.prange = [NaN NaN]; end % set plotting value range [min max], NaN = auto compute
if ~isfield(param,'pcast'), param.pcast = 0; end % plot the cast. 0 = no (default), 1 = yes.
if ~isfield(param,'pind'), param.pind = 1; end % plot the indenter. 0 = no, 1 = yes (default).
......
function basilhome = bas_getDataRoot
% basilhome = bas_getDataRoot
%
% The root folder where <basilid>/<processed MRI-data> is to be found.
% Currently: basilhome = '/home/mark/tue/WillekeBasil';
%
% See also, bas_setDataRoot, bas_prepFEM, bas_buildFEM
%
basilhome = '/home/mark/tue/WillekeBasil';
end
function [bonepd, bonepa] = bas_mapBone(basil)
% [bonePreDuring, bonePrePost] = bas_mapBone(basil)
function [bonepd, bonepa] = bas_mapBone(basil, basilhome)
% [bonePreDuring, bonePrePost] = bas_mapBone(basil, basilhome)
%
% Maps bone displacement and rotation from preload-to-loading and from
% preload-to-postload. Needs output from bas_segmentMRI(basil,[2 4 6]).
......@@ -9,16 +9,21 @@ function [bonepd, bonepa] = bas_mapBone(basil)
% bonePreDuring(2,:) = bone centre of mass during loading
% bonePreDuring(3,:) = Euler angles that describe bone rotation from
% pre-load to during-load
% written to disk as <basil>/bone_preload_loading.txt
% written to disk as <basilhome>/<basilid>/bone_preload_loading.txt
%
% bonePrePost(1,:) = bone centre of mass before loading
% bonePrepost(2,:) = bone centre of mass post loading
% bonePrePost(3,:) = Euler angles that describe bone rotation from
% pre-load to post-load
% written to disk as <basil>/bone_preload_postload.txt
% written to disk as <basilhome>/<basilid>/bone_preload_postload.txt
%
% If basilhome is empty, data will be sought in the root-folder defined by
% bas_getDataRoot
%
% See also bas_segmentMRI, bas_estBoneRot, bas_prepFEM, bas_buildFEM
% See also bas_segmentMRI, bas_estBoneRot, bas_prepFEM, bas_buildFEM,
% bas_getDataRoot
if nargin == 1, basilhome = bas_getDataRoot; end
% map bone
savenames = {'_preload'; '_loading'; '_postload'};
......@@ -42,7 +47,7 @@ npatch = 100;
for b = 1:numel(basil)
com = zeros(3,3); bonedirs = zeros(3,3); Vall = cell(1,3);
for q = 1:3 % courtesy of Willeke Traa
load(fullfile(num2str(basil(b)), ...
load(fullfile(basilhome, num2str(basil(b)), ...
strcat('contour_bone',savenames{q},'-ncc.mat')));
% Create mesh from contours
......@@ -77,7 +82,7 @@ for b = 1:numel(basil)
[Eopt,~,~] = lsqnonlin(@(E) bas_estBoneRot(E,inputStruct),E,[],[],OPT_options);
% write results to disk
bonepd = [com(:,1:2)'; Eopt];
save(fullfile(num2str(basil(b)),strcat('Bone',savenames{1},savenames{2},'.txt')),'bonepd', '-ascii');
save(fullfile(basilhome, num2str(basil(b)),strcat('Bone',savenames{1},savenames{2},'.txt')),'bonepd', '-ascii');
% map pre-load to post-load
......@@ -94,7 +99,7 @@ for b = 1:numel(basil)
[Eopt,~,~] = lsqnonlin(@(E) bas_estBoneRot(E,inputStruct),E,[],[],OPT_options);
% write results to disk
bonepa = [com(:,[1 3])'; Eopt];
save(fullfile(num2str(basil(b)),strcat('Bone',savenames{1},savenames{3},'.txt')),'bonepa', '-ascii');
save(fullfile(basilhome, num2str(basil(b)),strcat('Bone',savenames{1},savenames{3},'.txt')),'bonepa', '-ascii');
end
end
......
function BGlogic = bas_maskBG(basil,stat)
% BGlogic = bas_maskBG(basil,scans)
function BGlogic = bas_maskBG(basil, stat, basilhome)
% BGlogic = bas_maskBG(basil, scans, basilhome)
%
% Creates a logical backgound matrix, size(MRI data), to be fed at
% uiContourSegment in bas_segmentMRI.
%
% If basilhome is empty, data will be sought in the root-folder defined by
% bas_getDataRoot
%
% scans = 1, preload
% scans = 2, during load
% scans = 3, post load
% scans = 4, flash data
% default: scans = [1 2 4]
%
% See also bas_segmentMRI, bas_prepFEM
% See also bas_segmentMRI, bas_prepFEM, bas_getDataRoot
if nargin == 0;
scans = bas_getMeta;
basil = scans(:,1);
stat = repmat([1 2 3 4],numel(basil),1);
basilhome = bas_getDataRoot;
end
if nargin == 1
stat = repmat([1 2 3 4],numel(basil),1);
basilhome = bas_getDataRoot;
end
if size(stat,1) < size(basil,1)
......@@ -34,13 +39,13 @@ map(1,:) = [1 1 1];
for b = 1:numel(basil)
bstat = nonzeros(stat(b,:));
for s = 1:numel(bstat)
load(fullfile(num2str(basil), ...
load(fullfile(basilhome, num2str(basil), ...
strcat('MRI_slices', savenames{bstat(s)})));
mip = max(slices,[],3); % maximum intensity projection along z
BGlogic = get_mask(mip,map,size(slices,3));
save(fullfile(num2str(basil(b)), ...
save(fullfile(basilhome, num2str(basil(b)), ...
strcat('MRI_BG',savenames{bstat(s)})),'BGlogic');
end
......
function bas_prepFEM(basil, overwrite)
% bas_prepFEM(basil, overwrite)
function bas_prepFEM(basil, overwrite, basilhome)
% bas_prepFEM(basil, overwrite, basilhome)
%
% Checks for each input files that is needed to build the Abaqus model
% whether it exists, and runs the scripts to generate them if they do not
% exist (may require user interaction) or if overwrite ~= 0
% (default: overwrite = 0, do not overwrite existing data)
%
% If basilhome is empty, data will be sought in the root-folder defined by
% bas_getDataRoot
%
% Checks for
% <basil>/MRI_slices_preload.mat
% <basil>/MRI_slices_loading.mat
% <basil>/MRI_slices_postload.mat
% <basil>/MRI_voxel_preload.txt
% <basil>/MRI_voxel_loading.txt
% <basil>/MRI_voxel_postload.txt
% <basilhome>/<basil>/MRI_slices_preload.mat
% <basilhome>/<basil>/MRI_slices_loading.mat
% <basilhome>/<basil>/MRI_slices_postload.mat
% <basilhome>/<basil>/MRI_voxel_preload.txt
% <basilhome>/<basil>/MRI_voxel_loading.txt
% <basilhome>/<basil>/MRI_voxel_postload.txt
% or runs bas_MRItoMat(basil,'~/BrukerData',1)
% <basil>/MRI_BG_preload.txt
% <basil>/MRI_BG_loading.txt
% <basil>/MRI_BG_postload.txt
% <basilhome>/<basil>/MRI_BG_preload.txt
% <basilhome>/<basil>/MRI_BG_loading.txt
% <basilhome>/<basil>/MRI_BG_postload.txt
% or runs bas_maskBG(basil,[1 2 3])
% ! Requires user interaction
% <basil>/contour_skin_preload.mat
% <basil>/contour_skin_loading.mat
% <basil>/contour_bone_preload.mat
% <basil>/contour_bone_loading.mat
% <basil>/contour_bone_postload.mat
% <basilhome>/<basil>/contour_skin_preload.mat
% <basilhome>/<basil>/contour_skin_loading.mat
% <basilhome>/<basil>/contour_bone_preload.mat
% <basilhome>/<basil>/contour_bone_loading.mat
% <basilhome>/<basil>/contour_bone_postload.mat
% or runs bas_segmentMRI(basil, <missing ids>)
% ! Requires user interaction
% <basil>/Bone_preload_loading.txt
% <basil>/Bone_preload_postload.txt
% <basilhome>/<basil>/Bone_preload_loading.txt
% <basilhome>/<basil>/Bone_preload_postload.txt
% or runs bas_mapBone(basil)
% <basil>/Indenter_tipNR.txt
% <basil>/Indenter_Lc.mat
% <basilhome>/<basil>/Indenter_tipNR.txt
% <basilhome>/<basil>/Indenter_Lc.mat
% or runs bas_estCylPos(basil)
% <basil>/Indenter_StartEnd.txt
% <basilhome>/<basil>/Indenter_StartEnd.txt
% or runs bas_estIndDisp(basil, 0)
%
% See also bas_MRItoMat, bas_maskBG, bas_segmentMRI,
% bas_mapBone, bas_estCylPos, bas_estIndDisp, bas_buildFEM
% bas_mapBone, bas_estCylPos, bas_estIndDisp, bas_buildFEM, bas_getDataRoot
if nargin == 1, overwrite = 0; end
if nargin == 1, overwrite = 0; basilhome = bas_getDataRoot; end
if nargin == 2, basilhome = bas_getDataRoot; end
for b = 1:numel(basil)
fprintf('checking case %i\n',basil(b));
% MRI data
fprintf('checking MRI data...\n');
if ~exist(fullfile(num2str(basil(b)),'MRI_slices_preload.mat'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_slices_loading.mat'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_slices_postload.mat'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_voxel_preload.txt'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_voxel_loading.txt'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_voxel_postload.txt'),'file')
if ~exist(fullfile(basilhome, num2str(basil(b)),'MRI_slices_preload.mat'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_slices_loading.mat'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_slices_postload.mat'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_voxel_preload.txt'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_voxel_loading.txt'),'file') || ...
~exist(fullfile(basilhome,num2str(basil(b)),'MRI_voxel_postload.txt'),'file')
bas_MRItoMat(basil(b),'~/BrukerData',1);
end
fprintf('MRI data exists, proceeding\n');
% MRI background logicals
if ~exist(fullfile(num2str(basil(b)),'MRI_BG_preload.mat'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_BG_loading.mat'),'file') || ...
~exist(fullfile(num2str(basil(b)),'MRI_BG_postload.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'MRI_BG_preload.mat'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_BG_loading.mat'),'file') || ...
~exist(fullfile(basilhome, num2str(basil(b)),'MRI_BG_postload.mat'),'file') ...
|| overwrite == 1
bas_maskBG(basil(b),[1:3]);
bas_maskBG(basil(b),[1:3],basilhome);
end
if ~exist(fullfile(num2str(basil(b)),'contour_skin_preload.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'contour_skin_preload.mat'),'file') ...
|| overwrite == 1
fprintf('please segment UNDEFORMED SKIN contours\n');
bas_segmentMRI(basil(b), 1)
bas_segmentMRI(basil(b), 1, basilhome)
end
fprintf('undeformed skin countours exist, proceeding\n');
if ~exist(fullfile(num2str(basil(b)),'contour_bone_preload.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'contour_bone_preload.mat'),'file') ...
|| overwrite == 1
fprintf('please segment UNDEFORMED BONE contours\n');
bas_segmentMRI(basil(b), 2)
bas_segmentMRI(basil(b), 2, basilhome)
end
fprintf('undeformed bone countours exist, proceeding\n');
if ~exist(fullfile(num2str(basil(b)),'contour_skin_loading.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'contour_skin_loading.mat'),'file') ...
|| overwrite == 1
fprintf('please segment DEFORMED SKIN contours\n');
bas_segmentMRI(basil(b), 3)
bas_segmentMRI(basil(b), 3, basilhome)
end
fprintf('deformed skin countours exist, proceeding\n');
if ~exist(fullfile(num2str(basil(b)),'contour_bone_loading.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'contour_bone_loading.mat'),'file') ...
|| overwrite == 1
fprintf('please segment DEFORMED BONE contours\n');
bas_segmentMRI(basil(b), 4)
bas_segmentMRI(basil(b), 4, basilhome)
end
fprintf('deformed bone countours exist, proceeding\n');
if ~exist(fullfile(num2str(basil(b)),'contour_bone_postload.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'contour_bone_postload.mat'),'file') ...
|| overwrite == 1
fprintf('please segment POST LOAD BONE contours\n');
bas_segmentMRI(basil(b), 6)
bas_segmentMRI(basil(b), 6, basilhome)
end
fprintf('post load bone countours exist, proceeding\n');
% check if all contours have the same number of slices, delete
% otherwise
bas_checkVsize(basil(b));
bas_checkVsize(basil(b), basilhome);
% map bone displacements
fprintf('checking bone movements...\n');
if ~exist(fullfile(num2str(basil(b)),'Bone_preload_loading.txt'),'file') ...
|| ~exist(fullfile(num2str(basil(b)),'Bone_preload_postload.txt'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'Bone_preload_loading.txt'),'file') ...
|| ~exist(fullfile(basilhome, num2str(basil(b)),'Bone_preload_postload.txt'),'file') ...
|| overwrite == 1
[bonePreDuring, bonePrePost] = bas_mapBone(basil(b)) %#ok<NOPRT,NASGU>
[bonePreDuring, bonePrePost] = bas_mapBone(basil(b), basilhome) %#ok<NOPRT,NASGU>
end
fprintf('bone movements mapped, proceeding\n');
% indenter props
fprintf('checking indenter properties...\n');
if ~exist(fullfile(num2str(basil(b)),'Indenter_tipNR.txt'),'file') ...
|| ~exist(fullfile(num2str(basil(b)),'Indenter_Lc.mat'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'Indenter_tipNR.txt'),'file') ...
|| ~exist(fullfile(basilhome, num2str(basil(b)),'Indenter_Lc.mat'),'file') ...
|| overwrite == 1
tipNR = bas_estCylPos(basil(b)) %#ok<NOPRT,NASGU>
param.basilhome = basilhome;
tipNR = bas_estCylPos(basil(b), param) %#ok<NOPRT,NASGU>
end
fprintf('indenter position and orientation mapped, proceeding\n');
% indenter movement
fprintf('checking indenter movement...\n');
if ~exist(fullfile(num2str(basil(b)),'Indenter_StartEnd.txt'),'file') ...
if ~exist(fullfile(basilhome, num2str(basil(b)),'Indenter_StartEnd.txt'),'file') ...
|| overwrite == 1
indSE = bas_estIndDisp(basil(b),0) %#ok<NOPRT,NASGU>
param.basilhome = basilhome;
indSE = bas_estIndDisp(basil(b), param) %#ok<NOPRT,NASGU>
end
fprintf('indenter movement mapped, case %i done\n',basil(b));
end
......
......@@ -3,7 +3,7 @@ function bas_rebuildBasil(basil)
% bas_rebuildBasil(basil)
%
% Looks for basil<basilid>_modelparam.m in the working directory, loads the
% existing model parameters, and runs bas_buildFEM(basilid,param) if the
% existing model parameters, and runs bas_buildFEM(basilid, param) if the
% file exists.
%
% See also bas_buildFEM
......
function [skinVcspre, boneVcspre, skinVcsload, boneVcsload, skinVcspost, boneVcspost] = ...
bas_segmentMRI(basil, cntrs)
bas_segmentMRI(basil, cntrs, basilhome)
% [skinpre, bonepre, skinload, boneload, skinpost, bonepost] = ...
% bas_segmentMRI(basil,cntrs)
% bas_segmentMRI(basil,cntrs,basilhome)
%
% cntrs = 1: skin, pre-load
% cntrs = 2: bone, pre-load
......@@ -10,6 +10,11 @@ function [skinVcspre, boneVcspre, skinVcsload, boneVcsload, skinVcspost, boneVcs
% cntrs = 5: skin, post-loading
% cntrs = 6: bone, post-loading
% cntrs = 7: flash
%
% If basilhome is empty, data will be sought in the root-folder defined by
% bas_getDataRoot
%
% See also bas_getDataRoot, bas_prepFEM, bas_checkVsize
skinVcspre = []; boneVcspre = [];
skinVcsload = []; boneVcsload = [];
......@@ -20,6 +25,7 @@ if nargin == 0;
end
if nargin < 2, cntrs = repmat(1:4,numel(basil),1); end
if nargin < 3, basilhome = bas_getDataRoot; end
% Skin settings
skin.recoverOn = 0;
......@@ -38,13 +44,13 @@ for b = 1:numel(basil)
if ~isempty(intersect(cntrs(b,:),1)) || ~isempty(intersect(cntrs(b,:),2))
% pre-load
load(fullfile(num2str(basil(b)),'MRI_slices_preload.mat')); % image data
load(fullfile(num2str(basil(b)),'MRI_BG_preload.mat')); % cropping mask
load(fullfile(basilhome,num2str(basil(b)),'MRI_slices_preload.mat')); % image data
load(fullfile(basilhome,num2str(basil(b)),'MRI_BG_preload.mat')); % cropping mask
skin.logicBackGround = BGlogic; % Ones (white) describe image data regions of interest
bone.logicBackGround = BGlogic;
% voxel size
voxel = load(fullfile(num2str(basil(b)),'MRI_voxel_preload.txt'));
voxel = load(fullfile(basilhome,num2str(basil(b)),'MRI_voxel_preload.txt'));
skin.v = voxel; bone.v = voxel;
M = slices; %#ok<NODEF>
......@@ -62,23 +68,23 @@ for b = 1:numel(basil)
% some (3D) contrast normalisation: M=dataNorm(M,1);
if ~isempty(intersect(cntrs(b,:),1))
skinVcspre = uiContourSegment(M,skin, ...
fullfile(num2str(basil(b)),'contour_skin_preload.mat'));
fullfile(basilhome,num2str(basil(b)),'contour_skin_preload.mat'));
end
if ~isempty(intersect(cntrs(b,:),2))
boneVcspre = uiContourSegment(M,bone, ...
fullfile(num2str(basil(b)),'contour_bone_preload.mat'));
fullfile(basilhome,num2str(basil(b)),'contour_bone_preload.mat'));
end
end
if ~isempty(intersect(cntrs(b,:),3)) || ~isempty(intersect(cntrs(b,:),4))
% during load
load(fullfile(num2str(basil(b)),'MRI_slices_loading.mat')); % image data
load(fullfile(num2str(basil(b)),'MRI_BG_loading.mat')); % cropping mask
load(fullfile(basilhome,num2str(basil(b)),'MRI_slices_loading.mat')); % image data
load(fullfile(basilhome,num2str(basil(b)),'MRI_BG_loading.mat')); % cropping mask
skin.logicBackGround = BGlogic; % Ones (white) describe image data regions of interest
bone.logicBackGround = BGlogic;