Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Superimpose RTCT and RTDose #24

Open
wjcheon opened this issue Dec 15, 2022 · 2 comments
Open

Superimpose RTCT and RTDose #24

wjcheon opened this issue Dec 15, 2022 · 2 comments

Comments

@wjcheon
Copy link

wjcheon commented Dec 15, 2022

Dear mwheurts,

First of all, I am a big fan of you :)

I have a quesntion, I have read RT image and RT dose by using your codes.

The shape of RTCT is [ 512, 512, 131] and RTDose is [201, 101, 131].

I want to fusion or superimpose RTDOSE to RTCT with size of [512 512 131]

Please, any advice.

and I hope to see you someday as offline.

Best regards

Wonjoong Cheon,

@wjcheon
Copy link
Author

wjcheon commented Dec 15, 2022

`
function [outputArg1] = doseRegiste2CT(varargin)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here

if size(varargin{2}.data,1) ~= size(varargin{1}.data,1) ...
|| size(varargin{2}.data,2) ~= size(varargin{1}.data,2) ...
|| size(varargin{2}.data,3) ~= size(varargin{1}.data,3) ...
|| isequal(varargin{2}.width, varargin{1}.width) == 0 ...
|| isequal(varargin{2}.start, varargin{1}.start) == 0

% Create 3D mesh for reference image
[refX, refY, refZ] = meshgrid(single(varargin{1}.start(2) + ...
    varargin{1}.width(2) * (size(varargin{1}.data,2) - 1): ...
    -varargin{1}.width(2):varargin{1}.start(2)), single(varargin{1}.start(1): ...
    varargin{1}.width(1):varargin{1}.start(1) + varargin{1}.width(1)...
    * (size(varargin{1}.data,1) - 1)), single(varargin{1}.start(3):...
    varargin{1}.width(3):varargin{1}.start(3) + varargin{1}.width(3)...
    * (size(varargin{1}.data,3) - 1)));

% Create GPU 3D mesh for secondary dataset
[secX, secY, secZ] = meshgrid(single(varargin{2}.start(2) + ...
    varargin{2}.width(2) * (size(varargin{2}.data,2) - 1):...
    -varargin{2}.width(2):varargin{2}.start(2)), single(varargin{2}.start(1): ...
    varargin{2}.width(1):varargin{2}.start(1) + varargin{2}.width(1) ...
    * (size(varargin{2}.data,1) - 1)), single(varargin{2}.start(3):...
    varargin{2}.width(3):varargin{2}.start(3) + varargin{2}.width(3) ...
    * (size(varargin{2}.data,3) - 1)));

% Attempt to use GPU to interpolate dose to image/structure
% coordinate system.  If a GPU compatible device is not
% available, any errors will be caught and CPU interpolation
% will be used instead.
try
    % Initialize and clear GPU memory
    gpuDevice(1);

    % Interpolate the dose to the reference coordinates using
    % GPU linear interpolation, and store back to
    % varargin{2}.data
    varargin{2}.data = gather(interp3(gpuArray(secX), ...
        gpuArray(secY), gpuArray(secZ), ...
        gpuArray(varargin{2}.data), gpuArray(refX), ...
        gpuArray(refY), gpuArray(refZ), 'linear', 0));

    % Clear GPU memory
    gpuDevice(1);

    % Catch any errors that occured and attempt CPU interpolation
    % instead
catch
    % Interpolate the dose to the reference coordinates using
    % linear interpolation, and store back to varargin{2}.data
    varargin{2}.data = interp3(secX, secY, secZ, ...
        varargin{2}.data, refX, refY, refZ, '*linear', 0);
end

% Clear temporary variables
clear refX refY refZ secX secY secZ;

end

outputArg1 = varargin{2}.data;

end
`

I have solved the problem ! I got a hint from your other codes.

@mwgeurts
Copy link
Owner

mwgeurts commented Dec 15, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants