Deep-MI / fsqc

A set of quality control scripts for FreeSurfer- and FastSurfer-processed structural MRI data
https://deep-mi.org
MIT License
56 stars 14 forks source link

ValueError: array must not contain infs or NaNs #6

Closed XinQi7788 closed 3 years ago

XinQi7788 commented 3 years ago

When I ran qatools-python on a FreeSurfer process finished subject without any error, but got Error messages in details as below. The freeview of the subject looks fine as well.

Traceback (most recent call last): File "qatools.py", line 17, in qatoolspython.run_qatools(subjects_dir, output_dir, subjects, subjects_file, shape, screenshots, screenshots_html, screenshots_base, screenshots_overlay, screenshots_surf, screenshots_views, screenshots_layout, fornix, outlier, outlier_table, fastsurfer) File "/home/Xin/qatools-python/qatoolspython/qatoolspython.py", line 1045, in run_qatools _do_qatools(subjects_dir, output_dir, subjects, shape, screenshots, screenshots_html, screenshots_base, screenshots_overlay, screenshots_surf, screenshots_views, screenshots_layout, fornix, outlier, outlier_table, fastsurfer) File "/home/Xin/qatools-python/qatoolspython/qatoolspython.py", line 881, in _do_qatools evMat, evecMat, dstMat = brainprint.run_brainprint(sdir=subjects_dir, sid=subject, outdir=brainprint_outdir, evec=SHAPE_EVEC, skipcortex=SHAPE_SKIPCORTEX, num=SHAPE_NUM, norm=SHAPE_NORM, reweight=SHAPE_REWEIGHT, asymmetry=SHAPE_ASYMMETRY) File "/home/Xin/.local/lib/python3.8/site-packages/brainprint/brainprint.py", line 710, in run_brainprint dstMat = _compute_asymmetry(options, evMat) File "/home/Xin/.local/lib/python3.8/site-packages/brainprint/brainprint.py", line 647, in _compute_asymmetry structures_left_right[i]["right"]] = ShapeDNA.compute_distance( File "/home/Xin/.local/lib/python3.8/site-packages/lapy/ShapeDNA.py", line 135, in compute_distance return di.euclidean(ev1, ev2) File "/home/Xin/miniconda3/lib/python3.8/site-packages/scipy/spatial/distance.py", line 626, in euclidean return minkowski(u, v, p=2, w=w) File "/home/Xin/miniconda3/lib/python3.8/site-packages/scipy/spatial/distance.py", line 530, in minkowski dist = norm(u_v, ord=p) File "/home/Xin/miniconda3/lib/python3.8/site-packages/scipy/linalg/misc.py", line 140, in norm a = np.asarray_chkfinite(a) File "/home/Xin/miniconda3/lib/python3.8/site-packages/numpy/lib/function_base.py", line 488, in asarray_chkfinite raise ValueError( ValueError: array must not contain infs or NaNs

Please let me know how to resolve such issue? Thank you very much.

Xin

kdiers commented 3 years ago

Hi Xin,

do you observe this error for one particular subject or for multiple ones? I am asking because for our test cases I did not observe it so far, so I'd be surprised if it happens often. If it's only one (or very few) cases, then I speculate that it might be a problem with a particular brain structure (for which we compute the asymmetry) in this particular subject, but it's difficult to tell from the outside what exactly the problem is. If you can share this data (the 'aseg.mgz' file is sufficient for the moment), we could take a closer look. We could provide an upload link if that helps.

The easiest solution at the moment is to leave out the '--shape' option for this case; as an alternative, I am considering to implement an exception handling if there are issues with any single brain structures so that the program does not crash, but ideally it would be nice to know a bit more about the root of the problem before doing that.

Best, Kersten

XinQi7788 commented 3 years ago

Hi Kersten:

Sorry for my late reply, just saw your message. I observe this error from many subjects (such as 11 out of 1000 ADNI preprocessed images).

Please share me the upload link that I can upload a few aseg.mgz files of those failed subjects.

Thank you very much and looking forward to your reply.

Best Xin

XinQi7788 commented 3 years ago

Hi Kersten:

Is it possible to create a html file containing all the cc.png files of each subject from Fornix module?

Of course, we can write our own script to do so after the qatools-python finishes its processing, but it you can create such an extra flag to do so, that would be great and appreciate :).

Best Xin

kdiers commented 3 years ago

Hi, thanks for uploading the sample data.

The NaN issue is probably due to the fact that some parts of the surfaces are degenerate.The surfaces consist of triangles, and at some point we need to calculate the area of these triangles, which fails. I do not think that this is recoverable at the moment, so the only thing I could do was to catch these exceptions, and let the program continue processing instead of crashing. The output of the shape module will be empty in this case.

A --fornix-html option has been added to produce html output for the fornix module.

Thanks, Kersten