Skip to content

Commit

Permalink
incorrect merge revert and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wahln committed Feb 26, 2025
1 parent 5600b1f commit f07b82b
Show file tree
Hide file tree
Showing 39 changed files with 2,239 additions and 273 deletions.
3 changes: 3 additions & 0 deletions matRad/IO/matRad_writeNifTI.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
info.Datatype = metadata.datatype;
info.ImageSize = size(cube);
info.Description = sprintf('Exported from matRad %s',matRad_version());
if length(info.Description) >= 80
info.Description = info.Description(1:79);
end

if max(info.ImageSize) > 32767
info.Version = 'NIfTI2';
Expand Down
15 changes: 15 additions & 0 deletions matRad/basedata/matRad_MCemittanceBaseData.m
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,21 @@
mcDataOptics.Divergence2y = 0;
mcDataOptics.Correlation2y = 0;
mcDataOptics.FWHMatIso = 2.355 * sigmaSqIso;

% Parameters for parametrization of sigma squared model.
% sigma^2 = a + b*z + c*z^2;
mcDataOptics.sSQ_a = (sigmaSqIso/10)^2;
mcDataOptics.sSQ_b = (2*rho*sigmaT*sigmaSqIso)/10;
mcDataOptics.sSQ_c = sigmaT^2;

% Parameters for emittance model
mcDataOptics.twissEpsilonX = sqrt(mcDataOptics.sSQ_a*mcDataOptics.sSQ_c - (mcDataOptics.sSQ_b^2)/4);
mcDataOptics.twissAlphaX = - mcDataOptics.sSQ_b/(2*mcDataOptics.twissEpsilonX);
mcDataOptics.twissBetaX = mcDataOptics.sSQ_a/mcDataOptics.twissEpsilonX;

mcDataOptics.twissEpsilonY = mcDataOptics.twissEpsilonX;
mcDataOptics.twissAlphaY = mcDataOptics.twissAlphaX;
mcDataOptics.twissBetaY = mcDataOptics.twissBetaX;
end


Expand Down
8 changes: 7 additions & 1 deletion matRad/bioModels/matRad_BiologicalModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@
%Use the root folder and the biomodel folder only
folders = {fileparts(mfilename('fullpath'))};
folders = [folders matRad_cfg.userfolders];
metaBioModels = matRad_findSubclasses(meta.class.fromName(mfilename('class')),'folders',folders,'includeSubfolders',true);

persistent metaBioModels lastOptionalPaths
if isempty(metaBioModels) || (~isempty(lastOptionalPaths) && ~isequal(lastOptionalPaths, folders))
lastOptionalPaths = folders;
metaBioModels = matRad_findSubclasses(meta.class.fromName(mfilename('class')),'folders',folders,'includeSubfolders',true);
end

classList = matRad_identifyClassesByConstantProperties(metaBioModels,'model','defaults',{'none'});

if nargin > 0
Expand Down
50 changes: 23 additions & 27 deletions matRad/dicom/@matRad_DicomExporter/matRad_exportDicomRTDoses.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@

meta.Modality = 'RTDOSE';
meta.Manufacturer = '';
meta.DoseUnits = 'GY';

%Reference
%ID of the CT
meta.StudyInstanceUID = obj.StudyInstanceUID;
meta.StudyID = obj.StudyID;



%Dates & Times
currDate = now;
currDateStr = datestr(currDate,'yyyymmdd');
Expand Down Expand Up @@ -99,10 +96,11 @@
meta.GridFrameOffsetVector = transpose(ct.z - ct.z(1));

%Referenced Plan
%This does currently not work due to how Matlab creates UIDs by itself,
%we can not know the reference before it is written by the RTPlanExport,
%which itself needs the RTDose UIDs
%{
%This does currently not work well due to how Matlab creates UIDs by
%itself, we can not know the reference before it is written by the
%RTPlanExport, which itself needs the RTDose UIDs.
%However, we need to set the ReferencedRTPlanSequence, because it is a
%conditionally required field according to the DICOM standard
try
rtPlanUID = obj.rtPlanMeta.SOPInstanceUID;
catch
Expand All @@ -111,38 +109,34 @@
obj.rtPlanMeta.SOPClassUID = obj.rtPlanClassUID;
rtPlanUID = obj.rtPlanMeta.SOPInstanceUID;
end
%}


%meta.ReferencedRTPlanSequence.Item_1.ReferencedSOPClassUID = obj.rtPlanClassUID;
%meta.ReferencedRTPlanSequence.Item_1.ReferencedSOPInstanceUID = rtPlanUID;

if nargin < 4 || isempty(doseFieldNames)
doseFieldNames = cell(0);
fn = fieldnames(obj.resultGUI);
for i = 1:numel(fn)
if numel(size(obj.resultGUI.(fn{i}))) == 3
doseFieldNames{end+1} = fn{i};
end

meta.ReferencedRTPlanSequence.Item_1.ReferencedSOPClassUID = obj.rtPlanClassUID;
meta.ReferencedRTPlanSequence.Item_1.ReferencedSOPInstanceUID = rtPlanUID;

