Wednesday, 4 November 2015

1D surgery case

One dimensional surgery simulation has finally been successfully coded, taking out a segment and leaving that as space with a boundary as the simulation, we also tried stitching the function bak together, so there are two cases, in small tumours, the appropriate case would be stiching together, as the brain biomechanics would allow that degree of deformation, but in larger resections, the former case is more biologically appropriate. 

Code:

%%1D-Fisher equation

%define constants
D = 2.5e-6;     %Mean Cancer-cell Diffusion (mm^2/s)
rho = 4e-7;         %Mean Cancer-cell growth rate (cells/second/voxel)
k = 2.4e5;          %Maximum number of cells per unit volume (cells/mm^3)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          



%% Define Domain

%The size of DFull is 128*128*60*6. We choose n, m and p so that at full
%resolution (r=1) the size of D is 130*130*62*6, and we add a single layer
%of empty cells around the brain. This is just some insurance, because if
%the brain is touching the boundary of the domain, errors can occur.
%based on DTI data, 2.5mm voxels

                               %xpoints
xrange = [2.5:2.5:130*2.5];                  %All these dimensions are in mm, and come straight from the MRI data
dx = 2.5;      %space step size
xmax=max(xrange);
%right boundary
%m = floor(130);                       %ypoints
%p = floor(62);                        %zpoints
tsize =200;                              %tsteps.  Unlike the space steps, this is variable. The stability condition requires it varies.
trange = [0, (2e8)];                   %The time dimension in seconds
tmax=max(trange);
dt = (trange(2)-trange(1))/tsize;          %time step size
tsteps = 1:dt:trange(2);
%stability
%% Initial Conditions

% Define Initial Condition as a function of x. Remember the units
% of c are cells per mm^3

% ic = @(x) 1*exp(-((x-mean(xrange))^2/1));
C=zeros(1,132); %initialise C
N = length(C);
C(62:67)=k/4; %I.C. cells here

CC = zeros(1,N); %post surgery function
%% Solve equation 1D FTCS scheme
  %Explicitly step through time with anisotropic diffusion
  %Equation dc/ct=D(\del^2)c + rho*c(1 -c/k), the Fisher KPP equation
  %becomes in FTCS scheme
  % c(i,k+1) = rc(i-1,k) + (1-2r)c(i,k) + rc(i+1,k)
  % where r = Ddt/(dx)^2
  %so set
  r=((D*dt)/(dx)^2)
   % Define C as a vector
    %dCdt = (-2*D/dx^2).*C;
 %C = C + dCdt*dt;
 %C = C + dt*rho.*abs(C).*(1-abs(C)/k);

 C(1) = 0;
C(132) = 0;
Cnew1 = zeros(1,N);
Cnew2 = zeros(1,N);
%C = C + dCdt*dt;
   

 figure
 hold off
 ConcSumUncut=zeros(1,tsize);

for t=1:tsize
    CC=C;
   
 


       for i = 3:(N-2)
             C(i) = r*CC(i+1) + (1-2*r)*CC(i) + r*CC(i-1);
       end
          
  
       %Also add a cell growth term - the Fisher Equation.
    %Note the absolute values are just back-ups to ensure stability. We
    %know that the explicit diffusion equation is numerically stable, as
    %small disturbances will die down. But with an extra growth term, small
    %disturbances may lead to negative numbers, which are then inflated.
    %This is just a safety-measure.
            C = C + dt*rho.*abs(C).*(1-abs(C)/k);
            plot(CC)  % ./k to normalise
            axis([0 132 0 k])
            pause(0.1)
            disp(t)
            %while t <= 30
                %continue
              

%   if t == 30  %then do surgery
                  
%is=find(C>0.2*k,1)
%for i=1:N
   % if C(i) < 0.2*k
        %CC(i) = C(i);
   % end
%end
%plot(N,CC)
%legend('Tumour', 'Resected tumour')


