|
@@ -31,7 +31,7 @@ function [Geometry patient_dir] = nrrd2geometry
|
|
|
end
|
|
|
|
|
|
% Geometry.rhomw
|
|
|
- Geometry.rhomw = CT2dens(Geometry.data, 'pinn');
|
|
|
+y Geometry.rhomw = CT2dens(Geometry.data, 'pinn');
|
|
|
Geometry.rhomw(Geometry.rhomw < 0.0012) = 0.0012;
|
|
|
[Geometry.Smw Geometry.Fmw2] = dens2mstp(Geometry.rhomw);
|
|
|
|
|
@@ -78,66 +78,66 @@ function [Geometry patient_dir] = nrrd2geometry
|
|
|
mkdir(fullfile(patient_dir, 'opt_output'));
|
|
|
|
|
|
%% -----===== BTV and Ring creation =====-----
|
|
|
- waitbar(1/total_num_steps, hWaitbar, 'Step 2: Assign target and BTV margin');
|
|
|
- ROI_names = cellfun(@(c)c.name, Geometry.ROIS, 'UniformOutput', false);
|
|
|
-
|
|
|
- [target_idx okay] = listdlg('ListString', ROI_names, ...
|
|
|
- 'SelectionMode', 'single', 'Name', 'Target Selection', ...
|
|
|
- 'PromptString', 'Please select the target ROI. ');
|
|
|
- if okay ~= 1
|
|
|
- msgbox('Plan creation aborted');
|
|
|
- delete(hWaitbar);
|
|
|
- return;
|
|
|
- end
|
|
|
-
|
|
|
- [BTV_margin_answer] = inputdlg({sprintf('Please enter the BTV margin (cm):\n(default 0.6 cm or 1 sigma, enter 0 to skip)')}, ...
|
|
|
- 'BTV margin specification', 1, {'0.6'});
|
|
|
- if isempty(BTV_margin_answer)
|
|
|
- BTV_margin = 0.6;
|
|
|
- else
|
|
|
- BTV_margin = str2double(BTV_margin_answer{1});
|
|
|
- end
|
|
|
-
|
|
|
- % target_idx and BTV_margin are set. Expand PTV to BTV
|
|
|
- PTVmask = false(size(Geometry.rhomw));
|
|
|
- % for target_idx = target_indices
|
|
|
- PTVmask(Geometry.ROIS{target_idx}.ind) = 1;
|
|
|
- % end
|
|
|
- if BTV_margin > 0
|
|
|
- if exist('BTV_margin', 'var') && BTV_margin >= min(Geometry.voxel_size)
|
|
|
- bwD = bwdistsc(PTVmask, Geometry.voxel_size);
|
|
|
- Geometry.BTV = bwD <= BTV_margin;
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- % Create btv
|
|
|
- Geometry.ROIS{end+1} = Geometry.ROIS{end};
|
|
|
- Geometry.ROIS{end}.name = 'BTV';
|
|
|
- Geometry.ROIS{end}.num_curves = 0;
|
|
|
- Geometry.ROIS{end}.curves = {};
|
|
|
- Geometry.ROIS{end}.ind = find(Geometry.BTV);
|
|
|
- Geometry.ROIS{end}.visible = false;
|
|
|
-
|
|
|
- % Create ring
|
|
|
- [ring_margin_answer] = inputdlg({sprintf('Please enter the ring margin (cm):')}, ...
|
|
|
- 'Ring margin specification', 1, {'1'});
|
|
|
- if isempty(ring_margin_answer)
|
|
|
- ring_margin = 1;
|
|
|
- else
|
|
|
- ring_margin = str2double(ring_margin_answer{1});
|
|
|
- end
|
|
|
- bwD = bwdistsc(PTVmask, Geometry.voxel_size);
|
|
|
- Geometry.Ring = bwD <= ring_margin; % default ring radius 3 cm
|
|
|
- Geometry.Ring = xor(Geometry.Ring, PTVmask);
|
|
|
- Geometry.ROIS{end+1} = Geometry.ROIS{end};
|
|
|
- Geometry.ROIS{end}.name = 'Ring';
|
|
|
- Geometry.ROIS{end}.num_curves = 0;
|
|
|
- Geometry.ROIS{end}.curves = {};
|
|
|
- Geometry.ROIS{end}.ind = find(Geometry.Ring);
|
|
|
- Geometry.ROIS{end}.visible = false;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+% waitbar(1/total_num_steps, hWaitbar, 'Step 2: Assign target and BTV margin');
|
|
|
+% ROI_names = cellfun(@(c)c.name, Geometry.ROIS, 'UniformOutput', false);
|
|
|
+%
|
|
|
+% [target_idx okay] = listdlg('ListString', ROI_names, ...
|
|
|
+% 'SelectionMode', 'single', 'Name', 'Target Selection', ...
|
|
|
+% 'PromptString', 'Please select the target ROI. ');
|
|
|
+% if okay ~= 1
|
|
|
+% msgbox('Plan creation aborted');
|
|
|
+% delete(hWaitbar);
|
|
|
+% return;
|
|
|
+% end
|
|
|
+%
|
|
|
+% [BTV_margin_answer] = inputdlg({sprintf('Please enter the BTV margin (cm):\n(default 0.6 cm or 1 sigma, enter 0 to skip)')}, ...
|
|
|
+% 'BTV margin specification', 1, {'0.6'});
|
|
|
+% if isempty(BTV_margin_answer)
|
|
|
+% BTV_margin = 0.6;
|
|
|
+% else
|
|
|
+% BTV_margin = str2double(BTV_margin_answer{1});
|
|
|
+% end
|
|
|
+%
|
|
|
+% % target_idx and BTV_margin are set. Expand PTV to BTV
|
|
|
+% PTVmask = false(size(Geometry.rhomw));
|
|
|
+% % for target_idx = target_indices
|
|
|
+% PTVmask(Geometry.ROIS{target_idx}.ind) = 1;
|
|
|
+% % end
|
|
|
+% if BTV_margin > 0
|
|
|
+% if exist('BTV_margin', 'var') && BTV_margin >= min(Geometry.voxel_size)
|
|
|
+% bwD = bwdistsc(PTVmask, Geometry.voxel_size);
|
|
|
+% Geometry.BTV = bwD <= BTV_margin;
|
|
|
+% end
|
|
|
+% end
|
|
|
+%
|
|
|
+% % Create btv
|
|
|
+% Geometry.ROIS{end+1} = Geometry.ROIS{end};
|
|
|
+% Geometry.ROIS{end}.name = 'BTV';
|
|
|
+% Geometry.ROIS{end}.num_curves = 0;
|
|
|
+% Geometry.ROIS{end}.curves = {};
|
|
|
+% Geometry.ROIS{end}.ind = find(Geometry.BTV);
|
|
|
+% Geometry.ROIS{end}.visible = false;
|
|
|
+%
|
|
|
+% % Create ring
|
|
|
+% [ring_margin_answer] = inputdlg({sprintf('Please enter the ring margin (cm):')}, ...
|
|
|
+% 'Ring margin specification', 1, {'1'});
|
|
|
+% if isempty(ring_margin_answer)
|
|
|
+% ring_margin = 1;
|
|
|
+% else
|
|
|
+% ring_margin = str2double(ring_margin_answer{1});
|
|
|
+% end
|
|
|
+% bwD = bwdistsc(PTVmask, Geometry.voxel_size);
|
|
|
+% Geometry.Ring = bwD <= ring_margin; % default ring radius 3 cm
|
|
|
+% Geometry.Ring = xor(Geometry.Ring, PTVmask);
|
|
|
+% Geometry.ROIS{end+1} = Geometry.ROIS{end};
|
|
|
+% Geometry.ROIS{end}.name = 'Ring';
|
|
|
+% Geometry.ROIS{end}.num_curves = 0;
|
|
|
+% Geometry.ROIS{end}.curves = {};
|
|
|
+% Geometry.ROIS{end}.ind = find(Geometry.Ring);
|
|
|
+% Geometry.ROIS{end}.visible = false;
|
|
|
+
|
|
|
+
|
|
|
+ %% -----===== Save the matlab files =====-----
|
|
|
waitbar(2.33/total_num_steps, hWaitbar, 'Step 3: Save matlab geometry files');
|
|
|
% Save matlab geometry file
|
|
|
save(fullfile(patient_dir, 'matlab_files', 'Geometry.mat'), 'Geometry');
|
|
@@ -156,10 +156,9 @@ function [Geometry patient_dir] = nrrd2geometry
|
|
|
fwrite(fid, Geometry.Fmw2, 'single');
|
|
|
fclose(fid);
|
|
|
|
|
|
- fid = fopen(fullfile(patient_dir, 'geometry_files', 'target_mask.bin'), 'w');
|
|
|
- fwrite(fid, Geometry.BTV, 'single');
|
|
|
- fclose(fid);
|
|
|
-
|
|
|
+% fid = fopen(fullfile(patient_dir, 'geometry_files', 'target_mask.bin'), 'w');
|
|
|
+% fwrite(fid, Geometry.BTV, 'single');
|
|
|
+% fclose(fid);
|
|
|
|
|
|
% hWaitbar = waitbar(1/total_num_steps, 'Step 4, Create optimization geometry');
|
|
|
|