nipy / mindboggle

Automated anatomical brain label/shape analysis software (+ website)
http://mindboggle.info
Other
146 stars 54 forks source link

negative area values #100

Closed birdcw closed 7 years ago

birdcw commented 7 years ago

Hi All,

I've been trying out mindboggle on ADNI subjects. 1/5 of the subjects so far have had negative area measures for some of the labels. I can investigate further. I'm curious if there's any existing possible explanation for this?

binarybottle commented 7 years ago

Thank you for alerting us to this. I can't say that I've ever seen mindboggle generate negative area values, and I've processed a lot of ADNI brain images! Could you please send me the output table in question, label_shapes.csv, as well as vertices.csv, if you generated that as well?

Please send them to arno@mindboggle.info, or share them via dropbox, google drive, etc.

binarybottle commented 7 years ago

Sorry for the delay -- I returned from a programming workshop at MIT, which was all-consuming!

I took a look at the tables you sent me, and it seems that while the vertices.csv tables all have positive per-vertex area values, somehow the area sums computed for certain labels became negative. How strange. Would you please send me the FreeSurfer output directory for the subject ADNI_011_S_2274_MR_MPRAGE_GRAPPA2_br_raw_20110505140334725_58_S108103_I233442? I want to get to the bottom of this!

binarybottle commented 7 years ago

I looked back at our mindboggle-processed ADNI data that we summarized in an article and in a poster:

Klein A, Chaibub Neto E, Ghosh S, ADNI. Detailed shape analysis of healthy brains and brains with Alzheimer’s disease. In: 21st annual meeting for the Organization of Human Brain Mapping [Internet]. 2015. https://mfr.osf.io/render?url=https://osf.io/xfts3/?action=download%26mode=render

I couldn't find any examples of negative area values for labeled regions in the ADNI brains (each individual is a row and each label is a column in this heatmap of area values):

area area.pdf

Which is all to say that I'm very interested to understand how we processed the images differently...

birdcw commented 7 years ago

Hello,

Thanks for looking into this. I've sent my freesurfer and ants input to you. I used docker, included the optional ants input, and specified 8/8 cpus. I've started a new batch today, which includes alternate/repeat scans for 3 subjects who had negative areas. I'll let you know if I see negative values again.

birdcw commented 7 years ago

I hope to have 80 subjects processed by Monday, so it would be interesting and re-assuring to confirm how closely my tables match yours, at least for the all positive area subjects.

binarybottle commented 7 years ago

The nipype crash file indicates that there are missing values (two nans) in the area vtk file, rh.pial.area.vtk, but not in the original file rh.pial.vtk converted from FreeSurfer's rh.pial:

Executing node Shape_tables.a1 in dir: /home/jovyan/work/mindboggling/ADNI_011_S_2274_MR_MPRAGE_GRAPPA2_br_raw_20110505140334725_58_S108103_I233442/Mindboggle/_hemi_rh/Shape_tables Generic Warning: In ../IO/Legacy/vtkDataReader.cxx, line 1379 Error reading ascii data. Possible mismatch of datasize with declaration.

ERROR: In ../IO/Legacy/vtkDataReader.cxx, line 912 vtkPolyDataReader (0x4542000): Unsupported point attribute type: nan for file: /home/jovyan/work/mindboggling/ADNI_011_S_2274_MR_MPRAGE_GRAPPA2_br_raw_20110505140334725_58_S108103_I233442/Mindboggle/Surface_shapes/_hemi_rh/Surface_area/rh.pial.area.vtk

I confirmed this by running just the mindboggle.shapes.surface_shapes.area command, which calls the PointAreaMain C++ function, and this also generated the nan values.

I manually replaced the two nan values with zeros, and was able to proceed. I am traveling in Europe now, but will try to fix this soon...

binarybottle commented 7 years ago

I added some conditional statements to PointAreaComputer.cpp to avoid NaN values. Specifically, when any of the three angles about a vertex in the triangular mesh is a NaN value, the corresponding 1/3 area that would be added to the area of the vertex is set to zero. This avoided NaN values in the ADNI data you provided, so I am closing this issue. Please reopen this issue if this ever arises again, and thank you for helping us to solve it!

binarybottle commented 7 years ago

From Joachim Giard, who wrote the original program computing surface area:

"It's almost never a good idea to replace a Nan by zero. The best is to find why Nan can happen and try to find the origin. Here, we would like to know why some angles may have a Nan value. It's almost always a division by zero, so for the angle, it could be a limit case like twice the same edge or something similar... It seems to be possible only when a > b + c, i.e. when the triangle is badly defined or when the polygon is not a triangle. In this case, x could be greater than y in acos(x/y)."

"If we don't have control over surface reconstruction, assigning zero to the area is probably the best solution. Except if we remesh, but that's clearly non trivial. We just have to ensure that the number of badly defined triangles is not too important."

binarybottle commented 7 years ago

I will be building a new docker container with these changes very soon, and will alert you when it's ready, @birdcw.

binarybottle commented 7 years ago

I have created a new Docker container that will run FreeSurfer, ANTs, and the revised Mindboggle. Please see the new docker pull and run instructions (http://mindboggle.readthedocs.io/en/latest/#installing-mindboggle).