-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/e0404/matRad into dev
- Loading branch information
Showing
71 changed files
with
2,616 additions
and
1,319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
matRad/dicom/@matRad_DicomImporter/matRad_DicomImporter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
classdef matRad_DicomImporter < handle | ||
% matRad_DicomImporter matRad class to handle a dicom import. | ||
% | ||
% Example on how to use the matRad_DicomImport class | ||
% | ||
% dcmImpObj = matRad_DicomImporter('pathToFolder'); % create instance of matRad_DicomImporter | ||
% dcmImpObj.matRad_importDicom(dcmImpObj); % run the import | ||
% | ||
% | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% | ||
% Copyright 2020 the matRad development team. | ||
% | ||
% This file is part of the matRad project. It is subject to the license | ||
% terms in the LICENSE file found in the top-level directory of this | ||
% distribution and at https://github.com/e0404/matRad/LICENSE.md. No part | ||
% of the matRad project, including this file, may be copied, modified, | ||
% propagated, or distributed except according to the terms contained in the | ||
% LICENSE file. | ||
% | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
properties | ||
|
||
% path to DICOM file | ||
patDir; | ||
|
||
% lists of all files | ||
allfiles; | ||
patient; | ||
importFiles; % all the names (directories) of files, that will be imported | ||
|
||
% properties with data for import functions | ||
importCT; | ||
importRtss; | ||
importRTDose; | ||
|
||
% structures for .mat file | ||
ct = []; | ||
cst = []; | ||
stf = []; | ||
pln = []; | ||
resultGUI = []; | ||
|
||
ImportGrid; | ||
|
||
% bools | ||
dicomMetaBool; | ||
visBool; | ||
|
||
|
||
|
||
end | ||
|
||
methods | ||
|
||
function obj = matRad_DicomImporter(pathToFolder) | ||
|
||
%matRad_DicomImporter Construct an instance of this class | ||
% Can be called with the structures. If no argument is given, | ||
% all structures will be read from the base workspace | ||
|
||
obj.patDir = pathToFolder; | ||
matRad_cfg = MatRad_Config.instance(); | ||
|
||
if matRad_cfg.isOctave | ||
%Octave needs the DICOM package | ||
try | ||
pkg load dicom; | ||
catch | ||
matRad_cfg.dispError('The DICOM export requires the octave-forge package "dicom"!\n'); | ||
end | ||
end | ||
|
||
obj.patDir = pathToFolder; | ||
|
||
obj.matRad_scanDicomImportFolder(); | ||
|
||
% matRad_DicomImporter imports only one structure, to select | ||
% patients and structures within a single patient the | ||
% matRad_importDicomWidget is used | ||
|
||
ctFiles = strcmp(obj.allfiles(:,2),'CT'); | ||
rtssFiles = strcmpi(obj.allfiles(:,2),'rtstruct'); %note we can have multiple RT structure sets, matRad will always import the firstit finds | ||
rtPlanFiles = strcmpi(obj.allfiles(:,2),'rtplan'); | ||
rtDoseFiles = strcmpi(obj.allfiles(:,2),'rtdose'); | ||
|
||
obj.importFiles.ct = obj.allfiles(ctFiles,:);%All CT slice filepaths stored in a cell array like {'CTSlice1.dcm','CTSlice2.dcm'}; | ||
obj.importFiles.rtss = obj.allfiles(rtssFiles,:); | ||
obj.importFiles.rtplan = obj.allfiles(rtPlanFiles,:); | ||
obj.importFiles.rtdose = obj.allfiles(rtDoseFiles,:); | ||
|
||
for i = numel(obj.allfiles(:,1)):-1:1 | ||
if strcmp(obj.allfiles(i,2),'CT') | ||
obj.importFiles.resx = obj.allfiles{i,9}; | ||
obj.importFiles.resy = obj.allfiles{i,10}; | ||
obj.importFiles.resz = obj.allfiles{i,11}; %some CT dicoms do not follow the standard and use SpacingBetweenSlices | ||
break | ||
end | ||
end | ||
|
||
obj.importFiles.useImportGrid = false; | ||
|
||
|
||
end | ||
|
||
matRad_importDicom(obj) | ||
|
||
obj = matRad_importDicomCt(obj) | ||
|
||
obj = matRad_importDicomRTDose(obj) | ||
|
||
obj = matRad_importDicomRTPlan(obj) | ||
|
||
obj = matRad_importDicomRtss(obj) | ||
|
||
obj = matRad_importDicomSteeringPhotons(obj) | ||
|
||
obj = matRad_importDicomSteeringParticles(obj) | ||
|
||
obj = matRad_scanDicomImportFolder(obj) | ||
|
||
obj = matRad_calcHU(obj) | ||
|
||
obj = matRad_createCst(obj) | ||
|
||
obj = matRad_dummyCst(obj) | ||
|
||
% matRad_saveImport(obj); | ||
|
||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
function obj = matRad_createCst(obj) | ||
% matRad function to create a cst struct upon dicom import | ||
% | ||
% In your object, there must be a property that contains matlab structure | ||
% containing information about rt structure set (generated with | ||
% matRad_importDicomRtss and matRad_convRtssContours2Indices) | ||
% | ||
% Output - matRad cst structure | ||
% | ||
% call | ||
% obj = matRad_createCst(obj) | ||
% | ||
% | ||
% References | ||
% - | ||
% | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% | ||
% Copyright 2015 the matRad development team. | ||
% | ||
% This file is part of the matRad project. It is subject to the license | ||
% terms in the LICENSE file found in the top-level directory of this | ||
% distribution and at https://github.com/e0404/matRad/LICENSE.md. No part | ||
% of the matRad project, including this file, may be copied, modified, | ||
% propagated, or distributed except according to the terms contained in the | ||
% LICENSE file. | ||
% | ||
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
matRad_cfg = MatRad_Config.instance(); | ||
|
||
nStructures = size(obj.importRtss.structures,2); | ||
obj.cst = cell(nStructures,6); | ||
|
||
%Create set of default colors | ||
defaultColors = colorcube(nStructures); | ||
|
||
for i = 1:size(obj.importRtss.structures,2) | ||
obj.cst{i,1} = i - 1; % first organ has number 0 | ||
obj.cst{i,2} = obj.importRtss.structures(i).structName; | ||
|
||
if ~isempty(regexpi(obj.cst{i,2},'tv', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'target', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'gtv', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'ctv', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'ptv', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'boost', 'once')) || ... | ||
~isempty(regexpi(obj.cst{i,2},'tumor', 'once')) | ||
|
||
obj.cst{i,3} = 'TARGET'; | ||
|
||
obj.cst{i,5}.Priority = 1; | ||
|
||
% default objectives for targets | ||
objective = DoseObjectives.matRad_SquaredDeviation; | ||
objective.penalty = 800; | ||
objective.parameters = {30}; %Default reference Dose | ||
obj.cst{i,6}{1} = struct(objective); | ||
|
||
else | ||
|
||
obj.cst{i,3} = 'OAR'; | ||
|
||
obj.cst{i,5}.Priority = 2; | ||
|
||
obj.cst{i,6} = []; % define no OAR dummy objcetives | ||
|
||
end | ||
|
||
obj.cst{i,4}{1} = obj.importRtss.structures(i).indices; | ||
|
||
% set default parameter for biological planning | ||
obj.cst{i,5}.alphaX = 0.1; | ||
obj.cst{i,5}.betaX = 0.05; | ||
obj.cst{i,5}.Visible = 1; | ||
if isfield(obj.importRtss.structures(i),'structColor') && ~isempty(obj.importRtss.structures(i).structColor) | ||
obj.cst{i,5}.visibleColor = obj.importRtss.structures(i).structColor' ./ 255; | ||
else | ||
obj.cst{i,5}.visibleColor = defaultColors(i,:); | ||
matRad_cfg.dispInfo('No color information for structure %d "%s". Assigned default color [%f %f %f]\n',i,obj.cst{i,2},defaultColors(i,1),defaultColors(i,2),defaultColors(i,3)); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.