Commit c186d01e authored by Mark van Turnhout's avatar Mark van Turnhout
Browse files

listings tweaking

parent a80252df
......@@ -33,6 +33,7 @@
% listings and code
......@@ -69,7 +69,7 @@ The Poisson's ratio $\nu$ can be calculated from $\mu_0$ and $K_0$ with (see sec
\nu = \frac{3\frac{K_0}{\mu_0}-2}{6\frac{K_0}{\mu_0}+2}
BasilLab provides the function \bas{D2nu} to calculate the Poisson's ratio $\nu$ from $\mu_0$ and $D$, and the function \bas{nu2D} to calculate $D$ from $\mu_0$ and a Poisson's ratio $\nu$:
\begin{lstlisting}[language=basillab, numbers=none]
>> nu = bas_D2nu(0.0156, 60)
nu =
......@@ -94,7 +94,7 @@ For large models, in terms of elements and nodes, you may wish to increase \text
\subsection{\texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}} and \bas{rebuildFEM}}
\begin{lstlisting}[language=octave, float, caption={Example of \texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}}.}, label=modelparam]
\begin{lstlisting}[language=basillab, float, caption={Example of \texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}}.}, label=modelparam]
param.buildon = '16-Dec-2015 10:42:00';
param.basilhome = '/home/mark/tue/WillekeBasil';
param.seed = 6.000000e-01;
......@@ -122,24 +122,24 @@ param.indOff = 0.000000;
Next to the Abaqus python script \texttt{basil<basilid>\\index{basil<basilid>\\texttt{basil<basilid>\}}} that builds the model, \bas{buildFEM} also writes a file \texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}} in the current working directory. This file contains all the optional parameters that \bas{buildFEM} used to write the Abaqus python script. The default values are substituted for parameters that were not explicitly defined in the input parameter structure. In addition, the first line of \texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}} contains the the date and time that \bas{buildFEM} was called to write \texttt{basil<basilid>\\index{basil<basilid>\\texttt{basil<basilid>\}}} (\texttt{buildon}, see listing \ref{modelparam} for an example).
With this file, you can always and easily check the parameters that were used to build a particular model. As long as you keep this file, you can always ask \bas{buildFEM} to build the model again from scratch and be sure that you use the same options as you used before. Likewise, you can be sure to use the same options for (certain) different models. E.g.\ to build the model for \texttt{<basilid> = 140611} with the same parameters that were used to build a model for \texttt{<basilid> = 140613}, run:
\begin{lstlisting}[language=basillab, numbers=none]
>> run basil140613_modelparam.m, bas_buildFEM(140611,param)
\noindent BasilLab also provides the function \bas{rebuildFEM}. This function reads \texttt{basil<basilid>\_model\-param.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}} for a given \texttt{<basilid>} and then calls \bas{buildFEM} for \texttt{<basilid>} with the parameters that were read from \texttt{basil<basilid>\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}}. So, the following two commands are equivalent:
>> run basil140611_modelparam.m, bas_buildFEM(140611,param)
>> bas_rebuildFEM(140611)
Furthermore, \bas{rebuildFEM} also accepts the parameter structure as (optional) input. When \bas{rebuildFEM} is called with the parameter structure as an argument, it will first read the original parameters from \texttt{basil<basilid>\-\_modelparam.m\index{basil<basilid>\_modelparam.m@\texttt{basil<basilid>\_modelparam.m}}} and next substitute parameters that were supplied as an argument to \bas{rebuildFEM} with these (new) values. So again, the following two commands are equivalent:
>> run basil140611_modelparam.m, param.seed = 1; bas_buildFEM(140611,param)
>> param.seed = 1; bas_rebuildFEM(140611,param)
This function \bas{rebuildFEM} can be very useful when you wish to change a single or few parameters in all your models, while keeping the (other) original parameters for each individual \texttt{<basilid>} the same as before. E.g.\ when, you call
\begin{lstlisting}[language=basillab, numbers=none]
>> param.seed = 0.5; bas_rebuildFEM([140611:140613], param)
all parameters for \texttt{<basilid> = 140611}, \texttt{<basilid> = 140612} and \texttt{<basilid> = 140613} will be the same as before, except for the mesh seed size.\\
......@@ -150,7 +150,7 @@ all parameters for \texttt{<basilid> = 140611}, \texttt{<basilid> = 140612} and
When \bas{buildFEM} is called
\begin{lstlisting}[numbers=none, language=basillab]
>> bas_buildFEM([basilid1, basilid2, ... ], param)
the following files may be written in the current work directory for each \texttt{<basilid}$i$\texttt{>}:
......@@ -188,8 +188,8 @@ Before \bas{buildFEM} starts on the main Abaqus python script \texttt{basil<basi
In order to write the the mesh contours \bas{buildFEM} loads \texttt{Bone\_preload\_loading.txt\index{Bone\_preload\_loading.txt@\texttt{Bone\_preload\_loading.txt}}} to get the centre of mass of the tibia before indentation, and loads the segmented data before indentation \texttt{contour\_skin\_preload-ncc.mat\index{contour\_skin\_preload-ncc.mat@\texttt{contour\_skin\_preload-ncc.mat}}} and \texttt{contour\_bone\_preload-ncc.mat\index{contour\_bone\_preload-ncc.mat@\texttt{contour\_bone\_preload-ncc.mat}}}. These segmented contours are translated with the centre of mass of the tibia, and converted to circumferentially equidistant points (100 for the skin, 50 for the bone) with \bas{cylSurfPatch} and the \gibbon-function \gib{contourRegulariseAngle}.
The converted contours are then written to \texttt{basil<basilid>\\index{basil<basilid>\\texttt{basil<basilid>\}}} which contains 2 lines for each contour, e.g.:
\begin{lstlisting}[language=python, escapechar=!]
\begin{lstlisting}[language=apython, escapechar=!]
pts = [(-9.928135, 0.262538, -9.000000), (-9.863098, -0.045693, -9.000000), !\textnormal{(up to 100 or 50 triplets of coordinates)}!]
myPart.WireSpline(points=pts, mergeType=IMPRINT, meshable=ON, smoothClosedSpline=ON)
The first line
\ No newline at end of file
The first line
\lstset{ %
language = Octave, % choose the language of the code
language = basillab,
basicstyle = \footnotesize\ttfamily, % the size of the fonts that are used for the code
numbers = left, % where to put the line-numbers
numberstyle = \footnotesize, % the size of the fonts that are used for the line-numbers
......@@ -18,7 +18,8 @@ title = \lstname, % show the filename of files included with \lstinputlisting;
% also try caption instead of title
captionpos = t, % sets the caption-position to top
escapeinside = {\%*}{*)}, % if you want to add a comment within your code
%morekeywords = {*,...}, % if you want to add more keywords to the set
%morekeywords = {myPart,WireSpline}, % if you want to add more keywords to the set
commentstyle = \color{green},
stringstyle = \color{red},
keywordstyle = \color{blue},
......@@ -26,4 +27,3 @@ inputencoding = utf8,
extendedchars = false,
aboveskip = -1em
{alsolanguage = Python,
morekeywords = {WireSpline}}
{alsolanguage = Octave,
keywordsprefix = {bas_},
morekeywords = {param}}
......@@ -31,7 +31,7 @@ As a matter of principle and for philosophical reasons, BasilLab leaves the raw
\noindent \MRIroot{} is defined (hard-coded) in \bas{getMRIroot}. This script is called by BasilLab when it needs to know the path to the \MRIroot{}-folder. You can edit this script manually, or you can use \bas{setMRIroot} to update this script to your local situation. When you call \bas{setMRIroot}, the \bas{getMRIroot}-script is overwritten with a new version that provides the \MRIroot{} that you provided as an argument to \bas{setMRIroot}.
Similarly, \basilhome{} is defined in \bas{getDataRoot} and updated with \bas{setDataRoot}. The argument for \bas{setDataRoot} or \bas{setMRIroot} is the \textsl{full} path to the folder that you wish to define, e.g.:
\begin{lstlisting}[numbers=none, language=basillab]
>> bas_setMRIroot('/home/mark/BrukerData');
>> bas_setDataRoot(pwd);
......@@ -56,7 +56,7 @@ The actual parsing of raw MRI-data is done by a call to \bas{readMRI}, which in
\noindent The first argument of \bas{MRItoMat} is a list of \texttt{<basilid>}'s for which to parse and copy the MRI-data. The second argument can be used to skip copying and parsing of data that already exists in \basilhome\texttt{/<basilid>}. When the list of \texttt{<basilid>}'s is omitted, all data defined in \bas{getMeta} is parsed. When the last argument is \texttt{0}, data that is already present in \basilhome\texttt{/<basilid>} is not processed; when it is \texttt{1}, all data present in \basilhome\texttt{/<basilid>} will be overwritten. If \bas{MRItoMat} is called without arguments, all data defined in \bas{getMeta} is parsed and all existing data is overwritten.
To process the data for \texttt{<basilid> = 140611} and \texttt{<basilid> = 140613} and skip processing of data that is already present in \basilhome\texttt{/<basilid>}, call:
\begin{lstlisting}[numbers=none, language=basillab]
>> bas_MRItoMat([140611, 140613], 0);
......@@ -139,21 +139,21 @@ BasilLab is very lazy on the masking part.
The function \bas{maskBG}{} loads the voxel set that you wish to segment and shows a maximum intensity projection over the $z$-direction. In this image, you are asked to interactively select the centre and radius of a circle. The circle will serve as the basis of a cylinder-shaped 3D `mask' for \gib{uiContourSegment}. \bas{maskBG}{} does not make separate mask for skin and bone.
The mask for \basilhome\texttt{/<basilid>/}\texttt{MRI\_slices\_<foo>.mat\index{MRI\_slices\_<foo>.mat@\texttt{MRI\_slices\_<foo>.mat}}}\footnote{\texttt{<foo>} can be \texttt{preload} or \texttt{loading} or \texttt{postload} or \texttt{flash} (see table \ref{mritomatout}).}will be saved as \basilhome\texttt{/}\-\texttt{<basilid>}\-\texttt{/MRI\_BG\_<foo>.mat\index{MRI\_BG\_<foo>.mat@\texttt{MRI\_BG\_<foo>.mat}}}. To mask the data in the scans before (\texttt{1}), during (\texttt{2}) and after indentation (\texttt{3}) for \texttt{<basilid> = 140611} call:
\begin{lstlisting}[numbers=none, language=basillab]
>> bas_maskBG(140611, [1 2 3]);
\noindent With the masks, we can call \bas{segmentMRI} which in turn calls \gibbon{} for the actual segmentation. The output of \gib{uiContourSegment} is a Matlab structure called \texttt{Vcs} that contains a cell with contour points $(x, y,z)$ for each 2D MRI-slice. \bas{segmentMRI} saves this structure `as is'. The \texttt{Vcs}-structure for the skin in \basilhome\texttt{/<basilid>/}\texttt{MRI\_slices\_<foo>.mat\index{MRI\_slices\_<foo>.mat@\texttt{MRI\_slices\_<foo>.mat}}} will be saved as \basilhome\texttt{/<basilid>/}\texttt{contour\_skin\_<foo>.mat\index{contour\_skin\_<foo>.mat@\texttt{contour\_skin\_<foo>.mat}}}, that of the tibia as \basilhome\texttt{/<basilid>}\-\texttt{/contour\_bone\_<foo>.mat\index{contour\_bone\_<foo>.mat@\texttt{contour\_bone\_<foo>.mat}}}.
Note that \bas{segmentMRI} loaded \basilhome\texttt{/<basilid>/}\texttt{MRI\_voxel\_<foo>.txt\index{MRI\_voxel\_<foo>.mat@\texttt{MRI\_voxel\_<foo>.mat}}} in the process. The dimensions of the saved contours are in mm. To segment the skin and bone data in the scans before (\texttt{1,2}), during (\texttt{3,4}), and the bone contour after indentation (\texttt{6}) for \texttt{<basilid> = 140611} call:
>> bas_segmentMRI(140611, [1:4, 6]);
\noindent Finally, we need to check for missing contours in de segmented data. The \texttt{Vcs}-structure of \gib{uiContourSegment} may contain empty cells, and missing contour data may mess op BasilLab and post-processing. The function \bas{checkVsize} loads five contour-sets \texttt{contour\_skin\_preload.mat\index{contour\_skin\_preload.mat@\texttt{contour\_skin\_preload.mat}}}, \texttt{contour\_skin\_loading.mat\index{contour\_skin\_loading.mat@\texttt{contour\_skin\_loading.mat}}}, \texttt{contour\_bone\_preload.mat}, \texttt{contour\_bone\_loading.mat\index{contour\_bone\_loading.mat@\texttt{contour\_bone\_loading.mat}}}, and \texttt{contour\_bone\_postload.mat\index{contour\_bone\_postload.mat@\texttt{contour\_bone\_postload.mat}}} from \basilhome\texttt{/<basilid>/}, and deletes a contour that is missing from \textsl{any} set from \textsl{all} sets.
The (new) contour sets are saved with \texttt{-ncc} appended to their file name, i.e.\ the corrected set for \texttt{contour\_skin\_preload.mat\index{contour\_skin\_preload.mat@\texttt{contour\_skin\_preload.mat}}} will be saved as \texttt{contour\_skin\_preload-ncc.mat\index{contour\_skin\_preload-ncc.mat@\texttt{contour\_skin\_preload-ncc.mat}}}. The original data will remain untouched. To post-process the contours for \texttt{<basilid> = 140611} and \texttt{<basilid> = 140613} call:
>> bas_checkVsize([140611, 140613]);
......@@ -172,7 +172,7 @@ These Euler angles follow the \gibbon-convention (see \gib{euler2DCM.m}): $\alph
This kind of angle multiplication is not commutative. Abaqus uses a different definition for Euler angles. These three Euler angles from \gibbon{} can not be directly used in Abaqus. It will wreak havoc.
The $3\times 3$ matrix (centres of mass, Euler angles) is written to \texttt{Bone\_preload\_loading.txt\index{Bone\_preload\_loading.txt@\texttt{Bone\_preload\_loading.txt}}} or \texttt{Bone\_preload\_postload.txt\index{Bone\_preload\_postload.txt@\texttt{Bone\_preload\_postload.txt}}}, depending on the case, in \basilhome\texttt{/<basilid>/}. To map the tibia movements for \texttt{<basilid> = 140611} and \texttt{<basilid> = 140613} call:
>> bas_mapBone([140611, 140613]);
......@@ -205,7 +205,7 @@ If all went well, you should now have the files listed in table \eqref{prepfemfi
\item the bone contours after indentation;
in that order. Other files are produced automagically and do not require user interaction. To prepare your MRI-data for building of the FEM for \texttt{<basilid> = 140611} and \texttt{<basilid> = 140613} call:
>> bas_prepFEM([140611, 140613]);
......@@ -238,7 +238,7 @@ file in \basilhome\texttt{/<basilid>/}& written by & needed for \\
\section{Building the FE model}\label{buildmodel}
The FEM building process is described in detail in the next chapter. Briefly, we use the script \bas{buildFEM} to read the necessary model data from \basilhome\texttt{/<basilid>/} and to write an Abaqus python script \textsl{in the current working directory}\footnote{Note: \textsl{in the current working directory}, these files are \textsl{not} written to \basilhome\texttt{/<basilid>/}.}. With this python script, Abaqus builds (and optionally: runs) the FE model: geometry, material parameters, boundary conditions, contact, etc. To write the Abaqus model scripts for \texttt{<basilid> = 140611} and \texttt{<basilid> = 140613} call:
>> bas_buildFEM([140611, 140613], param);
where \texttt{param} is a structure with modelling options (see chapter \ref{buildfem}).
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment