MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
287 stars 178 forks source link

fixelcfestats: abnormal termination when doing t-tests + f-test #2289

Closed diagiraldo closed 3 years ago

diagiraldo commented 3 years ago

Describe the bug I am trying to run the fixelcfestats to perform hypothesis testing for multiple contrasts + an f-test, but the process terminates abruptly while calculating the basic properties of the default permutation, even when I use the -notest flag:

fixelcfestats -force smoothed_fixel_data list_of_files.txt design_matrix.txt contrasts.txt wm_fixel_connectivity stats_results -mask fixel_mask.mif -exchange_within blocks.txt -variance blocks.txt -ftests ftests.txt -notest
fixelcfestats: [WARNING] existing output files will be overwritten
fixelcfestats: Number of fixels in template: 574477
fixelcfestats: Number of fixels in mask: 498510
fixelcfestats: [done] Configuring data import from files listed in "list_of_files.txt" as found relative to directory "smoothed_fixel_data"
fixelcfestats: Number of inputs: 8
fixelcfestats: Number of factors: 6
fixelcfestats: Design matrix condition number: 14.3611
fixelcfestats: Number of variance groups: 2
fixelcfestats: Number of hypotheses: 5
fixelcfestats: [WARNING] A total of 15032 fixels in the provided mask do not possess any streamlines-based connectivity; these will not be enhanced by CFE, and hence cannot be tested for statistical significance
fixelcfestats: [100%] Loading fixel data (no smoothing)
fixelcfestats: [  6%] Calculating basic properties of default permutation...double free or corruption (out)
Aborted (core dumped)

It should be mentioned I am including two different measures in the testing so I have 2 exchangeability blocks and variance blocks while the design matrix also has 2 blocks, however It works without problem when:

To Reproduce

Data I used to reproduce the error: https://drive.google.com/file/d/1U3rIOQ9T8DvVXH3wCNycKuohx4pM_VLD/view?usp=sharing

Platform/Environment/Version

Advanced debugging information

This is what happens when debugging:

diana@expe:/mnt/md0/min_example_ftests_contrasts$ gdb --args fixelcfestats -force smoothed_fixel_data list_of_files.txt design_matrix.txt contrasts.txt wm_fixel_connectivity stats_results -mask fixel_mask.mif -exchange_within blocks.txt -variance blocks.txt -ftests ftests.txt -notest
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from fixelcfestats...(no debugging symbols found)...done.
(gdb) r
Starting program: /mnt/md0/mrtrix3/bin/fixelcfestats -force smoothed_fixel_data list_of_files.txt design_matrix.txt contrasts.txt wm_fixel_connectivity stats_results -mask fixel_mask.mif -exchange_within blocks.txt -variance blocks.txt -ftests ftests.txt -notest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
fixelcfestats: [WARNING] existing output files will be overwritten
fixelcfestats: Number of fixels in template: 574477
fixelcfestats: Number of fixels in mask: 498510
fixelcfestats: [done] Configuring data import from files listed in "list_of_files.txt" as found relative to directory "smoothed_fixel_data"
fixelcfestats: Number of inputs: 8
fixelcfestats: Number of factors: 6
fixelcfestats: Design matrix condition number: 14.3611
fixelcfestats: Number of variance groups: 2
fixelcfestats: Number of hypotheses: 5
fixelcfestats: [WARNING] A total of 15032 fixels in the provided mask do not possess any streamlines-based connectivity; these will not be enhanced by CFE, and hence cannot be tested for statistical significance
fixelcfestats: [100%] Loading fixel data (no smoothing)
[New Thread 0x7ffe594f3700 (LWP 31227)]
fixelcfestats: [  0%] Calculating basic properties of default permutation...[New Thread 0x7ffe58cf2700 (LWP 31228)]
fixelcfestats: [  2%] Calculating basic properties of default permutation...[New Thread 0x7ffe53fff700 (LWP 31229)]
fixelcfestats: [  3%] Calculating basic properties of default permutation...[New Thread 0x7ffe537fe700 (LWP 31230)]
[New Thread 0x7ffe52ffd700 (LWP 31231)]
[New Thread 0x7ffe527fc700 (LWP 31232)]
fixelcfestats: [  4%] Calculating basic properties of default permutation...[New Thread 0x7ffe51ffb700 (LWP 31233)]
[New Thread 0x7ffe517fa700 (LWP 31234)]
fixelcfestats: [  5%] Calculating basic properties of default permutation...[New Thread 0x7ffe50ff9700 (LWP 31235)]
[New Thread 0x7ffe33fff700 (LWP 31236)]
double free or corruption (out)
fixelcfestats: [  7%] Calculating basic properties of default permutation...
Thread 9 "fixelcfestats" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffe517fa700 (LWP 31234)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6a078b1 in __GI_abort () at abort.c:79
#2  0x00007ffff6a50907 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff6b7ddfa "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff6a5797a in malloc_printerr (str=str@entry=0x7ffff6b7fad0 "double free or corruption (out)") at malloc.c:5350
#4  0x00007ffff6a5eee5 in _int_free (have_lock=0, p=0x7ffe38000d90, av=0x7ffff6db2c40 <main_arena>) at malloc.c:4278
#5  __GI___libc_free (mem=0x7ffe38000da0) at malloc.c:3124
#6  0x00007ffff7b49507 in MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&) ()
   from /mnt/md0/mrtrix3/bin/../lib/libmrtrix.so
