Is there a way to hide the default waitbar that is created by the dicomCollection function?
8 ビュー (過去 30 日間)
古いコメントを表示
Within the dicomCollection function the waitbar is created at line 45:
loader = images.internal.dicom.CollectionLoader(source, recursive);
Opening this leads to a class definition for "CollectionLoader" which contains a function that creates the waitbar by default. I have not been able to edit this file so I am unable to comment out waitbar or disable it as of yet. I don't want to write a custom dicomCollection function because the native one works quite well for my purposes but the waitbar is getting kind of annoying - can't control it's positioning, can't hide it, etc... If anybody knows a work around to block the waitbar creation I would really appreciate it!
0 件のコメント
回答 (1 件)
Simar
2023 年 11 月 21 日
Hi ,
I understand that you are looking for a workaround to suppress the visibility of waitbar when using MATLAB's “dicomCollection” function without altering internal MATLAB files or creating a new custom function. The “dicomCollection” function in MATLAB, as you have noticed, automatically creates a waitbar which can be inconvenient if one is trying to run the code without any GUI elements or if one wants more control over the “waitbar” behaviour. Since the “CollectionLoader” class is a part of the internal MATLAB code, it is not intended to be modified by users. However, there are a few workarounds you might consider suppressing the waitbar without modifying the internal MATLAB files:
1.Use Java to Find and Close the Waitbar: MATLAB's “waitbar” are Java JFrame objects and can interact with them using MATLAB's Java interface. This method involves finding the waitbar window and closing it right after it is created. This can be tricky because one need to time it correctly, and it might require a loop that continuously checks for the existence of the waitbar.
% Run dicomCollection function
dicomCollection(...);
% Attempt to find and close the waitbar
f = findall(0,'type','figure','tag','TMWWaitbar');
if ~isempty(f)
close(f)
end
2. Use a Clean-up Object: Create a clean-up object in script that automatically closes the waitbar when the function completes or when an error occurs.
cleanupObj = onCleanup(@() delete(findall(0,'type','figure','tag','TMWWaitbar')));
dicomCollection(...);
3. UI Control Manipulation: If not able to close the waitbar, move it off-screen by setting its position to coordinates outside the screen's resolution.
% Get screen size
screenSize = get(0, 'ScreenSize');
% Run dicomCollection function
dicomCollection(...);
% Move the waitbar off-screen
f = findall(0,'type','figure','tag','TMWWaitbar');
if ~isempty(f)
set(f, 'Position', [screenSize(3)+100, screenSize(4)+100, 1, 1]);
end
4. MATLAB Handle Visibility: Set the “HandleVisibility” property of figures to “off,” which prevents them from being returned by functions like “gcf” or “findall”. This will not prevent the waitbar from being created, but it may help in some cases to keep it from being as intrusive.
set(0, 'DefaultFigureHandleVisibility', 'off');
dicomCollection(...);
set(0, 'DefaultFigureHandleVisibility', 'on');
Remember that using these workarounds could potentially interfere with other MATLAB functions or figures, so use them with caution and only when necessary. If running a script that repeatedly calls “dicomCollection”, include the workaround inside the loop or the script where “dicomCollection” is called to ensure it applied each time.
Please refer to the following documentation links-
discomCollection- https://in.mathworks.com/help/images/ref/dicomcollection.html?searchHighlight=dicomCollection&s_tid=srchtitle_support_results_1_dicomCollection
set(handle visibility)- https://in.mathworks.com/help/matlab/ref/set.html?searchHighlight=set&s_tid=srchtitle_support_results_1_set
Hope it helps!
Best Regards,
Simar
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!