3

I run some code with Profiler, the code deals with DICOM files, and the dicom... functions in Matlab.

In the main window of the Profiler, I see that dicominfo>parseSequence takes almost all of the running time. Inside this inner function, it seems like that:

enter image description here

You can see here that dicominfo>parseSequence takes total of 241.488 seconds (in the title), and inside it there is a function called dicominfo>processMetadata, that takes 240.801 seconds, 99.7% from the time.

But, when I click it to see its contents, it says that the processMetadata takes only 50.391 seconds! :

enter image description here

How can it be...? Where all my time goes...?

EDIT

I really think that this is a Profiler issue, but for @Tokkot ask, I attach the piece of code that I profiled:

cd ([Fname '\' seq(m).name]);
files=dir;                                      % Names of all files in current sequence
for n=4:length(files)
        info=dicominfo([pwd '\' files(n).name]);
        info.PatientName=PatientName;               % convert the field Name to initials
        info.PatientID='';                          % delete ID
        [X,~]=dicomread([pwd '\' files(n).name]);
        dicomwrite(X, sprintf('anon%s', files(n).name), info, 'createmode', 'copy');
        delete([pwd '\' files(n).name]);
end 
Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
Adiel
  • 3,071
  • 15
  • 21
  • 1
    There is some inconsistency here. In the first windows, it says the number of calls is 9382, while in the bottom it says there are 10234 calls. It looks like you have used the profiler for two separate runs of the function (08:06:38, and 08:22:39). The latter one is much faster. You might want to have a look at [this question](http://stackoverflow.com/questions/16873733/why-does-matlab-run-faster-after-a-script-is-warmed-up) regarding warm-up in MATLAB. – Stewie Griffin Sep 02 '15 at 08:12
  • 1
    Hi, the warm-up issue is really interesting, but it definitely not the case here. I did only single run: the clock-time is when I open the profiler report, and not when I run the script (yesterday night...). The number of calls in the first window is the calls to `processMetadata` only from `parseSequence`, but there are some more calls to `processMetadata` from other places in the main function. – Adiel Sep 02 '15 at 08:19
  • 1
    @StewieGriffin you can see the number of calls in the second window, under "Parents" (first table) – Adiel Sep 02 '15 at 08:23
  • 1
    We really need a minimum working example to help you here. – Tokkot Sep 02 '15 at 15:22
  • 1
    Ok @Tokkot, I attached code in question. Variables there are not important, mainly folders names. – Adiel Sep 02 '15 at 15:37
  • I am experiencing EXACTLY THE SAME ISSUE. But in my case the routine takes 5 seconds and the profiler reports 500............ – Brethlosze Jul 18 '16 at 21:59
  • Could you share your Matlab Version and Platform?. Mine is R2014b+MSW8. – Brethlosze Jul 18 '16 at 22:00
  • @hypfco Well, it's not only mine profiler that broken :) My Version is also R2014b, working on windows 7. I can check it later also on another platform that I have, R2015b + win10. Anyway, apparently Matlab is not the fastest way to anonymize DICOM files, `DicomBrowser` is mutch better. And `dicominfo` stays very slow function. – Adiel Jul 28 '16 at 05:56
  • I am not using the `DICOM` functions. I think the `profiler` is faulty. – Brethlosze Aug 01 '16 at 02:54

0 Answers0