Skip to content

Commit

Permalink
Merge pull request e0404#625 from amitantony/dev_classGUI_a_DicomImpo…
Browse files Browse the repository at this point in the history
…rtBug

Dev class GUI a dicom import bug
  • Loading branch information
wahln authored May 26, 2023
2 parents 5984075 + 72d5d3c commit 37c2f02
Show file tree
Hide file tree
Showing 35 changed files with 1,413 additions and 340 deletions.
1 change: 1 addition & 0 deletions MatRad_Config.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ function setDefaultPropertiesForEduMode(obj)

obj.devMode = false;
obj.eduMode = true;

end

function setDefaultGUIProperties(obj)
Expand Down
23 changes: 21 additions & 2 deletions dicom/matRad_importDicom.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%[env, ~] = matRad_getEnvironment();
[env, ~] = matRad_getEnvironment();


%%
if ~exist('dicomMetaBool','var')
Expand All @@ -54,7 +55,7 @@
resolution.z = files.resz; % [mm] / lps coordinate system
if files.useDoseGrid && isfield(files,'rtdose')
% get grid from dose cube
if verLessThan('matlab','9')
if isOctave || verLessThan('matlab','9')
doseInfo = dicominfo(files.rtdose{1,1});
else
doseInfo = dicominfo(files.rtdose{1,1},'UseDictionaryVR',true);
Expand Down Expand Up @@ -161,3 +162,21 @@
resultGUI.w = [resultGUI.w; [stf(i).ray.weight]'];
end
end


%% save ct, cst, pln, dose
matRadFileName = [files.ct{1,3} '.mat']; % use default from dicom
[FileName,PathName] = uiputfile('*','Save as...',matRadFileName);
if ischar(FileName)
% delete unnecessary variables
switch env
case 'MATLAB'
clearvars -except ct cst pln stf resultGUI FileName PathName;
save([PathName, FileName], '-regexp', '^(?!(FileName|PathName)$).','-v7');
case 'OCTAVE'
clear -x ct cst pln stf resultGUI FileName PathName;
save([PathName, FileName],'-v6');
end
% save all except FileName and PathName

end
22 changes: 15 additions & 7 deletions dicom/matRad_importDicomRtss.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
if nargin < 3
visBool = 0;
end

matRad_cfg = MatRad_Config.instance();
env = matRad_getEnvironment();
matRad_checkEnvDicomRequirements(env);
isOctave = strcmp(env,'OCTAVE');
Expand All @@ -52,9 +52,17 @@
end

% list the defined structures
listOfDefStructs = fieldnames(structInfo.StructureSetROISequence);
try
listOfDefStructs = fieldnames(structInfo.StructureSetROISequence);
catch
matRad_cfg.dispError('StructureSetROISequence not defined ')
end
% list of contoured structures
listOfContStructs = fieldnames(structInfo.ROIContourSequence);
try
listOfContStructs = fieldnames(structInfo.ROIContourSequence);
catch
matRad_cfg.dispError('ROIContourSequence not defined ')
end

%% process structure data
numOfDefStructs = numel(listOfDefStructs);
Expand Down Expand Up @@ -86,11 +94,11 @@
listOfSlices = fieldnames(structInfo.ROIContourSequence.(...
listOfContStructs{i}).ContourSequence);
else
warning(['Contour ' structures(i).structName ' is empty'])
matRad_cfg.dispWarning(['Contour ' structures(i).structName ' is empty'])
continue;
end
else
warning(['Contour ' structures(i).structName ' is empty'])
matRad_cfg.dispWarning(['Contour ' structures(i).structName ' is empty'])
continue;
end

Expand All @@ -113,12 +121,12 @@

% sanity check 1
if numel(unique(structZ)) > 1
error('Detected contour points outside of single slice\n');
matRad_cfg.dispError('Detected contour points outside of single slice\n');
end

% sanity check 2
if unique(structZ) > max(dicomInfo.SlicePositions) || unique(structZ) < min(dicomInfo.SlicePositions)
warning(['Omitting contour data for ' structures(i).structName ' at slice position ' num2str(unique(structZ)) 'mm - no ct data available.\n']);
matRad_cfg.dispWarning(['Omitting contour data for ' structures(i).structName ' at slice position ' num2str(unique(structZ)) 'mm - no ct data available.\n']);
else
structures(i).item(j).points = [structX, structY, structZ];
end
Expand Down
1 change: 1 addition & 0 deletions dicom/matRad_scanDicomImportFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

% dicom import needs image processing toolbox -> check if available
available = matRad_checkEnvDicomRequirements();
isOctave = strcmp(matRad_cfg.env,'OCTAVE');

if ~available
matRad_cfg.dispError('Image processing toolbox / packages not available!');
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example2_photons.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
%%
% Enable sequencing and disable direct aperture optimization (DAO) for now.
% A DAO optimization is shown in a seperate example.
pln.propOpt.runSequencing = 1;
pln.propSeq.runSequencing = 1;
pln.propOpt.runDAO = 0;

%%
Expand Down
6 changes: 3 additions & 3 deletions examples/matRad_example3_photonsDAO.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@

%%
% Enable sequencing and direct aperture optimization (DAO).
pln.propOpt.runSequencing = 1;
pln.propOpt.runDAO = 1;
pln.propSeq.runSequencing = true;
pln.propOpt.runDAO = true;

%% Generate Beam Geometry STF
stf = matRad_generateStf(ct,cst,pln);
Expand All @@ -90,7 +90,7 @@
% order to modulate the intensity of the beams with multiple static
% segments, so that translates each intensity map into a set of deliverable
% aperture shapes.
resultGUI = matRad_siochiLeafSequencing(resultGUI,stf,dij,5);
resultGUI = matRad_sequencing(resultGUI,stf,dij,pln);

%% DAO - Direct Aperture Optimization
% The Direct Aperture Optimization is an optimization approach where we
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example4_photonsMC.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
pln.propStf.bixelWidth = 10;
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0);
pln.propOpt.runSequencing = 0;
pln.propSeq.runSequencing = 0;
pln.propOpt.runDAO = 0;

