isetbio / isetbio_v0.1

Tools for modeling image systems engineering in the human visual system front end
MIT License
7 stars 0 forks source link

s_initISET does not clean up #31

Open npcottaris opened 9 years ago

npcottaris commented 9 years ago

This may be a 2014b issue only. Not sure.

Example follows.

>> clear all

>> close all

>> v_sceneFromRGB

>> whos

>> whos global
  Name           Size                Bytes  Class     Attributes
  vcSESSION      1x1             139052945  struct    global    
>> s_initISET
(windows still open)

>> whos
  Name           Size               Bytes  Class     Attributes

  d              0x1                  320  struct              
  vcSESSION      1x1             69546115  struct    global   

>> vcSESSION.SCENE{1}

ans =

     []

>> vcSESSION.SCENE{2}

ans = 

type: 'scene'
data: [1x1 struct]
name: 'eagle - LCD-Apple'
spectrum: [1x1 struct]
illuminant: [1x1 struct]
distance: 0.5000
wAngular: 2.2436
filename: '/Users/Shared/Matlab/Toolboxes/isetbio/isettools/data/images/rgb/eagle.jpg'

This does not happen always. For example it does not happen with v_sceneReIllumination.m

hjiang36 commented 9 years ago

Hi Nick,

This problem does not happen always and it will happen when you do not have a variable called 'vcSESSION' (or this variable is global and 'exist' function cannot detect it).

I see the code structure get changed in dev branch and to be safe, I made this updates in branch rieke (see https://github.com/isetbio/isetbio/blob/rieke/isettools/scripts/s_initISET.m). If you really want it at this point, you could checkout this file to dev (I'm not sure where shall I put it actually). Thanks HJ

npcottaris commented 9 years ago

Thanks.

On Dec 18, 2014, at 4:57 PM, Haomiao Jiang notifications@github.com wrote:

Hi Nick,

This problem does not happen always and it will happen when you do not have a variable called 'vcSESSION' (or this variable is global and 'exist' function cannot detect it).

I see the code structure get changed in dev branch and to be safe, I made this updates in branch rieke (see https://github.com/isetbio/isetbio/blob/rieke/isettools/scripts/s_initISET.m https://github.com/isetbio/isetbio/blob/rieke/isettools/scripts/s_initISET.m). If you really want it at this point, you could checkout this file to dev (I'm not sure where shall I put it actually). Thanks HJ

— Reply to this email directly or view it on GitHub https://github.com/isetbio/isetbio/issues/31#issuecomment-67564080.

DavidBrainard commented 9 years ago

After Brian's new sceneGet, things have gotten a bit better but there is still an issue.

If I run v_sceneFromRGB, it leaves windows open when it finishes. This is fine.

a) v_sceneFromRGB has a call to ieInit in it. But when I run v_sceneFromRGB again, those windows are not closed by the call to ieInit (nor, I am pretty sure, by s_initISET). I think this is because ieInit is here being invoked from inside a function.

b) The non-closing can cause some validation errors, we think, because addtional fields get added to structures as multiple versions of the gui windows pile up. Whether this happens or not depends on how figures were set during the runs that generated the validation data and during the validation run itself. I think that validations are working OK now because we always turn off figures when we invoke the validations from our high level scripts, but this issue could resurface in the future.

c) If, after I run v_sceneFromRGB, I then type ieInit at the command line, the windows clear. Sometimes they clear the first time I do it, sometimes I have to run ieInit twice. Or at least, doing it twice works, and sometimes it has failed when I do it once. Maybe it has never worked with a single invocation at the command line. I am running 2014b.

So, there is still something to figure out and fix here.

wandell commented 9 years ago

a) I think you are right but I don't understand the issue. ieInit is very short, by the way. And the only function it calls is pretty short (ieMainClose). I will try to figure out why it only closes on the second call some time, but this will be hard to figure out.

b) Right.

c) I also get the 'ieInit works second, but not first, time' on other versions of Matlab. It often works the first time, but not always. Also puzzling to me. I will screw around after I get this damn review paper finished.

hjiang36 commented 9 years ago

ieInit doesn't work for the first time because the if-statement in line 13 returns false when vcSESSION is not a visible variable in the workspace (even though it's global). For example, calling 'clx; vcAddObject(sceneCreate); sceneWindow; ieInit;' will not close the scene window.

The reason why it works when it's called twice is because in the first call, ieInit create a visible variable vcSESSION in the workspace (see line 20) and this makes the if-statement pass (line13) in the second run.

To fix this issue, we just need to remove the if-statement in line 13. ieMainClose will do nothing (not crash) if there's no running session. Also, I think it's a good idea to remove line 20 as well so that we can alway hide vcSESSION from the user.

However, making this fix will cause v_sceneFromRGB fail because it cleans up the input parameters of that function. I think we can remove line 35 in v_sceneFromRGB and that could make all validation scripts passed.

To avoid further problems, I didn't make a commit for the fix mentioned above. I think perhaps we should have a function that only cleans ISET related fields (say vcSESSION) and keeps other variables.

Thanks

Best, HJ

On Thu Jan 01 2015 at 10:09:08 AM Brian Wandell notifications@github.com wrote:

a) I think you are right but I don't understand the issue. ieInit is very short, by the way. And the only function it calls is pretty short (ieMainClose). I will try to figure out why it only closes on the second call some time, but this will be hard to figure out.

b) Right.

c) I also get the 'ieInit works second, but not first, time' on other versions of Matlab. It often works the first time, but not always. Also puzzling to me. I will screw around after I get this damn review paper finished.

— Reply to this email directly or view it on GitHub https://github.com/isetbio/isetbio/issues/31#issuecomment-68493416.

wandell commented 9 years ago

I am trying HJ’s suggestions on my computer, with one addition - I put a close all to get rid of the figures on the screen, too.

I will see how that works for me for a while and then possibly subject you all to it.

I am stopping for the night. Hopefully you all stopped long ago.

Brian

On Jan 2, 2015, at 1:47 PM, Haomiao Jiang notifications@github.com wrote:

ieInit doesn't work for the first time because the if-statement in line 13 returns false when vcSESSION is not a visible variable in the workspace (even though it's global). For example, calling 'clx; vcAddObject(sceneCreate); sceneWindow; ieInit;' will not close the scene window.

The reason why it works when it's called twice is because in the first call, ieInit create a visible variable vcSESSION in the workspace (see line 20) and this makes the if-statement pass (line13) in the second run.

To fix this issue, we just need to remove the if-statement in line 13. ieMainClose will do nothing (not crash) if there's no running session. Also, I think it's a good idea to remove line 20 as well so that we can alway hide vcSESSION from the user.

However, making this fix will cause v_sceneFromRGB fail because it cleans up the input parameters of that function. I think we can remove line 35 in v_sceneFromRGB and that could make all validation scripts passed.

To avoid further problems, I didn't make a commit for the fix mentioned above. I think perhaps we should have a function that only cleans ISET related fields (say vcSESSION) and keeps other variables.

Thanks

Best, HJ

On Thu Jan 01 2015 at 10:09:08 AM Brian Wandell notifications@github.com wrote:

a) I think you are right but I don't understand the issue. ieInit is very short, by the way. And the only function it calls is pretty short (ieMainClose). I will try to figure out why it only closes on the second call some time, but this will be hard to figure out.

b) Right.

c) I also get the 'ieInit works second, but not first, time' on other versions of Matlab. It often works the first time, but not always. Also puzzling to me. I will screw around after I get this damn review paper finished.

— Reply to this email directly or view it on GitHub https://github.com/isetbio/isetbio/issues/31#issuecomment-68493416.

— Reply to this email directly or view it on GitHub.


Brian A. Wandell Stein Family Professor Cognitive and Neurobiological Imaging (CNI) Psychology Department Phone: 1-650-725-2466 http://www.stanford.edu/~wandell