Effacer les filtres
Effacer les filtres

APP DESIGNER: Issue with using properties between callback functions.

3 vues (au cours des 30 derniers jours)
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 commentaires
Adam Danz
Adam Danz le 10 Fév 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
Anupreet Singh le 10 Fév 2022
Hi Adam,
Yes that makes a lot of sense. Thank you so much for your help.

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 10 Fév 2022
Modifié(e) : Cris LaPierre le 10 Fév 2022
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.
  1 commentaire
Anupreet Singh
Anupreet Singh le 10 Fév 2022
That makes a lot of sense!!
Thank you all so much for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by