fangq / brain2mesh

Brain2Mesh - a one-liner for high-quality brain mesh generation
http://mcx.space/brain2mesh
Other
34 stars 14 forks source link

The mesh fails with my segmentation from SPM #11

Closed RebinaFrancis closed 4 years ago

RebinaFrancis commented 4 years ago

Dear brain2mesh

I have been trying to use your program to create meshes from an MRI segmented using SPM12, however, the results seem very wrong ('rotated', in fact). I have followed your guide in spm_seg_with_brain2mesh.pdf which works fine. Could you perhaps tell me what might be wrong? I have included screenshots of the segmentation in SPM, as well as the output from brain2mesh for both my segmentation and the output from following your guide.

Additionally, I get the following error when trying to include the skull tissue type in brain2mesh:

Error using plot3 There is no FaceColor property on the Line class. Error in plotmesh (line 145) h=plot3(node(idx,1),node(idx,2),node(idx,3),opt{:}); Error in SPM_example_brain (line 34) plotmesh(node,elem(elem(:,5)==2,:),'x>90 | z<130','FaceColor',[1 1 0.9]) %%bone

I suppose this might be due to a difference in matlab version? I am using MATLAB R2019b.

I hope you can help. Best Rebina

My segmentation image

My mesh image

Your mesh image

fangq commented 4 years ago

@RebinaFrancis, brain2mesh (same as iso2mesh) uses the MRI coordinates, so if the raw image is rotated, the mesh generated will be rotated - if you want to convert it to the correct (RAS) orientation, you will have to read out the qform/sform records in the NIfTI-1 header and apply the rotation matrix to the generated mesh nodes. see

https://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/quatern.html

also, I see your raw image has a lot of noise. To set a different threshold to remove the noise, you should do a data cleaning/trimming, for example, for your scalp data, read it in matlab, set a more aggressive threshold, say 90% of the peak value to get rid off the noise, and then save it back to the .nii.gz file using savenifti.m in iso2mesh.

other than the rotation and high background noise, I don't see other issues - you should not run the 10-20 point line because the reference positions included are not for this anatomy.

RebinaFrancis commented 4 years ago

Thank you, it works!

fangq commented 4 years ago

cool! closing this ticket for now. feel free to reopen if you see additional issues.

RebinaFrancis commented 4 years ago

Dear Brain2mesh

As I understand it, openmeeg recommends the meshsize to be approximately 600 to 800 points per surface(https://openmeeg.github.io/tutorial.html). Without adjusting any parameters in cfg, I get a size between approx. 100000 and 900000. I have tried setting 'cfg.maxnode' to 1000. However, the number of nodes is still very high. Could you perhaps help me? I have included screenshots of the size of the elements per surface before and after this change .

Best Rebina

Before this change before

After this change After