parfor with temporary variable worning
Show older comments
I need expert's help.
I attached a code below:
The worning signal indicated "temp_info".
I want to stack CT images as a 3D volume.
But, position information of each slice is on the temp_info (loaded by dicominfo fn.)
I will handle few hundreds patient data.
Seriously, i need your help...
Best regards
Wonjoong Cheon
function [outputArg1] = dicomread3D(path_)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
ct_list = dir(fullfile(path_, '*.dcm'));
num = length(ct_list);
temp_img_size = dicomread(fullfile(ct_list(1).folder, ct_list(1).name));
dcm_stack = zeros(temp_img_size(1), temp_img_size(2), num);
f = waitbar(0,'Please wait...');
parfor iter2 = 1: num
temp_img = dicomread(fullfile(ct_list(iter2).folder, ct_list(iter2).name));
temp_info = dicominfo(fullfile(ct_list(iter2).folder, ct_list(iter2).name));
ct_location = temp_info.InstanceNumber;
dcm_stack(:,:,ct_location) = temp_img;
waitbar(iter2/num, f, 'Load 3D medical images...');
end
close(f)
try
outputArg1 = (dcm_stack.*temp_info.RescaleSlope)+temp_info.RescaleIntercept;
catch
outputArg1 = dcm_stack;
disp('Rescale information is empty')
end
end
Accepted Answer
More Answers (1)
Walter Roberson
on 24 Nov 2022
0 votes
temp_info is assigned to inside the parfor in a way that is not indexed by the loop variable. parfor automatically makes it a temporary variable, and that means it cannot be used after the loop.
1 Comment
wonjoong cheon
on 24 Nov 2022
Categories
Find more on Image Thresholding in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!