#7  0x00007ffff7b4b399 in MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor::operator()(unsigned long const&) () from /mnt/md0/mrtrix3/bin/../lib/libmrtrix.so
#8  0x00007ffff7b4b499 in MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >::execute() () from /mnt/md0/mrtrix3/bin/../lib/libmrtrix.so
#9  0x00007ffff7b2f57d in std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<void (MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >::*)(), MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >*> >, void> >::_M_invoke(std::_Any_data const&) () from /mnt/md0/mrtrix3/bin/../lib/libmrtrix.so
#10 0x0000555555572c79 in std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) ()
#11 0x00007ffff6dc7827 in __pthread_once_slow (once_control=0x5555558b07f8, init_routine=0x7ffff76498a0 <__once_proxy>) at pthread_once.c:116
#12 0x00007ffff7b35c3f in std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<void (MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >::*)(), MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >*> >, void>::_Async_state_impl(std::thread::_Invoker<std::tuple<void (MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >::*)(), MR::Thread::(anonymous namespace)::__Sink<MR::Thread::(anonymous namespace)::__Batch<unsigned long>, MR::Thread::(anonymous namespace)::__Multi<MR::Math::Stats::GLM::all_stats(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, MR::vector<MR::Math::Stats::CohortDataImport, 0> const&, MR::vector<MR::Math::Stats::GLM::Hypothesis, 0> const&, Eigen::Array<unsigned long, -1, 1, 0, -1, 1> const&, Eigen::Array<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&)::Functor> >*> >&&)::{lambda()#1}> > >::_M_run() () from /mnt/md0/mrtrix3/bin/../lib/libmrtrix.so
#13 0x00007ffff764a6df in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
---Type <return> to continue, or q <return> to quit---
#14 0x00007ffff6dbf6db in start_thread (arg=0x7ffe517fa700) at pthread_create.c:463
#15 0x00007ffff6ae8a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Lestropie commented 3 years ago

Hi Diana,

I've sent a request to obtain access to the Google Drive data.

There's a chance that #2269 will intrinsically resolve your issue, as the deeper structural changes happening there are very relevant to the case where both t-tests and F-tests are performed. But then again, given it's the all_stats() function that's failing, maybe not, the changes there are mostly around the GLM classes... I've not yet fully resolved and completed those changes, but you could just try compiling and running it and see what happens. #2260 should not be relevant here as you don't have non-finite values in your data.

Rob

Lestropie commented 3 years ago

Thanks for the data Diana.

My dismissal of non-finite values was slightly premature: while there are no non-finite values in your input data inside your mask (and hence no warning regarding such was generated at the command-line), the fixel data outside of this mask does contain non-finite values. It is the combination of this fact with the presence of an F-test that exposed the error (using -fonly actually still has the same error, it just happened to not be detected in release mode when you tried it).

2294 should fix the fault.

Rob