%for i = 1:(is-1)
     Cnew1(i+((N/2)-is)+1) = CC(i);
   
%end
%for i = (N-is):N
    Cnew2(i-(N/2-is)) = CC(i);

%end
%C = Cnew1 + Cnew2;



 %feed this back into main loop
    ConcSumUncut(t)=sum(C);
    end
          

            
 %plot(Csurg)
 

figure
plot(ConcSumUncut)
%end
%%Surgery function
%cuts C for C>is and stiches back together the ends

%%%One Dimensional tumour resection simulation.  Boundary at cut edges.
%%post-resection.
%%1D-Fisher equation

%define constants
D = 2.5e-6;     %Mean Cancer-cell Diffusion (mm^2/s)
rho = 4e-7;         %Mean Cancer-cell growth rate (cells/second/voxel)
k = 2.4e5;          %Maximum number of cells per unit volume (cells/mm^3)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          



%% Define Domain

%The size of DFull is 128*128*60*6. We choose n, m and p so that at full
%resolution (r=1) the size of D is 130*130*62*6, and we add a single layer
%of empty cells around the brain. This is just some insurance, because if
%the brain is touching the boundary of the domain, errors can occur.
%based on DTI data, 2.5mm voxels

                               %xpoints
xrange = [2.5:2.5:130*2.5];                  %All these dimensions are in mm, and come straight from the MRI data
dx = 2.5;      %space step size
xmax=max(xrange);
%right boundary
%m = floor(130);                       %ypoints
%p = floor(62);                        %zpoints
tsize =200;                              %tsteps.  Unlike the space steps, this is variable. The stability condition requires it varies.
trange = [0, (2e8)];                   %The time dimension in seconds
tmax=max(trange);
dt = (trange(2)-trange(1))/tsize;          %time step size
tsteps = 1:dt:trange(2);
%stability

%% Initial Conditions

% Define Initial Condition as a function of x. Remember the units
% of c are cells per mm^3

% ic = @(x) 1*exp(-((x-mean(xrange))^2/1));
C=zeros(1,132); %initialise C
N = length(C);
C(62:67)=k/4; %I.C. cells here

CC = zeros(1,N); %post surgery function

%% Solve equation 1D FTCS scheme
  %Explicitly step through time with anisotropic diffusion
  %Equation dc/ct=D(\del^2)c + rho*c(1 -c/k), the Fisher KPP equation
  %becomes in FTCS scheme
  % c(i,k+1) = rc(i-1,k) + (1-2r)c(i,k) + rc(i+1,k)
  % where r = Ddt/(dx)^2
  %so set
  r=((D*dt)/(dx)^2)
   % Define C as a vector
    %dCdt = (-2*D/dx^2).*C;
 %C = C + dCdt*dt;
 %C = C + dt*rho.*abs(C).*(1-abs(C)/k);

 C(1) = 0;
C(132) = 0;

   

 figure
 hold off
 ConcSum=zeros(1,tsize);

for t=1:30
    CC=C;
   
 


       for i = 2:(N-1)
             C(i) = r*CC(i+1) + (1-2*r)*CC(i) + r*CC(i-1);
       end
          
  
       %Also add a cell growth term - the Fisher Equation.
    %Note the absolute values are just back-ups to ensure stability. We
    %know that the explicit diffusion equation is numerically stable, as
    %small disturbances will die down. But with an extra growth term, small
    %disturbances may lead to negative numbers, which are then inflated.
    %This is just a safety-measure.
            C = C + dt*rho.*abs(C).*(1-abs(C)/k);
         % C = C + dt*0.001*rho.*abs(C).*(1-abs(C)/k).*(abs((C) - 0.2*k));
            plot(CC)  % ./k to normalise
            axis([0 132 0 k])
            pause(0.1)
            disp(t)
            %while t <= 30
                %continue
              

   if t == 30  %then do surgery
                  
CC = zeros(1,N);
is=find(C>0.2*k,1);
for i=1:N
    if C(i) < 0.2*k
        CC(i) = C(i);
    end
