e0404 / matRad

An open source multi-modality radiation treatment planning sytem developed by e0404 @ DKFZ
http://www.matRad.org
Other
225 stars 176 forks source link

Photon Dose Calculation issue #42

Closed adrianamaria closed 8 years ago

adrianamaria commented 8 years ago

Hello and happy new year!

I am contacting you regarding the DIJ calculation step, namely some errors i've encountered. Maybe you've also experienced this before and have some word of advice.

I've had two types of errors, which i will be listing below. In any case, regardless, the calculation stops at 10%.

1) matRad: Generating stf struct... Progress: 100.00 % matRad: Uniform primary photon fluence -> pre-compute kernel convolution... matRad: Photon dose calculation... Progress: 10.01 %Out of memory. Type HELP MEMORY for your options.

Error in matRad_calcPhotonDose (line 244) dij.physicalDose(:,(ceil(counter/numOfBixelsContainer)-1)*numOfBixelsContainer+1:counter) = [doseTmpContainer{1:mod(counter-1,numOfBixelsContainer)+1,1}];

Error in matRadGUI>btnCalcDose_Callback (line 578) dij = matRad_calcPhotonDose(evalin('base','ct'),stf,evalin('base','pln'),evalin('base','cst'),0);

Error in gui_mainfcn (line 95) feval(varargin{:});

Error in matRadGUI (line 66) gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)matRadGUI('btnCalcDose_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating UIControl Callback

2) matRad: Generating stf struct... Progress: 100.00 % matRad: Uniform primary photon fluence -> pre-compute kernel convolution... matRad: Photon dose calculation... Progress: 10.00 %>> Error using horzcat Requested 44879302x2585 (5.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.

Error in matRad_calcPhotonDose (line 244) dij.physicalDose(:,(ceil(counter/numOfBixelsContainer)-1)*numOfBixelsContainer+1:counter) = [doseTmpContainer{1:mod(counter-1,numOfBixelsContainer)+1,1}];

Error in matRadGUI>btnCalcDose_Callback (line 578) dij = matRad_calcPhotonDose(evalin('base','ct'),stf,evalin('base','pln'),evalin('base','cst'),0);

Error in gui_mainfcn (line 95) feval(varargin{:});

Error in matRadGUI (line 66) gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)matRadGUI('btnCalcDose_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating UIControl Callback

Do you have some ideas on handling this?

Many thanks, Adriana

markbangert commented 8 years ago

Hi Adriana,

the error you are dealing with has to do with memory issues. How much memory do you have available on your machine? We recommend having at least 8GB better 16GB and for challenging particle cases maybe even 32GB. Apparently you don't even have 5.8GB available?!

In that case I reccommend reducing the voxel resolution when importing the CT. At what resolution are you currently working on? Youn might want to interpolate your ct to 3x3x3mm^3 - which is possible during dicom import. als you can consider reducing the bixel resolution or you can set a smaller lateral cut off. All these approximations come at a loss in precision. You need to decide yourself which one is acceptable for your application...

adrianamaria commented 8 years ago

Hello Mark,

Thank you for your answer. Before posting this issue i've checked the memory myself, and apparently it shouldn't be a problem (>300 GB free on the drive). I've also tried reducing the bixel resolution to 2 mm (smallest value i have found in literature) and, for the sake of it, reducing the number of OARs. Unfortunately, the same outcome. I had hoped reducing the voxel resolution would be my last resort (I can't remember which was the resolution i had done the importing with, less than 2 mm anyway).

Is there some memory selection to allow Matlab to work with? Or it just uses the available free space on the drive it's been installed on?

Thanks, A.

markbangert commented 8 years ago
markbangert commented 8 years ago
adrianamaria commented 8 years ago

Makes sense. Will try to adjust the above mentioned parameters in order to decrease the memory requirements. Thank you, Mark! We can consider this issue closed now.

markbangert commented 8 years ago

Great! Another setting which is somewhat more hidden is the lateral cut off (compare line 88 in https://github.com/e0404/matRad/blob/master/matRad_calcPhotonDose.m). It is already set quite tight with 20mm but if you are desparately looking for options to decrease memory consumption you can decrease this value carefully. BTW by typing 'whos' in the matlab command prompt you see the memory consumption of all work space variables!

rcorredorj commented 8 years ago

Hi,

Just a little comment on this topic. I would say that a Dij matrix of 44879302x2585 elements is far too big. I would check if the image is using the original resolution after importing the DICOM, and if that is the case, probably a resampling is a good idea.

Just for your info, I'll describe the way I usually use matRad and how do I import my data: the DICOM import system was not included in matRad before, thus I was using Slicer to open the images and the contours. There I was able to generate a labelmap with the contours rasterized at a specific resolution. That is like having a 3D matrix with e.g. a value 1 for the TV, 2 for an OAR, 3 for the rest of the body, etc. When I had the CT and the labelmap resampled to the same resolution (for example, 3x3x3 mm), I was able to import those 3D matrices in Matlab. It exists a simple format for this called MetaImage (extension: .mhd) and in Mathworks you find code to open those files as matrices in Matlab. Then, having these two matrices (the CT and the labelmap) you can generate the CST and then the Dij.

Good luck !

Ricardo RaC

markbangert commented 8 years ago

Thanks for sharing Ricardo!

And good to hear that matRad works so easily with Slicer :)