APP DESIGNER: Issue with using properties between callback functions.
이전 댓글 표시
Hi,
I am working on an image segmentation GUI. When I load in my volume, I am storing it in a property I made called "app.volume". I do this as I want to use the volume between callback functions. I load in my volume in one callback function and assign app.volume the data. However, when I move onto the following callback function, in which I need to use the app.volume data, I am not able to retrieve it.
I am not sure why this is happening, and I need to be able to work with the volume between various callback functions. Any advice?
댓글 수: 17
Rik
2022년 2월 10일
Can you post the code for the two callbacks?
Anupreet Singh
2022년 2월 10일
Cris LaPierre
2022년 2월 10일
What do you mean you are not able to retrieve it? Is there an error message? if so, please share the complete error message (all the red text).
Anupreet Singh
2022년 2월 10일
Anupreet Singh
2022년 2월 10일
Anupreet Singh
2022년 2월 10일
편집: Anupreet Singh
2022년 2월 10일
Cris LaPierre
2022년 2월 10일
What do you do between pressing SelectDICOMDirectoryButtonPushed and ViewDICOMSeriesButtonPushed?
Anupreet Singh
2022년 2월 10일
Is your app object actually named "app"? Sometimes I see people change the app object name and then copy-paste solutions into their app without adapting the object name. Although, on second thought, you'd probably get an error that "app" is an unknown function or variable in that case.
Adam Danz
2022년 2월 10일
If the folder in PathName did not contain any dcm files, 'a' would be an empty structure which would likely throw an error in extractfield() and 'out' would be 0 so "img" would never be defined which would also throw an error whem img is assigned to app.volume. So that eliminates the possibility that no dcm files were found.
I see that you are not preallocating the img and metadata variables. I wonder if your dicom images are being read successfully.
Anupreet Singh
2022년 2월 10일
Adam Danz
2022년 2월 10일
Have you tried placing a break point at the end of SelectDICOMDirectoryButtonPushed() and then running the code to that point, and manually executing disp(size(app.volume))? Knowing the outcome of that would eliminate some possibilities.
Are there any other warnings or errors when you open the app or when using any other features of the app?
Anupreet Singh
2022년 2월 10일
Anupreet Singh
2022년 2월 10일
Stephen23
2022년 2월 10일
CLEAR, CLC, CLOSE ALL
Adam Danz
2022년 2월 10일
Ah, I missed that. That clears your app object from the function workspace so when you assign data to app.volume, "app" becomes a structure variable which is cleared when the SelectDICOMDirectoryButtonPushed function ends. The "app" object still exists outside of the function but its values are gone which is why it retains the [0,0] size in the next callback function.
Lesson learned: there is rarely a need to clear variables within function workspaces. One exception is if a variable size is large and you no longer need it and want to reduce memory.
Anupreet Singh
2022년 2월 10일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 DICOM Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