doseFieldNames = cell(0);
fn = fieldnames(obj.resultGUI);
for i = 1:numel(fn)
if numel(size(obj.resultGUI.(fn{i}))) == 3
doseFieldNames{end+1} = fn{i};
end
end





obj.rtDoseMetas = struct([]);
obj.rtDoseExportStatus = struct([]);

for i = 1:numel(doseFieldNames)
doseName = doseFieldNames{i};
doseName = doseFieldNames{i};
doseUnits = 'GY';

%Now check if we export physical or RBE weighted dose, they are known
%to dicom
if strncmp(doseName,'physicalDose',12)
if strncmp(doseName,'physicalDose',12) || strncmp(doseName,'LET',3)
doseType = 'PHYSICAL';
elseif strncmp(doseName,'RBExDose',8)
elseif strncmp(doseName,'RBExDose',8) || strncmp(doseName,'BED',3) || strncmp(doseName,'alpha',3) || strncmp(doseName,'beta',3) || strncmp(doseName,'effect',6) || strncmp(doseName,'RBE',3)
doseType = 'EFFECTIVE';
if strncmp(doseName,'RBE',3)
doseUnits = 'RELATIVE';
end
else
matRad_cfg.dispInfo('Dose Cube ''%s'' of unknown type for DICOM. Not exported!\n',doseName);
continue;
Expand Down Expand Up @@ -174,6 +168,8 @@
metaCube = meta;
metaCube.DoseType = doseType;
metaCube.DoseSummationType = deliveryType;
metaCube.DoseComment = doseName;
metaCube.DoseUnits = doseUnits;

%ID of the RTDose
metaCube.SeriesInstanceUID = dicomuid;
Expand Down
19 changes: 16 additions & 3 deletions matRad/dicom/@matRad_DicomImporter/matRad_importDicomRTDose.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,24 @@
else
doseInstanceHelper = [];
end


doseComment = '';
if isfield(dose.(itemName).dicomInfo,'DoseComment')
doseComment = dose.(itemName).dicomInfo.DoseComment;
end

if strncmpi(doseTypeHelper,'PHYSICAL',6)
doseTypeHelper = 'physicalDose';
if any(strcmp(doseComment,{'physicalDose','LET'}))
doseTypeHelper = doseComment;
else
doseTypeHelper = 'physicalDose';
end
elseif strncmpi(doseTypeHelper,'EFFECTIVE',6)
doseTypeHelper = 'RBExDose';
if any(strcmp(doseComment,{'RBExDose','BED','alpha','beta','effect','RBE'}))
doseTypeHelper = doseComment;
else
doseTypeHelper = 'RBExDose';
end
end

%If given as plan and not per fraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
%always given
obj.importRTDose.dose.dicomInfo.SOPClassUID = doseInfo.SOPClassUID;
obj.importRTDose.dose.dicomInfo.SOPInstanceUID = doseInfo.SOPInstanceUID;
obj.importRTDose.dose.dicomInfo.ReferencedRTPlanSequence = doseInfo.ReferencedRTPlanSequence;
if isfield(doseInfo,'ReferencedRTPlanSequence')
obj.importRTDose.dose.dicomInfo.ReferencedRTPlanSequence = doseInfo.ReferencedRTPlanSequence;
end

end

Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@
close(h)

if ~isempty(obj.allfiles)
obj.patient = unique(obj.allfiles(:,3));
obj.patients = unique(obj.allfiles(:,3));

if isempty(obj.patient)
if isempty(obj.patients)
matRad_cfg.dispError('No patient found with DICOM CT _and_ RT structure set in patient directory!');
end
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@

%Get available, valid classes through call to matRad helper function
%for finding subclasses
availableDoseEngines = matRad_findSubclasses('DoseEngines.matRad_DoseEngineBase','packages',{'DoseEngines'},'folders',optionalPaths,'includeAbstract',false);
persistent allAvailableDoseEngines lastOptionalPaths
if isempty(allAvailableDoseEngines) || (~isempty(lastOptionalPaths) && ~isequal(lastOptionalPaths, optionalPaths))
lastOptionalPaths = optionalPaths;
allAvailableDoseEngines = matRad_findSubclasses('DoseEngines.matRad_DoseEngineBase','packages',{'DoseEngines'},'folders',optionalPaths,'includeAbstract',false);
end

availableDoseEngines = allAvailableDoseEngines;

%Now filter for pln
ix = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ function warnDeprecatedEngineProperty(this,oldProp,msg,newProp)
function assignPropertiesFromPln(this,pln,warnWhenPropertyChanged)
matRad_cfg = MatRad_Config.instance();

%Check radiation mode
if ~isfield(pln,'radiationMode') || ~any(strcmp(pln.radiationMode,this.possibleRadiationModes))
matRad_cfg.dispError('Invalid radiation mode for engine ''%s''!',this.name);
end

%Set Scenario Model
if isfield(pln,'multScen')
this.multScen = pln.multScen;
Expand Down
Loading

0 comments on commit f07b82b

Please sign in to comment.