end
C = CC;
plot(CC)
%C(is+1) = C(is);
%C(N-is-1) = C(N-is);
 %feed this back into main loop
    
    end
          

ConcSum(t)=sum(C);
            
 %plot(Csurg)
 
end
               if  i == is-1;
             C(i) = (1-r)*CC(i) + r*CC(i-1);
               if   i ==(N-is+1);
               C(i) = r*CC(i+1) + (1-r)*CC(i);
               end
               end
              
for t=31:tsize
     CC=C;
   
 
 for i=2:(is-2)
       C(i) = r*CC(i+1) + (1-2*r)*CC(i) + r*CC(i-1);
          
         
 end

 for i=(N-is):N-1
     
       C(i) = r*CC(i+1) + (1-2*r)*CC(i) + r*CC(i-1);
     
      
 end
   %for i = (N-is+1):(N-1)
      % C(i) = r*CC(i+1) + (1-2*r)*CC(i) + r*CC(i-1);
  


       %Also add a cell growth term - the Fisher Equation.
    %Note the absolute values are just back-ups to ensure stability. We
    %know that the explicit diffusion equation is numerically stable, as
    %small disturbances will die down. But with an extra growth term, small
    %disturbances may lead to negative numbers, which are then inflated.
    %This is just a safety-measure.
            C = C + dt*rho.*abs(C).*(1-(abs(C)/k));
           %Cubic growth term?
           %C = C + dt*0.001*rho.*abs(C).*(1-abs(C)/k).*abs((C-(0.02*k)./C));
            plot(CC)  % ./k to normalise
            axis([0 132 0 (k)])
            pause(0.1)
            disp(t)
            ConcSum(t) = sum(C);
end
figure
plot(ConcSum)
%end
%%Surgery function
%cuts C for C>is and stiches back together the ends

Sunday, 11 October 2015

Summary of current issues:

Working on segmenting T1 and T2 images from Simon to export to MATLAB and try to quantify difference in tumour spread for boundary.  
  1. Need a different tool?  Check is FSL or MRTrix will do it, but I think they will only make a mask and brain extraction for diffusion data?  
  2. analysis of the data in MATLAB, converting scalar field to meaning
  3. differentiating between tumour and (say) bone of other dense material with same image value.
  4. Maybe using FreeSurfer and/or 3D Slicer to do segmentatin and extraction.
Growing tumours:

Have found optimal values for stable solutions generally seem to exist at around Stability condition =  0.02 or thereabouts. Can simulate tumours quite effectively when parameters are right.

Simulation issues:  
  1. Need to confirm how anisotropic the in vivo tumours are, scaling anisotropy appears to make things 'jagged' but still more like a spiky ball as opposed to strictly following any structures.  Investigate this further and visually compare with images.

Tuesday, 8 September 2015

