From vishwak at miamioh.edu Wed May 9 14:14:54 2018 From: vishwak at miamioh.edu (Vishwanath, Karthik) Date: Wed, 9 May 2018 14:14:54 -0400 Subject: [Nirfast] Failing while trying to graphically place sources/detectors Message-ID: Hi All, Was having trouble creating and placing sources/detectors in a standard slab mesh using NIRFAST-9.0 on a linux system (Ubuntu 16.04.4 LTS; 4.4.0-122-generic x86_64 kernel). My MATLAB version is R2017a. I've listed sequence of steps with the messages in the workspace window shown and the fixes I attempted (in blue text) ================================================== >> nirfast Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Error using textscan Unknown parameter 'bufsize'. Error in read_nod_elm (line 45) data = textscan(fid,'%u32 %f %f %f%*[^\n]','bufsize',409500); Error in checkerboard3d_mm (line 109) [telem tnode] = read_nod_elm(fnprefix,1); Error in make_slab (line 89) mesh = checkerboard3d_mm(fullfile(outputdir,'test_node_ele.ele'),... Error in create_mesh (line 25) eval(['mesh = make_' lower(shape) '(sizevar);']); Error in gui_create_mesh>done_Callback (line 532) mesh = evalin('base',content{end}); Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject, eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== Changed line 45 in "toolbox/meshing/tools/read_nod_elm.m" to: data = textscan(fid,'%u32 %f %f %f%*[^\n]') Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Added Shield: 0.0010 s Delaunay Triangulation Time: 0.7141 s Connectivity Time: 0.0359 s Circumcenters Time: 0.0129 s 47 th level was reached 100.0000 % of Tetraedroms were checked Walking Time: 0.0399 s Manifold extraction Time: 0.4239 s Total Time: 1.2299 s Writing data to file...Done writing mesh to: Path: /home/karthik/Research/Matlab/lib/nirfast Filename: test_node_ele.node/.ele --> Beginning mesh generation process, please wait... Done with sub-volume separation. =========================================== Calculating desired length at boundary nodes.. done. Calculating prism normals and bounding boxes.. done. Sealing boundary buffer zone.. done. Tagging interior nodes... done -----> Running BSP tree to filter out nodes. -----> done. Writing data to file.Done writing the nodes to: Path: /tmp Filename: input4delaunay.a.node Writing data to file... Done writing surface to a poly file: Path: /tmp Filename: input4delaunay.poly ---------> Running Delaunay, please wait.../bin/bash: /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/toolbox/meshing/bin/delaunaygen-linux64.exe: Permission denied Warning: Delaunay Generator failed. Trying again... > In checkerboard3d (line 181) In checkerboard3d_mm (line 167) In make_slab (line 89) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) /bin/bash: /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/ toolbox/meshing/bin/delaunaygen-linux64.exe: Permission denied Error using checkerboard3d (line 186) Delaunay Generator failed again. Check your input setting! Error in checkerboard3d_mm (line 167) [mesh.elements, mesh.nodes] = checkerboard3d(telem(:,1:3),tnode,myargs); Error in make_slab (line 89) mesh = checkerboard3d_mm(fullfile(outputdir,'test_node_ele.ele'),... Error in create_mesh (line 25) eval(['mesh = make_' lower(shape) '(sizevar);']); Error in gui_create_mesh>done_Callback (line 532) mesh = evalin('base',content{end}); Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== In shell: $ chmod +x /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/ toolbox/meshing/bin/delaunaygen-linux64.exe Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Added Shield: 0.0003 s Delaunay Triangulation Time: 0.4179 s Connectivity Time: 0.0214 s Circumcenters Time: 0.0032 s Warning: Brute continuation necessary > In MyRobustCrust>Marking (line 408) In MyRobustCrust (line 134) In make_slab (line 85) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Warning: 1000 th level was reached\n > In MyRobustCrust>Marking (line 440) In MyRobustCrust (line 134) In make_slab (line 85) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) 99.7824 % of Tetraedroms were checked Walking Time: 0.0985 s Manifold extraction Time: 0.2470 s Total Time: 0.7971 s Writing data to file...Done writing mesh to: Path: /home/karthik/Research/Matlab/lib/nirfast Filename: test_node_ele.node/.ele --> Beginning mesh generation process, please wait... Done with sub-volume separation. =========================================== Calculating desired length at boundary nodes.. done. Calculating prism normals and bounding boxes.. done. Sealing boundary buffer zone.. done. Tagging interior nodes... done -----> Running BSP tree to filter out nodes. -----> done. Writing data to file.Done writing the nodes to: Path: /tmp Filename: input4delaunay.a.node Writing data to file... Done writing surface to a poly file: Path: /tmp Filename: input4delaunay.poly ---------> Running Delaunay, please wait... done. <--------- --> Finished mesh generation. Undefined function or variable 'myflag'. Error in optimize_mesh_gui>optimize_mesh_gui_OpeningFcn (line 78) if myflag Error in gui_mainfcn (line 220) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:}); Error in optimize_mesh_gui (line 40) [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); Error in gui_create_mesh>done_Callback Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@( hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== Added line 64 in toolbox/meshing/tools/optimize_mesh_gui.m: 64 myflag=''; 65 if(nargin > 3) Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done The mesh is generated and the figure dialog for "Place sources and detectors" comes up. The mesh is viewable, can be rotated and panned using the tools in the figure window. However, clicking on the mesh generates the following error: Error using matlab.graphics.axis.Axes/get There is no x_RenderTransform property on the Axes class. Error in select3d>local_Data2PixelTransform (line 361) xform = get(ax,'x_RenderTransform'); Error in select3d (line 208) xvert = local_Data2PixelTransform(ax,vert)'; Error in gui_place_sources_detectors>figure1_WindowButtonDownFcn (line 386) p = select3d; Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_place_sources_detectors (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_place_sources_detectors('figure1_WindowButtonDownFcn',hObject,eventdata,guidata(hObject)) Error while evaluating Figure WindowButtonDownFcn. ================================================== Was not sure how to proceed from there. Let me know if there is any other information needed to help track/fix this. Thanks, -- Karthik Vishwanath, PhD James C. & Carole E. Garland Professorship Office: 109 Kreger Hall Dept. of Physics, Miami University, Oxford OH Tel: (513) 529-2315 Web: OSIM Lab -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.wojtkiewicz at cs.bham.ac.uk Wed May 9 17:41:45 2018 From: s.wojtkiewicz at cs.bham.ac.uk (Stanislaw Wojtkiewicz) Date: Wed, 9 May 2018 22:41:45 +0100 Subject: [Nirfast] Failing while trying to graphically place sources/detectors In-Reply-To: References: Message-ID: <001301d3e7de$87ea1fa0$97be5ee0$@cs.bham.ac.uk> Hi Karthik I can confirm, the newest Matlab does not like some functions used in NIRFAST. The very last issue: ?Error using matlab.graphics.axis.Axes/get There is no x_RenderTransform property on the Axes class.? MathWorks removed the ?x_RenderTransform? axes property starting with Matlab R2014a. More community comments about that here: https://undocumentedmatlab.com/blog/undocumented-view-transformation-matrix No easy fix of that (the GUI of source/detector placing might require some refurbishment). However, I might have a solution for you. Here is how to add source/detector manually (using Matlab commands). Step by step: #0 Do not place points using a mouse. #1 @ the left side of the GUI where you have empty lists of sources and detectors: put some values in both. E.g. 1 2 3 2 4 5 For (x y z) coordinates of e.g. 2 sources. Do similar with detectors. The 'points placing' with a mouse just reads the (x y z) coordinates from the figure axes and puts them into the lists. You might try to put the exact coordinates if you know them. #2 Save the mesh from the GUI. Step #1 is not necessary. You should be able to save mesh without fiducial points. However, you will have more work later :) #3 Load the mesh in Matlab command window, script, etc.. using the ?load_mesh? function (mesh = load_mesh(?path_to_mesh/mesh_name?);) #4 Adjust your sources and detector. The mesh structure should have following fields: source: [1?1 struct] meas: [1?1 struct] e.g. >> mesh.source ans = struct with fields: distributed: 0 fixed: 0 num: 1 coord: [47.0244 59.5354 48.0170] fwhm: 0 and >> mesh.meas ans = struct with fields: fixed: 0 num: [2?1 double] coord: [2?3 double] int_func: [2?5 double] Look for the fields meaning on the online documentation. Focus on: coordinates (coord) and numbering (num). #5 Change the mesh.link field accordingly (using your sources and detectors numbering). The ?link? field is explained somewhere online. It is basically a list of source and detector numbers and logical indicator (0, 1) if this pair is considered as active (if the boundary fluence rate should be calculated for that pair). #6 Save the mesh using the command ?save_mesh(mesh, ?path_2_mesh/mesh_name?)? #7 Enjoy the mesh. The source/detector coordinates do not have to be exactly on the mesh surface. Try to put them close to the surface. The load_mesh function will take care of proper positioning if you leave the ?fixed? field set to ?0?. I hope I helped. Regards Stanislaw Wojtkiewicz, PhD --- School of Computer Science University of Birmingham B15 2TT From: Vishwanath, Karthik Sent: 09 May 2018 19:15 To: nirfast at public.kitware.com Subject: [Nirfast] Failing while trying to graphically place sources/detectors Hi All, Was having trouble creating and placing sources/detectors in a standard slab mesh using NIRFAST-9.0 on a linux system (Ubuntu 16.04.4 LTS; 4.4.0-122-generic x86_64 kernel). My MATLAB version is R2017a. I've listed sequence of steps with the messages in the workspace window shown and the fixes I attempted (in blue text) ================================================== >> nirfast Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Error using textscan Unknown parameter 'bufsize'. Error in read_nod_elm (line 45) data = textscan(fid,'%u32 %f %f %f%*[^\n]','bufsize',409500); Error in checkerboard3d_mm (line 109) [telem tnode] = read_nod_elm(fnprefix,1); Error in make_slab (line 89) mesh = checkerboard3d_mm(fullfile(outputdir,'test_node_ele.ele'),... Error in create_mesh (line 25) eval(['mesh = make_' lower(shape) '(sizevar);']); Error in gui_create_mesh>done_Callback (line 532) mesh = evalin('base',content{end}); Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== Changed line 45 in "toolbox/meshing/tools/read_nod_elm.m" to: data = textscan(fid,'%u32 %f %f %f%*[^\n]') Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Added Shield: 0.0010 s Delaunay Triangulation Time: 0.7141 s Connectivity Time: 0.0359 s Circumcenters Time: 0.0129 s 47 th level was reached 100.0000 % of Tetraedroms were checked Walking Time: 0.0399 s Manifold extraction Time: 0.4239 s Total Time: 1.2299 s Writing data to file...Done writing mesh to: Path: /home/karthik/Research/Matlab/lib/nirfast Filename: test_node_ele.node/.ele --> Beginning mesh generation process, please wait... Done with sub-volume separation. =========================================== Calculating desired length at boundary nodes.. done. Calculating prism normals and bounding boxes.. done. Sealing boundary buffer zone.. done. Tagging interior nodes... done -----> Running BSP tree to filter out nodes. -----> done. Writing data to file.Done writing the nodes to: Path: /tmp Filename: input4delaunay.a.node Writing data to file... Done writing surface to a poly file: Path: /tmp Filename: input4delaunay.poly ---------> Running Delaunay, please wait.../bin/bash: /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/toolbox/meshing/bin/delaunaygen-linux64.exe: Permission denied Warning: Delaunay Generator failed. Trying again... > In checkerboard3d (line 181) In checkerboard3d_mm (line 167) In make_slab (line 89) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) /bin/bash: /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/toolbox/meshing/bin/delaunaygen-linux64.exe: Permission denied Error using checkerboard3d (line 186) Delaunay Generator failed again. Check your input setting! Error in checkerboard3d_mm (line 167) [mesh.elements, mesh.nodes] = checkerboard3d(telem(:,1:3),tnode,myargs); Error in make_slab (line 89) mesh = checkerboard3d_mm(fullfile(outputdir,'test_node_ele.ele'),... Error in create_mesh (line 25) eval(['mesh = make_' lower(shape) '(sizevar);']); Error in gui_create_mesh>done_Callback (line 532) mesh = evalin('base',content{end}); Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== In shell: $ chmod +x /home/karthik/Research/Matlab/lib/nirfast/NIRFAST-9.0/toolbox/meshing/bin/delaunaygen-linux64.exe Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done Added Shield: 0.0003 s Delaunay Triangulation Time: 0.4179 s Connectivity Time: 0.0214 s Circumcenters Time: 0.0032 s Warning: Brute continuation necessary > In MyRobustCrust>Marking (line 408) In MyRobustCrust (line 134) In make_slab (line 85) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Warning: 1000 th level was reached\n > In MyRobustCrust>Marking (line 440) In MyRobustCrust (line 134) In make_slab (line 85) In create_mesh (line 25) In gui_create_mesh>done_Callback (line 532) In gui_mainfcn (line 95) In gui_create_mesh (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) 99.7824 % of Tetraedroms were checked Walking Time: 0.0985 s Manifold extraction Time: 0.2470 s Total Time: 0.7971 s Writing data to file...Done writing mesh to: Path: /home/karthik/Research/Matlab/lib/nirfast Filename: test_node_ele.node/.ele --> Beginning mesh generation process, please wait... Done with sub-volume separation. =========================================== Calculating desired length at boundary nodes.. done. Calculating prism normals and bounding boxes.. done. Sealing boundary buffer zone.. done. Tagging interior nodes... done -----> Running BSP tree to filter out nodes. -----> done. Writing data to file.Done writing the nodes to: Path: /tmp Filename: input4delaunay.a.node Writing data to file... Done writing surface to a poly file: Path: /tmp Filename: input4delaunay.poly ---------> Running Delaunay, please wait... done. <--------- --> Finished mesh generation. Undefined function or variable 'myflag'. Error in optimize_mesh_gui>optimize_mesh_gui_OpeningFcn (line 78) if myflag Error in gui_mainfcn (line 220) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:}); Error in optimize_mesh_gui (line 40) [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); Error in gui_create_mesh>done_Callback Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_create_mesh (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_create_mesh('done_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback. ================================================== Added line 64 in toolbox/meshing/tools/optimize_mesh_gui.m: 64 myflag=''; 65 if(nargin > 3) Selected menu in GUI: Mesh->Create Mesh ->Simple Shapes -> Standard Selected slab and set L/W/H to 20mm and click Done The mesh is generated and the figure dialog for "Place sources and detectors" comes up. The mesh is viewable, can be rotated and panned using the tools in the figure window. However, clicking on the mesh generates the following error: Error using matlab.graphics.axis.Axes/get There is no x_RenderTransform property on the Axes class. Error in select3d>local_Data2PixelTransform (line 361) xform = get(ax,'x_RenderTransform'); Error in select3d (line 208) xvert = local_Data2PixelTransform(ax,vert)'; Error in gui_place_sources_detectors>figure1_WindowButtonDownFcn (line 386) p = select3d; Error in gui_mainfcn (line 95) feval(varargin{:}); Error in gui_place_sources_detectors (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_place_sources_detectors('figure1_WindowButtonDownFcn',hObject,eventdata,guidata(hObject)) Error while evaluating Figure WindowButtonDownFcn. ================================================== Was not sure how to proceed from there. Let me know if there is any other information needed to help track/fix this. Thanks, -- Karthik Vishwanath, PhD James C. & Carole E. Garland Professorship Office: 109 Kreger Hall Dept. of Physics, Miami University, Oxford OH Tel: (513) 529-2315 Web: OSIM Lab --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.wojtkiewicz at cs.bham.ac.uk Mon May 14 18:16:00 2018 From: s.wojtkiewicz at cs.bham.ac.uk (Stanislaw Wojtkiewicz) Date: Mon, 14 May 2018 23:16:00 +0100 Subject: [Nirfast] NIRFASTSLicer_2.0_major_bugs_report+solutions In-Reply-To: <001301d3e93e$0dd5b5b0$29812110$@Domain> References: <001301d3e93e$0dd5b5b0$29812110$@Domain> Message-ID: <005c01d3ebd1$24583890$6d08a9b0$@cs.bham.ac.uk> Hi All I want to report bugs in NIRFASTSlicer_v.2.0 mesh generation module. I also deliver solutions (attached). Major problems: - translation of coordinates from patient space to x-y-z space -> crushes the module - unfinished implementation of fiducial coordinates processing (since NIRFASTSlicer v1.0) -> fiducials useless The 'Create Mesh' crush and fiducials problems can be reproduced using my head model (generated from MRI with SPM and saved with NIRFASTSlicer2.0). (Please mail me for the segmentation '*.nrrd' file. It's only 632KB. However, Nirfast mailing list email size limit is 300KB.) The command: cd('C:/Program Files/NIRFASTSlicer 2.0.0/lib/NIRFASTSlicer-2.0/matlab-modules'); Image2Mesh(cli_argsread({'--nirfastDir','D:/PROGRAMS/nirfast8/toolbox','--la belmap','C:/Users/wojtkies/AppData/Local/Temp/NIRFASTSlicer/EICE_vtkMRMLLabe lMapVolumeNodeC.nrrd','--fiducials','34.7404,71.4787,25.567','--fiducials',' 0.909979,77.0329,25.567','--fiducials','-29.8908,69.9639,25.567','--meshdir' ,'D:/DOCUMENTS/GRANTY/BITMAP/Warsaw_meeting_05.2018/TEST/mesh_test','--meshn ame','nirfast_mesh','--meshtype','Standard','--cell_size','3.5','--cellradiu sedge','3','--facet_size','3.5','--facetangle','25','--facetdistance','3'})) ; (Win 10, Matlab R2016a, NIRFASTSLicer2.0 - pure as download, NIRFAST9.0 - pure as download) DETAILS of the two major problems + other minor/major bugs repairs: #1 Coordinates translation The current implementation (Image2Mesh.m) assumes only one possible orientation of object in the patient space. All images are processed as oriented 'LPS' . The MRI structure I use was saved in 'right-anterior-superior' ('RAS') orientation. My spacedir matrix (rotation/scale matrix from patient to xyz space) is as follows (I have 1mm voxels spacing, thus ones in the matrix): 0 0 1 -1 0 0 0 1 0 However, the code assumes nonzero diagonal values (as it is true for 'LPS' patient space orientations). Thus, the following lines: % param.TransformMatrix(1,1) = param.TransformMatrix(1,1) / abs(spacedir(1,1)); % param.TransformMatrix(2,2) = param.TransformMatrix(2,2) / abs(spacedir(2,2)); % param.TransformMatrix(3,3) = param.TransformMatrix(3,3) / abs(spacedir(3,3)); produce NaNs at the diagonal of the transformation matrix. We divide 0 by 0. This leads to a big crush. I think, that the best solution is to use affine transform (param.TransformMatrix = img.ijkToLpsTransform;). This affine matrix is called 'ijkToLpsTransform' but Slicer puts there correct values no matter what is the patient space orientation (i.e. it does not have to be LPS). The rotation and translation of the model are handled separately despite a ready to use affine matrix. Is there any reason to not trust this matrix? I checked it for different DICOMS (a neck and heads carried out by different hospitals) and this affine transform matrix was always good (for different patient orientations!). I am not sure if I fully understand the terminology LPS etc. and what exactly is passed from Slicer (I just tried to reverse engineer this problem). However, it looks like the proposed solution works. Briefly, my changes to the Image2Mesh.m file: - the affine transform instead of rotation and translation The rotation was carried out inside 'Image2Mesh.m' file, the translation was carried out inside 'RunCGALMeshGenerator.m' file. The affine transform does all at once. I have moved the affine operation into 'Image2Mesh.m' as this file is closely related to the Slicer which generates the affine transformation matrix. And it might be more clear to keep the transformation as close as possible to the transformation matrix. - with the affine transform, there is no need of the hard/hand-coded repairs of the rotation matrix (is this to match the fiducials coordinates? I do not understand this rotations around 0X and 0Y axes.): % param.TransformMatrix(1,1) = -1 * param.TransformMatrix(1,1); % param.TransformMatrix(2,2) = -1 * param.TransformMatrix(2,2); - removed redundancies - code polishing, etc. The fix requires changes in two files: RunCGALMeshGenerator.m (NIRFAST package) and Image2Mesh.m (Slicer package). Fixed files attached. #2 Unfinished fiducials business Fiducials coordinates are translated internally by the Slicer (by the same vector as in the affine transform in #1). However, they are not rotated. Fiducials look like they are always in the same patient space, no matter what is the data patient orientation. Thus, to convert the fiducials to the x-y-z coordinates a following rotation matrix should be used: -1 0 0 0 -1 0 0 0 1 I have added the following to the 'Image2Mesh.m' file: sdcoords = ([-1 0 0;0 -1 0; 0 0 1]*sdcoords')'; This and affine transform of the model brings the model and fiducials to the same space. BTW: The fiducials coordinates passed to the 'Image2Mesh.m' function and saved as a *.csv file are different.. #3 Reading fiducials fails if there is only one fiducial. sdcoords = cell2mat(fiducials)'; For one fiducial, the 'fiducials' is not a cell and the command fails returning error. Problem solved in the attached file. #4 Can you repair/swap RunCGALMeshGenerator.m and Image2Mesh.m files in the packages to download? I am going to run a training session 'from MRI to FEM model' for PhD students soon (in 2 weeks). The very first thing I will have to do is to ask everybody to repair tools by replacing files here and there (or use my Matlab meshing implementation directly on SPM files, which I developed to test the errors). I have to work on DICOM files that confuses NIRFASTSlicer. So, I have no choice but distribute NIRFASTSlicer with my repaired files. #5 'Image2Mesh (Matlab)' module? A testing leftover? It has inactive settings/parameters. These parameters are loaded from the 'Create Mesh' module. There is no easy way to guess that. I propose to delete this redundant module. Or repair the inactive options and leave it as backward compatibility for meshing 'LabelMaps' not 'Segmentations' as in the new 'Create Mesh' module. Or add option of meshing a 'LabelMap' to the 'Create Mesh' module? Regards Stanislaw Wojtkiewicz, PhD --- School of Computer Science University of Birmingham B15 2TT --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: RunCGALMeshGenerator.m URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Image2Mesh.m URL: From s.wojtkiewicz at cs.bham.ac.uk Mon May 14 18:53:40 2018 From: s.wojtkiewicz at cs.bham.ac.uk (Stanislaw Wojtkiewicz) Date: Mon, 14 May 2018 23:53:40 +0100 Subject: [Nirfast] NIRFAST bug (?) in forward solution @ frequency domain Message-ID: <00a101d3ebd6$6732af60$35980e20$@cs.bham.ac.uk> Hi All I encountered a weird problem as in the subject. Just to confirm: Can you repeat a very simple experiment: A slab mesh and a source in the frequency domain. I get weird values with the NIRFAST 9 (pure as download) @ frequency domain. For a comparison, I attach the same mesh and source in frequency domain but solved witch my GPU, parallel implementation of BiCGStab solver. Can you confirm? I might be able to look into that at some point. data_FD = femdata_stnd(mesh,100e6); % data_FD = femdata_stnd_CUDA(mesh,100e6); plotimage(mesh, log10(abs(full(data_FD.phi(:,1))))) plotimage(mesh, angle(full(data_FD.phi(:,1)))) Continuous wave mode works fine. Regards Stanislaw Wojtkiewicz, PhD --- School of Computer Science University of Birmingham B15 2TT --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: phase_my_CUDA_BiCGStab_solver.png Type: image/png Size: 30259 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: phase_NIRFAST_9.png Type: image/png Size: 77731 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: amp_my_CUDA_BiCGStab_solver.png Type: image/png Size: 32285 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: amp_NIRFAST_9.png Type: image/png Size: 33865 bytes Desc: not available URL: From s.wojtkiewicz at cs.bham.ac.uk Tue May 15 05:16:37 2018 From: s.wojtkiewicz at cs.bham.ac.uk (Stanislaw Wojtkiewicz) Date: Tue, 15 May 2018 10:16:37 +0100 Subject: [Nirfast] Mathworks removed 'cholinc' function Message-ID: <001b01d3ec2d$6dbe2e20$493a8a60$@cs.bham.ac.uk> Hi All One more problem to report. In time-resolved modality (file 'femdata_stnd_tr.m') the incomplete Cholesky factorisation is used to generate a preconditioner: % R = cholinc(MASS1,1e-3); However, Mathworks removed this function completely since it was not a true incomplete Cholesky (it utilized incomplete LU with pivoting). I suggest to replace the missing function by: R = ichol(MASS1,struct('type','ict','droptol',1e-3,'shape','upper')); Works in my case. Regards Stanislaw Wojtkiewicz, PhD --- School of Computer Science University of Birmingham B15 2TT --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: