vistalab / vistasoft

VISTASOFT is the main software repository of the VISTA lab at Stanford University.
http://vistalab.stanford.edu
148 stars 142 forks source link

ROI definition issue on Macbook - seemingly easy fix #328

Open fails1to1compile09 opened 4 years ago

fails1to1compile09 commented 4 years ago

Dear all,

Another question: on my Macbook Mojave, mrMesh does work, but there is an issue with transferring the ROI from the brain's surface in the Mesh window to the Gray volume window.

I figured out a seemingly easy fix, but if someone can confirm that it is a valid fix (and won't cause any problems), that would be great.

It appears that while Volume{x} updates the Mesh number (e.g., Volume{1}.meshNum3d=2), it does not get updated in the vw variable. mrMesh tries to find the selected mesh in view, and crashes.

If I make the following change in the function meshROI2Volume, it appears to update the variable vw to Volume{1} in my case, but presumably the current volume, and the issue dissappears. vw now also contains the substructure meshNum3d. The change: replace "if notDefined('vw'), vw = getSelectedVolume; end" by "vw = getSelectedVolume;". (line 27).

Does anyone see any issue with this temporary fix?

Thank you

JWinawer commented 4 years ago

I do not think that's a good fix. The function accept vw as an input variable. So if the variable is provided, it should be used. Your edit would overwrite the input variable every time the function is called.

It is hard to tell what is causing your problem - are you using the GUI or a script? The problem may arise from combining GUI use, which defines a view structure as a Global variable, usually with all caps, such as VOLUME{1}, whereas scripts often use local variables. If you call meshROI2Volume from a GUI, it should do the right thing and update your global view structure.

Jon

On Thu, Jan 16, 2020 at 2:41 AM fails1to1compile09 notifications@github.com wrote:

Dear all,

Another question: on my Macbook Mojave, mrMesh does work, but there is an issue with transferring the ROI from the brain's surface in the Mesh window to the Gray volume window.

With my somewhat limited programming experience, I figured out a seemingly easy fix, but if someone can confirm that it is a valid fix (and won't cause any problems), that would be great.

It appears that while Volume{x} updates the Mesh number (e.g., Volume{1}.meshNum3d=2), it does not get updated in the vw variable. mrMesh tries to find the selected mesh in view, and crashes.

If I make the following change in the function meshROI2Volume, it appears to update the variable vw to Volume{1} in my case, but presumably the current volume, and the issue dissappears. vw now also contains the substructure meshNum3d. The change: replace "if notDefined('vw'), vw = getSelectedVolume; end" by "vw = getSelectedVolume;". (line 27).

Does anyone see any issue with this temporary fix?

Thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_vistalab_vistasoft_issues_328-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAAQFPXXTVFB2JNVDUCHKES3Q6A2W7A5CNFSM4KHRZH2KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IGTLF2A&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=W4u2U_DhoNoJOD0UdsYQiqH56Bg3zFfOtNa0RCuuEIs&m=MCAikCvo-lGMIVmvoD8vtcv45E0H0_7Na6UsvkH6ZVc&s=H4k1rGOMVnOVq2ax72d99kB_uP5mCMZIu5vb2OJecog&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAQFPXSENJ5LBJW7PHVIMXLQ6A2W7ANCNFSM4KHRZH2A&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=W4u2U_DhoNoJOD0UdsYQiqH56Bg3zFfOtNa0RCuuEIs&m=MCAikCvo-lGMIVmvoD8vtcv45E0H0_7Na6UsvkH6ZVc&s=oUvAEtCOO3I2XxueG5uw5flgy16MYIWb3GdZU-r7Oyg&e= .

-- Jonathan Winawer Associate Professor of Psychology and Neural Science

New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/

fails1to1compile09 commented 4 years ago

Dear Prof. Winawer, and other colleagues,

(EDITED on Sunday 19 January 4:25 am, PST; 7:25 am EST)

Thank you very much.

Problem in the 3D window - more information - and possible solution I tested the codes some more, and I noticed that my problem only occurs when I: 1) open the VOLUME window (e.g. mrVista '3') 2) click on the menu Window and subsequently 'Open 3D Window'. 3) draw the ROI using keys like 'd' (draw), 'c' (complete), 'f' (fill), 'u' (undo) 4) in the 3D window, click on the menu Mesh, then Xform ROI, then click on 'Mesh ROI to VOLUME (fill layers)'

When I use debugging mode (the red circles on the left of the code), and I check what kind of vw variable the function gets as input, I see something that looks very differently from VOLUME{1}. The vw input to meshROI2Volume looks like a structure of Menu, Figure and UI definitions, even after the function runs mrGlobals. E.g., vw.figure1, vw.menuImages, vw.menuPlot, vw.menuMesh, vw.menuEdit, vw.btnUpdate, vw.txtROIsize, vw.editROIsize, (...), vw.menuFile.

If I try to debug step by step, I add the following after "if notDefined('vw'), vw = getSelectedVolume; end" (line 27). in meshROI2Volume: tmp = getSelectedVolume; vw.meshNum3d=tmp.meshNum3d; vw.mesh=tmp.mesh; vw.edges=tmp.edges; vw.nodes=tmp.nodes; vw.coords=tmp.coords; vw.ROIs=tmp.ROIs; vw.viewType=tmp.viewType; vw.ui=tmp.ui; vw.name=tmp.name; vw.selectedROI=tmp.selectedROI; vw.anat=tmp.anat; vw.refreshFn=tmp.refreshFn; vw.curDataType=tmp.curDataType; clear tmp

Now the code finishes running AND -unlike in earlier edits- it stores the ROIs. The required tmp fields appear to originate from a structure that is very similar to VOLUME{1}, which is what made me think that "meshROI2Volume" gets the wrong vw structure input for some reason. If this is the case, this really seems to be a big problem here. Does anyone have suggestions for a cleaner/more sophisticated way to solve the issue in the 3D window?

For now, I go for the safer solution: don't use the 3D window for ROIs at all Very recently, I started thinking outside the box, and tried to see if there is a way to define the ROIs from the VOLUME (Gray) Window. And this manner exists (Thank you so much, programmers!).

The way to do this is: 1) open the VOLUME window (e.g. mrVista '3') 2) click on the menu Gray, Surface Mesh, Build New Mesh and subsequently click 'Left Hemisphere' (or 'Right Hemisphere'). (select the appropriate segmentation file) 3) draw the ROI in the Mesh surface that appears using keys like 'd' (draw), 'c' (complete), 'f' (fill), 'u' (undo) 4) click on the menu Gray, Mesh ROIs and subsequently click 'Get ROI From Mesh (drawn with "d" key , All Layers)'.

In this approach, the issue does not occur. It also uses meshROI2Volume, but it gets an empty vw input (as I found out when using 'debugging mode' to evaluate what was happening). As a result, when the code runs line 27 "if notDefined('vw'), vw = getSelectedVolume; end", it will actually run vw = getSelectedVolume, which appears to work in this context.

JWinawer commented 4 years ago

Can you please share with us exactly what you are doing? In other words, if you are running code on the command line, what is the code, starting from when you first open the vistasession until you run into a problem? If you are doing this in a GUI, what is the exact sequence of GUI commands? Without this, it is hard to reproduce your error.

On Fri, Jan 17, 2020 at 10:30 AM fails1to1compile09 < notifications@github.com> wrote:

An update: I searched the code a little more, and if I add the following after "if notDefined('vw'), vw = getSelectedVolume; end" (line 27). in meshROI2Volume:

tmp = getSelectedVolume; vw.meshNum3d=tmp.meshNum3d; vw.mesh=tmp.mesh; vw.edges=tmp.edges; vw.nodes=tmp.nodes; vw.coords=tmp.coords; vw.ROIs=tmp.ROIs; vw.viewType=tmp.viewType; vw.ui=tmp.ui; vw.name http://vw.name=tmp.name http://tmp.name; vw.selectedROI=tmp.selectedROI; vw.anat=tmp.anat; vw.refreshFn=tmp.refreshFn; vw.curDataType=tmp.curDataType; clear tmp

This works and the ROI is stored now (and it does not completely redefine the vw structure). However, if I compare a generated ROI between the earlier suggested 'solution' with the current 'solution', the coordinates are identical. Additionally, it may still not be the proper solution yet, because it may theoretically somehow overwrite other fields of the vw structure (?).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_vistalab_vistasoft_issues_328-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAAQFPXQDFSED6DPPFBEXUEDQ6H2LPA5CNFSM4KHRZH2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJISB5A-23issuecomment-2D575742196&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=W4u2U_DhoNoJOD0UdsYQiqH56Bg3zFfOtNa0RCuuEIs&m=ZaHsH5AdB5Qpqm8z0fkXeeAl86v6Iy4fYqgM891TU1s&s=9qqU5xxdJXKfrrzIzo8ZQAmV6PO2g7uu7iZvbEVOg2o&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAQFPXQ6LQKI3OHGSDA3R33Q6H2LPANCNFSM4KHRZH2A&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=W4u2U_DhoNoJOD0UdsYQiqH56Bg3zFfOtNa0RCuuEIs&m=ZaHsH5AdB5Qpqm8z0fkXeeAl86v6Iy4fYqgM891TU1s&s=R0tHqUsdrrS8L9mhkVdPHhHDR2eKC8ZOtzvgWT02P8s&e= .

-- Jonathan Winawer Associate Professor of Psychology and Neural Science

New York University 6 Washington Place New York, NY, 10003 (212) 998-7922 (phone) (212) 995-4018 (fax) jonathan.winawer@nyu.edu http://psych.nyu.edu/winawer/

fails1to1compile09 commented 4 years ago

I tried to expand a little on what I did below (perhaps the extra details will clarify it):

The only time I use the code, is to 1) initialise the session (mrInit), and to 2) open the GUI session (e.g., "mrVista", "mrVista '3'"). After that, I only use the GUI. I do some extra things for the connective field model, but by that stage, I don't use the mrMesh anymore (ROIs have been delineated using the above general 2-step GUI approach).

I do this: _1. open the VOLUME window (e.g. mrVista '3')

  1. click on the menu Window and subsequently 'Open 3D Window'.
  2. in the 3d window, click on the menu File, then Build From Volume, then click Left Hemisphere.
  3. in the dialog window that pops up, I change nothing and press ok
  4. when they ask whether the selected segmentation is the right segmentation, I press Yes (I previously set the labels according to instructions for the toolbox online, using ITKgray/ ITKsnap)
  5. in the window that asks me to save, I click Cancel
  6. then to smooth, I click on the menu Mesh, then Smooth Mesh / Smooth Mesh (user selected), and follow the required steps.
  7. I draw the ROI using keys like 'd' (draw), 'c' (complete), 'f' (fill), 'u' (undo)
  8. in the 3D window, click on the menu Mesh, then Xform ROI, then click on 'Mesh ROI to VOLUME (fill layers)'_ Via this approach, I get the error. (I give more details about my own debugging attempts above ) Do you need extra details of the process before step 1, or will this suffice? Generally, I followed the online instructions for the analysis for it.

If I instead do things from the VOLUME window (all GUI; I only give the main steps), I don't get the error. If requested, I can also give the steps for that, but it appears to be less relevant.

fails1to1compile09 commented 4 years ago

Is this sufficient detail, or is a more thorough description required?

Edit: to clarify, I found the above mentioned 'alternative' working approach from the VOLUME window more or less through trial and error. I wasn't sure if it is the correct approach. Now, I did a search to see if I could confirm this approach, and it's basically the same as following Prof. Winawer's (your) instructions here: https://devwikis.nyu.edu/display/winawerlab/3D+mesh+visualization#id-3Dmeshvisualization-BuildingmeshesinGUI . So this must be the correct approach, and (for now, at least) I will avoid the 3D window approach described above.

I guess it might be helpful to fix the 3D window approach, in case others are (failing at) using it, but -given that there is a working approach- it is either unnecessary or should not have priority (?)

Thank you for your time