APP DESIGNER: Issue with using properties between callback functions.
Show older comments
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 Comments
Rik
on 10 Feb 2022
Can you post the code for the two callbacks?
Anupreet Singh
on 10 Feb 2022
Cris LaPierre
on 10 Feb 2022
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
on 10 Feb 2022
Anupreet Singh
on 10 Feb 2022
Anupreet Singh
on 10 Feb 2022
Edited: Anupreet Singh
on 10 Feb 2022
Cris LaPierre
on 10 Feb 2022
What do you do between pressing SelectDICOMDirectoryButtonPushed and ViewDICOMSeriesButtonPushed?
Anupreet Singh
on 10 Feb 2022
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
on 10 Feb 2022
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
on 10 Feb 2022
Adam Danz
on 10 Feb 2022
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
on 10 Feb 2022
Anupreet Singh
on 10 Feb 2022
Stephen23
on 10 Feb 2022
CLEAR, CLC, CLOSE ALL
Adam Danz
on 10 Feb 2022
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
on 10 Feb 2022
Accepted Answer
More Answers (0)
Categories
Find more on DICOM Format 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!