Almost totally sure that the problem is too many negative eigenvalues in the tensor.  An analysis showed that around 8% of the eigenvalues of the tensor are negative (using tensor MouseTensorNyFiles, from Nyoman's data). 

Will check the other tensors and think on how to fix it.


Sunday, 6 September 2015

 

Isotropic case for mouse brain did not yield any answers, although some tumours grew better especially when the number of time steps was increased. Tumours still stopped growing and concentration dropped to zero or negative.The upper video is of one of the best tumours, will run with same parameters to see if it can become any bigger.


A good example of an instability.   Will check data around this time that instability appears.

Monday, 24 August 2015

Mouse model instabilities 25/08/15

Progress: Simulations with conservative parameters of delta t have still been yielding unstable results.

As proliferation parameter rho is slowed down, the tumours look more real on the visualisation tools, to an extent.  They never grow to fill the whole brain, the ones that look solid even have an instability where they start shrinking and the concentration drops to zero, which implies an unstable data point somewhere in the tensor(?)

e.g.


The simulations are taking now 40+ minutes to run on my desktop PC and are becoming unrunnable apart from for time scales longer than about 23 days on my MacBook.

Data files are very large now due to the higher resolution so until I get stable solutions, I am just saving a record of the parameters I have varied with notes on how the solution behaved. 

Looking at the diffusion tensor variable Mean_Diff, surface plot of slice (:,:,101), I will try running simulations at around (40,40,101) which will be away from the two spikes, although they are only a factor of two or so larger than the surrounding points.

Saturday, 8 August 2015

Mouse Brain Simulations part 1:

After meetings at CAI and separately with Nyoman I have been working on processing the mouse brain data to simulate some tumours.  Initial results were flawed, after  a second attempt, where I understood the orientation and data better, I have produced a first simulation.

The anisotropy and diffusion are very apparent in this, presumably due to the much higher resolution images and more defined tracts.

Next step will be to compare this to tractography and make some slices, also repeat the process with the other mouse brain data Nyoman gave me.

A 7T Human image would be fantastic next.

EDIT:  I realised that the max tumour cell concentration was completely wrong as the human value had been used and the voxel size is 11680 times smaller in the mouse scan!

Hence the max tumour cell conc/voxel is around 20 in the mice scan using the same parameters.  Running this data now.

Tuesday, 4 August 2015

Centre for Advanced Imaging meeting and Mouse Brain Data

  1. Following a meeting at CAI on Monday 03/08/2015, they have agreed to work with us and scan some of Simon Puttick's immunodeficient glioblastoma mice for us, to obtain a longitudinal data series. 
  2. Nyoman Kurniawan, the small animal imaging expert at CAI has shared a 9.44T mouse brain atlas with us, which I have been working to put into the code and simulate tumours. I have done some of the preliminary processing, extracted the diffusion tensor, now to put in the new scan dimensions into our code.  The mouse brain has much smaller voxels and  is a different shape, the dimensions of the scan are 72x90x170, with the long axis inferior-superior (z-axis) because the mice are scanned vertically with the nose pointing to the sky. The hard bit here is lining up all the data, looking at the way it is organised in mrinfo for example to extract the right coordinates and so on. 

Tuesday, 21 July 2015

Wrote the following code to calculate the gradient of an isosurface of tumour to give a quantitative measure of shape:


%% gradient of a slice of tumour
% if not already defined, make Tumour from cstore
% for i = 1:201
% Tumour(:,:,:,i) =cstore{i};
% end
% then take time point t
% Tumour(t) = Tumour(:,:,:,t)
t = 200;
Slice = Tumour(:,:,40,t); %slice at z = 40, t = 125

%Manually make isosurface matrix
%RR = isosurface(Tumour80,2e5); then we have sructure RR.V (1613x3 double)
%and RR.F
RR = zeros(102,102);
ISO = Slice >2e5;
RR = RR + ISO;
%calculate gradient
%%Anisotropy Measure using gradient integral
%A quantitative measure of tumour anisotropy,
%1/(2*pi*R)*Integraldxdy* absolute value of grad phi
%discretised version:
%Sigma(ijk) abs(grad c(r)) =
%sqrt((partialc/partialx)^2+(partialc/partialy)^2+(partialc/partialz))dV
%partialc/partialx = ((Ci+1,j,k - Ci-1,j,k)/2deltax)

%practice code

dx = 1;
for i = 1:99, j = 1:100;
    dcdxsq =(RR(i+1,j) - RR(i,j)).^2;
end
for i=1:100, j = 1:99;
    dcdysq=(RR(i,j+1) - RR(i,j)).^2;
end
GridSum = sqrt(sum(sum(dcdxsq)) + sum(sum(dcdysq)));
figure
imagesc(RR)

GG=gradient(RR);
Aniso2 = sqrt(sum(sum(GG.^2)))
str = sprintf('Tumour surface = %f',Aniso2);
title(str);
%ThreeD version

TSurf = Tumour(:,:,:,t); %tumour matrix, t = 130
TIso = TSurf >2e5;
TTT = zeros(102,102,62);
TIso = TIso + TTT;
figure
fv = isosurface(TSurf,2e5);
p1 = patch(fv,'FaceColor','red','EdgeColor','none');
view(3)
daspect([1,1,1])
axis([0 100 0 100 0 60])
camlight
camlight(-80,-10)
lighting gouraud
title('Triangle Normals')
IsoGradient = gradient(fv.vertices);
AbsGrad3 = sqrt(sum(sum(IsoGradient.^2)))
str = sprintf('Tumour isosurface with Anisotropy = %f', AbsGrad3);
title(str)
%total tumour cells inside isosurface
ZZ = find(TSurf>2e5);
ZZZ= sum(sum(sum(ZZ)));

stf = sprintf('total tumour cells inside isosurface = %f', ZZZ)
str
Aniso2
AbsGrad3

Using this, I tabulated and plotted the data from a range of anisotropies using this code
%graphing anisotropy\
AnisoData = ...
[  NaN,      0,       1,            10,       15,         30,          45,       60,    100; ...
   NaN,    NaN,     NaN,           NaN,      NaN,         NaN,        NaN,      NaN,    NaN; ...
    40,      0,       0,             0,        0,          0,           0,        0,      0; ...
    50,      0,       0,          50.8308,  50.8358,     50.8358,    50.8572,   50.8621,   50.8690; ...
    60,   531.8208, 273.9941,    272.4435,  274.2529,   274.2529,   272.1032,   272.1409,  272.5392; ...
    70,   978.4913, 498.2811,    511.0714,  511.8223,   511.8223,   514.6845,   515.4931,  521.0318; ...
    80, 1.3849e+03, 764.0871,    784.7974,  787.4831,   787.4831,   802.9823,   802.8959,  809.3151; ...
    90, 1.8490e+03, 1.0832e+03, 1.1284e+03, 1.1359e+03, 1.1359e+03, 1.1695e+03, 1.1801e+03, 1.1909e+03; ...
   100, 2.3453e+03, 1.4825e+03, 1.5795e+03, 1.5993e+03, 1.5993e+03, 1.6569e+03, 1.6642e+03,1.6791e+03; ...
   110, 2.9061e+03, 1.9680e+03, 2.1226e+03, 2.1498e+03, 2.1498e+03, 2.2122e+03, 2.2211e+03,2.2375e+03; ...
   120, 3.4490e+03, 2.4469e+03, 2.6406e+03, 2.6727e+03, 2.6727e+03, 2.7469e+03, 2.7582e+03, 2.7812e+03; ...
   130, 3.9770e+03, 2.9079e+03, 3.1535e+03, 3.2000e+03, 3.2000e+03, 3.2964e+03, 3.3147e+03, 3.3333e+03; ...
   140, 4.4230e+03, 3.3718e+03, 3.6241e+03, 3.6663e+03, 3.6663e+03, 3.7589e+03, 3.7653e+03, 3.7858e+03; ...
   150, 4.6209e+03, 3.8110e+03, 4.0923e+03, 4.1365e+03, 4.1365e+03, 4.2477e+03, 4.2624e+03, 4.2996e+03; ...
   160, 4.8136e+03, 4.2563e+03, 4.5334e+03, 4.5946e+03, 4.5946e+03, 4.6870e+03, 4.6991e+03, 4.7366e+03; ...
   170, 4.9855e+03, 4.6604e+03, 4.9125e+03, 4.9501e+03, 4.9501e+03, 5.0425e+03, 5.0592e+03, 5.0788e+03; ...
   180, 5.1144e+03, 5.0263e+03, 5.1811e+03, 5.2162e+03, 5.2162e+03, 5.2552e+03, 5.2698e+03, 5.2814e+03; ...
   190, 5.2438e+03, 5.2282e+03, 5.2929e+03, 5.2902e+03, 5.2902e+03, 5.2949e+03, 5.2953e+03, 5.3019e+03; ...
   200, 5.2867e+03, 5.2929e+03, 5.2865e+03, 5.2865e+03, 5.2865e+03, 5.2865e+03, 5.2865e+03, 5.2865e+03];
X = AnisoData(3:end,1)*13.82;
Y0 = AnisoData(3:end,2);
Y1 = AnisoData(3:end,3);
Y10 = AnisoData(3:end,4);
Y15 = AnisoData(3:end,5);
Y30 = AnisoData(3:end,6);
Y45 = AnisoData(3:end,7);
Y60 = AnisoData(3:end,8);
Y100 = AnisoData(3:end,9);
plot(X,Y0, X,Y1, X,Y10, X,Y15, X,Y30, X,Y45, X,Y60, X,Y100)
axis([0 3000 0 5.5e3])
legend('y = rf0','y = rf1','y = rf10','y = rf15','y = rf30','y = rf45','y = rf60','y = rf100')
title('Plot of gradient of isosurface for varying anisotropy')
xlabel('time of tumour growth (days)')
ylabel('Abs(grad(isosurface))')


and produced some preliminaty graphs, which show the data behaves as expected and this may be a good measure of anisotropy of tumour surface.

Tomorrow I will explore the sum of tumour cell concentration within an isosurface as the anisotropy is varied. 

Then on to modelling resection.

Meeting with Z yesterday, plan is to explore virtual surgery this year, talk about experiments with mouse models next year and fully get to grips with what we have here and get my skills up a bit before moving on to more realistic simulations involving tissue mechanics. 
As Zoltan said, my skills are probably not up to tackling this kind of problem just yet, so this sems like a very good plan to me.


Wednesday, 15 July 2015

Anisotropy and Tissue Modelling progress

In the last fortnight I have met with Dr Yonghui Li, who kindly processed the tractography of the diffusion scan we have been working with and gave me a tutorial on the problems involved in doing this task.  Namely, making sure orientation and registration are correct while switching formats to MRTrix friendly files and processing.

I attended a Centre for Advanced Imaging seminar and there met Drs Gary Cowin, Nyoman Kurniawan and Andrew Janke, who showed me around and suggested that we do the deformation of the tissue modelling in a software package called ANTS (Advanced Normalisation of TissueS), which I downloaded and have not managed to compile successfully yet.

Further meeting to follow on Zoltan's return, Gary is the coordinator for imaging research and was very accommodating.

'Anisotropy'

Really we should be referring to surface irregularity?  

Finally got some working code, used the MATLAB \gradient function to calculate the gradient though, then took an absolute value of this. 

Using logical indexing to create a manual isosurface, we can get a matrix of ones, then we could use a nearest neighbours counting approach which I will start work on tomorrow, it should be reasonably straight forward, the question on whether it will provide any greater information than using the built in function is not really clear though.  

I also wrote code to show a movie of the surface plot of tumour evolution in a slice, which shows the traveling wave behaviour nicely.  

Found some code already written to view slice planes of a volume in MATLAB vis3d, which is very handy to have too. 

%% movie of surface plot of tumour cell density evolution in a slice
% if not already defined, make Tumour from cstore
% for i = 1:201
% Tumour(:,:,:,i) =cstore{i};
% end
% then take time point t
% Tumour(t) = Tumour(:,:,:,t)

Slice = Tumour80(:,:,40); %slice at z = 40

%Manually make isosurface matrix
%isoMatrix = Slice > 2e5;
%imagesc(Slice)
%figure
%surf(Slice)
colormap bone
caxis ([0 2.4e5])
colorbar

%make movie of surf plot
writerObj = VideoWriter('surfPlotofSlice.avi');
open(writerObj);
hold off
figure
for kk = 50:120
    Slice = Tumour(:,:,40,kk);
     surf(Slice)
     axis ([0 100 0 100 0 2.5e5])
    pause(0.1)
        frame = getframe;
        writeVideo(writerObj,frame);
colormap gray
caxis ([0 2.4e5])
end
close(writerObj);

Sunday, 5 July 2015

Progress:


Monday July 06:

Working on anisotropy measures and visualisation of data. 

The simulation runs well now, I need to collect a new lot of data sets with the new boundary that includes the falx, but these can be ran as needed.

Exploration of the isosurface function in MATLAB has been productive, and 3D visualisation techniques have been explored and movies rendered.  

Dr Yonghui Li has provided me with a data set of processed tractography and given me a tutorial on how to do this myself, although I have not yet done so, nor was I able to open the data on my immediate attempt this morning.  

Next steps will be to explore the tractographic data and imaging tools associated with this and to produce a real anisotropy quantitative measure. 

Anisotropy:


A 2D toy model using a random grid was easily able to be implemented, however I have not yet been able to extend this to the 3D isosurface data produced.  

Tasks:  
  1. Get a quantitative measure for the anisotropy of an isosurface.
  2. Get a measure for total cell concentration within a given isosurface.
  3. Measure the volume of the isosurface to compare with the surface area as a measure of smoothness.   

Wednesday, 24 June 2015

Modification of code to include falx cerebri appears reasonably successful based on simulations.
Non-smoothed data in movie looks potentially closer to being biologically realistic.

Falx code:

Lines 135-142
%FALX HERE!!!!! set of zeroes.
% add in falx cerebri here!!
front=meshgrid(48:49,68:100,0:60);
top=meshgrid(48:49,38:68,34:60);
back=meshgrid(48:49,0:38,0:60);
Dom(front) = 0;
Dom(top) = 0;
Dom(back) = 0;

Adjusting the anatomical boundary 25/06/15


Current plans and work:

One major issue that needs to be fixed is the lack of an anatomical boundry at the Falx Cerebri, which is a structure that the tumour cannot spread through as it is the reflection of the meninges between the two hemispheres and essentially a wall of connective tissue separating the left and right hemisphere apart from at the corpus callosum.  I experimented with adding in a set of points to the variable Dom, which is the brain mask set, I had promising initial results and will upload the code adjustment, check the boundary again in MRTrix and re-run some simulations.

I wrote a 2-D test code for the anisotropy measure which needs to be extended to 3D and applied to the brain data.   Before this I will examine the isocaps code and see what different isosurfaces look like and how much brain tissue they extend through.  I think looking at isocontours or isocaps superimposed on the MRI data would be a nice visualisation technique which I will work on too. 

In short:

1. Fix Domain problems re falx
2. Examine  isosurfaces
3. produce anisotropy measure.



 

 

 

 

Sunday, 14 June 2015

Three D movies and meeting with Dr Yonghui Li

15/06/15

Meeting today with Dr Yongui Li (y.li17@uq.edu.au) at Queensland Brain Institute was very productive, he is interested in helping us with the tractography and imaging software side of things.  He has concerns about moving from human to mouse models as the imaging software and technical details can be tricky, but is well established there between CAI and QBI.

He has taken my data set to do tractography on and spoke to me about the care needed to do each step before you can look at the output effectively.  Still remains to be seen how we would visualise things when we have the tumour, I may email Robert Smith at the Florey Institute again to get his advice, as he seems to think it is possible, maybe converting to a Nifti file to then view in MRTrix?

Modified my 3D visualisation code using the isocaps function in MATLAB to produce movies at some differing anisotropies.  I will collect slice sequences tomorrow too.  On visual inspection, you can see some time points where the surface definitely appears more anisotropic.

 Rf01
Rf10

rf15

rf30

rf60 

Tuesday, 9 June 2015

Created 4D tumour matrix from cstore using a for loop

for i = 1:200
Tumour(:,:,:,i) = cstore{i}

now to convert this data to a useable form such as nifti and see if I can view it in mrtrix or just look at it directly in MATLAB which might be slow.

Looked at imagesc view of tumour with brain overlay, looks more realistic.  Reshaped it into a strange rectangle though.


Monday, 8 June 2015

3D visualisation in MATLAB




3D visualisation techniques
Following the MATLAB documentation for 3D visualisation, I created the following script to visualise their sample MRI data:
%3D visualisation of MRI images
%From document visualize.pdf
load mri
D = squeeze(D); %gets rid of the redundant 4th dimension which was time = 1
figure
colormap(map)
image_num = 8;
image(D(:,:,image_num)) %shows z slice 'image_num'
axis image 
x = xlim;
y = ylim;
cm = brighten(jet(length(map)),-.5); %reduces brightness by 50%
figure
colormap(cm)
contourslice(D,[],[],image_num)
axis ij
xlim(x)
ylim(y)
daspect([1,1,1])
figure
colormap(cm)
contourslice(D,[],[],[1,12,19,27],8); %displays four contours 1,12,19,27 in 3D
view(3);
axis tight
%Applying isosurfaces to 3D data
figure
colormap(map)
Ds = smooth3(D); %using smoothing function to smooth data
hiso = patch(isosurface(Ds,5),...
    'FaceColor',[1,.75,.65],...
    'EdgeColor','none');...
    isonormals(Ds,hiso) %renders the isosurface using vertex normals obtained
                        %from the smoothed data
%Adding Isocaps to Show Cut-Away Surface
hcap = patch(isocaps(D,5),'FaceColor','interp','EdgeColor','none');
%Defining the View
view(35,30)
axis tight
daspect([1,1,.4])
%Add lighting
lightangle(45,30);
lighting gouraud
hcap.AmbientStrength = 0.6;
hiso.SpecularColorReflectance = 0;
hiso.SpecularExponenet = 50;

This outputted the following images:
Standard MRI slice

Contour Slice



Four contour slices stacked 
Isosurface
Isocaps function to show head with slice where MRI data is

Now will use this function  to plot concentration matrix and diffusion tensor with isosurface of head from original scan.

  1. Plan/Potential issues: Will need to register diffusion scan from which we derived the original diffusion tensor and brain mask to create head isosurface.  Tjis should not be too much of a problem as the box dimension will be the same.  
  2. Future higher definition work may need a T1 scan we can register with a 64 direction diffusion scan so have a high res anatomical scan and a diffusion data set we can derive a diffusion tensor for the tumour model and also has enough data to overlay tractography.




 

Contour plot and isocaps view of tumour.  Not properly orientated and sans brain and skuil.

Saturday, 6 June 2015

Images and videos for varying anisotropies 1, 10, 30 using a scaled ImageSC command [0 2.5e5]







Tumour slice series, r-factor 01 (anisotropy = water).








 Tumour Series for r factor 10, as Jbabdi et al, 10x water diffusion coefficient.








Slice series for r-factor 30.



07/06/2015.
 Tasks for week ahead:
  1. Make a movie of tumour growth using imageSc scaled properly.
  2. Establish a way of extracting the brain and skull(do not think it's in the DICOMs actually) outlines for 2D and 3D images.  Look at isocaps command in MATLAB.
  3. Write code for new anisotropy measure using the discrete gradient measure.
  4. Investigate anatomical boundaries for tumour growth in our code, may need to add in the Falx, if not automatically segmented via FSL brain mask, we could do this manually as a centreline of zero flux with the coordinates of the corpus calossum being the only connection of the two hemispheres as is anatomically realistic.

Task 01: animations
Animation for rf01
Animation for rf10
Animation for rf30

Tuesday, 2 June 2015







Image using imagesc with no brain registration, just the tumour. anisotropy = 1 (same as water), D mean 1.5x10^-7, rho = 4









Same plot technique, same location, anisotropy (r factor) = 10

Note different shapes of initial tumour especially.

N.b.  Question needs answering, is the falx cerebri counted as an anatomical boundary in the brain mask. as it should be!