How do I specify a filename path when using PARFOR?

1 view (last 30 days)
I am trying to perform a bootstrapping technique of sorts for image processing and reconstructions. In order to do so, I am using a random number generator to select, open, and produce different combinations of dicom files. Each combination, referred to as a "bootstrapped image", takes ~5 minutes to produce when done locally. Since I want to generate 1000+ bootstrapped images, I would like to run my code in parallels.
If a use PARFOR as indicated below, the process crashes when calling dicominfo(filename). It gives the message: Error using dicominfo>getFileDetails (line 389) File "Test3.dcm" not found.
If I run the code as only a FOR loop it locates the file to open without a problem.
I have tried including the path in the filename and having it in the same directory as the function I am running.
I am trying to add the containing folder (C:\Documents and Settings\My Documents\BootstrappingTrial) into the AdditionalPath section under "Manage Cluster Profiles" but again this doesn't seem to help. (However I'm not entirely sure what path I should be putting under here.)
Is there anything I can do to remedy this?
Thank you.
clear;
N = 100; % number of files to sample from
parfor j = 1:1000
Y = zeros(32,32,1,10);
n = round( (N-1)*rand(10,1) + 1 ); % produces 10 random numbers b/w 1 and N
for i = 1:10
filename = strcat('Test',num2str(n(i)),'.dcm');
info=dicominfo(filename); %%%%%%THIS LINE IS WHERE THE PROBLEM OCCURS
[Xa,~] = dicomread(filename);
X = Xa * info.private;
Y(:,:,1,i) = Y(:,:,1,i) + X(:,:,1,i); %%True function is more complicated but you get the point...
end
filename2 = strcat('Bootstrapped',num2str(j),'.dcm');
dicomwrite(Y, filename2); % Write bootstrapped image to a new file
end
  2 Comments
Walter Roberson
Walter Roberson on 18 May 2014
Are you using multiple cores on the same system, or are you using a distributed computing system?
Sarah CW
Sarah CW on 20 May 2014
Thank you for your response Walter. I am using a distributed computer system.
UPDATE: I have found that if a move the files into a shared folder on the server then it seems to find the files. I would still prefer though to keep the files on my own computer and link them if necessary.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!