APP DESIGNER: Issue with using properties between callback functions.

11 次查看(过去 30 天)
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 个评论
Adam Danz
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.

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2022-2-10
编辑:Cris LaPierre 2022-2-10
I think I have discovered the issue. In the SelectDICOMDirectoryButtonPushed() callback function, I have the following line at the beginning of the function:
clc; clearvars; close all; % to clear anything that may have previously been loaded
Ah, that's it.
That code clears the input variable app from the function workspace, so when you assign img to app.volume, you do so to a local variable, not the app property. Once the callback function finishes executing, that local variable is deleted. When you then call ViewDICOMSeriesButtonPushed, it passes in app without the volume property being populated.
You are in a function, so it is completely unnecessary to use any of that code. Your function starts with a brand new workspace with just the input variables. You do not need to clear, close, or clc anything.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by