% dose calculation settings
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example5_protons.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0);
pln.propOpt.runDAO = 0;
pln.propOpt.runSequencing = 0;
pln.propSeq.runSequencing = 0;

% dose calculation settings
pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm]
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example6_protonsNoise.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0);
pln.propOpt.runDAO = 0;
pln.propOpt.runSequencing = 0;
pln.propSeq.runSequencing = 0;

% dose calculation settings
pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm]
Expand Down
2 changes: 1 addition & 1 deletion examples/matRad_example7_carbon.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0);
pln.propOpt.runDAO = 0;
pln.propOpt.runSequencing = 0;
pln.propSeq.runSequencing = 0;

% dose calculation settings
pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm]
Expand Down
Binary file added gui/icons8-gamma-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gui/matRad_MainGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
StructureVisibilityWidget
InfoWidget
ViewingWidget
DVHStatsWidget
eventListeners

matRad_cfg = MatRad_Config.instance();
Expand Down
23 changes: 23 additions & 0 deletions gui/matRad_Widget.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
classdef matRad_Widget < handle

% matRad_Widget Main Class for GUI widget generation
% Describes a standard fluence optimization problem by providing the
% implementation of the objective & constraint function/gradient wrappers
% and managing the mapping and backprojection of the respective dose-
% related quantity
%
% References
% -
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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/LICENSES.txt. 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 (GetAccess = public , SetAccess = protected)
widgetHandle %Holds parent widget handle
Expand Down
24 changes: 23 additions & 1 deletion gui/widgets/matRad_3DWidget.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
classdef matRad_3DWidget < matRad_ViewingWidget


% matRad_3DWidget class to generate GUI widget for 3D plan visualization
% Describes a standard fluence optimization problem by providing the
% implementation of the objective & constraint function/gradient wrappers
% and managing the mapping and backprojection of the respective dose-
% related quantity
%
% References
% -
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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/LICENSES.txt. 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
viewingWidgetHandle;
end
Expand Down
Loading

0 comments on commit 37c2f02

Please sign in to comment.