Tckgen/mrview Segmentation fault: Invalid memory access

Hello,

I think i’m being really dense and would appreciate any advise. I have seen similar posts, but have not quite been able to resolve issues running tckgen. Initially I got Segmentation fault: Invalid memory access when attempting to run tckgen. I tried various submission iterations to overcome this. I have also cleared up my storage space so that shouldn’t be an issue, so I am kind of at a loss why it isnt working as expected.

%%shell

projectDir=$WORK/connectomeProject
DATADIR=$projectDir/data ; echo "dataDir is : ${DATADIR}"  
module load mrtrix

echo -n "" > ${projectDir}/commandFiles/tractGenCommands.txt    

for subject in `ls $DATADIR`;
    do
        if [ -f ${DATADIR}/${subject}/5TT_lesion.mif ];
      then
        echo " module load \"mrtrix\"; tckgen ${DATADIR}/${subject}/WM_FODs.mif ${DATADIR}/${subject}/100M.tck -act ${DATADIR}/${subject}/5TT_lesion.mif -backtrack -crop_at_gmwmi -seed_dynamic ${DATADIR}/${subject}/WM_FODs.mif -maxlength 250 -select 100M -cutoff 0.06 -force; tcksift ${DATADIR}/${subject}/100M.tck ${DATADIR}/${subject}/WM_FODs.mif ${DATADIR}/${subject}/10M_SIFT.tck -act ${DATADIR}/${subject}/5TT_lesion.mif -term_number 10M"  >> ${projectDir}/commandFiles/tractGenCommands.txt
      else
        echo " module load \"mrtrix\"; tckgen ${DATADIR}/${subject}/WM_FODs.mif ${DATADIR}/${subject}/100M.tck -act ${DATADIR}/${subject}/5TT.mif -backtrack -crop_at_gmwmi -seed_dynamic ${DATADIR}/${subject}/WM_FODs.mif -maxlength 250 -select 100M -cutoff 0.06 -force; tcksift ${DATADIR}/${subject}/100M.tck ${DATADIR}/${subject}/WM_FODs.mif ${DATADIR}/${subject}/10M_SIFT.tck -act ${DATADIR}/${subject}/5TT.mif -term_number 10M"  >> ${projectDir}/commandFiles/tractGenCommands.txt
    fi
done
      
    # Run array job
    $HOME/c3nl_tools/hpcRunArrayJob.sh ${projectDir}/commandFiles/tractGenCommands.txt 12:00:00 48 124Gb

** Edit ** I have changed the above to generate 10M streamlines in favour of SIFT2

All the best,
Niall

Dear Neuroenthusiasts,

Around half my sample have completed without error, but there seems to be certain participants who are just being uncompliant. I tried re-running previous steps and the RGB, WM_FOD look fine. I have included the debug output if anyone has any insight.

tckgen -version is 64 bit release version, built Dec 20 2017, using Eigen 3.3.4

(py27) -bash-4.2$ 
(py27) -bash-4.2$ tckgen -nthreads 0 WM_FODs.mif 10M.tck -act 5TT.mif -backtrack -crop_at_gmwmi -seed_dynamic WM_FODs.mif -maxlength 250 -select 100 -cutoff 0.06 -force -debug
tckgen: [WARNING] existing output files will be overwritten
tckgen: [DEBUG] No config file found at "/etc/mrtrix.conf"
tckgen: [DEBUG] No config file found at "/home/nbourke/.mrtrix.conf"
tckgen: [INFO] opening image "WM_FODs.mif"...
tckgen: [DEBUG] reading key/value file "WM_FODs.mif"...
tckgen: [DEBUG] sanitising image information...
tckgen: [INFO] image "WM_FODs.mif" opened with dimensions 128x128x66x45, voxel spacing 2x2x2x1, datatype Float32LE
tckgen: [DEBUG] memory-mapping file "WM_FODs.mif"...
tckgen: [DEBUG] file "WM_FODs.mif" mapped at 0x2b87d07ed000, size 194641920 (read-only)
tckgen: [DEBUG] image "WM_FODs.mif" loaded
tckgen: [DEBUG] image "WM_FODs.mif" initialised with strides = [ -45 5760 737280 1 ], start = 5715, using direct IO
tckgen: [DEBUG] sanitising image information...
tckgen: [DEBUG] allocating scratch buffer for image "fixel map voxels"...
tckgen: [DEBUG] image "fixel map voxels" loaded
tckgen: [DEBUG] image "fixel map voxels" initialised with strides = [ -1 128 16384 ], start = 127, using direct IO
tckgen: [DEBUG] sanitising image information...
tckgen: [DEBUG] allocating scratch buffer for image "SIFT model processing mask"...
tckgen: [DEBUG] image "SIFT model processing mask" loaded
tckgen: [DEBUG] image "SIFT model processing mask" initialised with strides = [ -1 128 16384 ], start = 127, using direct IO
tckgen: [INFO] opening image "5TT.mif"...
tckgen: [DEBUG] reading key/value file "5TT.mif"...
tckgen: [DEBUG] sanitising image information...
tckgen: [INFO] image "5TT.mif" opened with dimensions 128x128x66x5, voxel spacing 2x2x2xnan, datatype Float32LE
tckgen: [DEBUG] memory-mapping file "5TT.mif"...
tckgen: [DEBUG] file "5TT.mif" mapped at 0x2b87dcdf1000, size 21626880 (read-only)
tckgen: [DEBUG] image "5TT.mif" loaded
tckgen: [DEBUG] image "5TT.mif" initialised with strides = [ 5 640 81920 1 ], start = 0, using direct IO
tckgen: [DEBUG] sanitising image information...
tckgen: [DEBUG] allocating scratch buffer for image "5TT scratch buffer"...
tckgen: [DEBUG] image "5TT scratch buffer" loaded
tckgen: [DEBUG] image "5TT scratch buffer" initialised with strides = [ -5 640 81920 1 ], start = 635, using direct IO
tckgen: [INFO] 5TT image dimensions match fixel image - importing directly
tckgen: [DEBUG] unmapping file "5TT.mif"
tckgen: [DEBUG] image "5TT.mif" unloaded
tckgen: [INFO] opening image "5TT.mif"...
tckgen: [DEBUG] reading key/value file "5TT.mif"...
tckgen: [DEBUG] sanitising image information...
tckgen: [INFO] image "5TT.mif" opened with dimensions 128x128x66x5, voxel spacing 2x2x2xnan, datatype Float32LE
tckgen: [DEBUG] memory-mapping file "5TT.mif"...
tckgen: [DEBUG] file "5TT.mif" mapped at 0x2b87df733000, size 21626880 (read-only)
tckgen: [DEBUG] image "5TT.mif" loaded
tckgen: [DEBUG] image "5TT.mif" initialised with strides = [ 5 640 81920 1 ], start = 0, using direct IO
tckgen: [100%] segmenting FODs
tckgen: [INFO] opening image "WM_FODs.mif"...
tckgen: [DEBUG] reading key/value file "WM_FODs.mif"...
tckgen: [DEBUG] sanitising image information...
tckgen: [INFO] image "WM_FODs.mif" opened with dimensions 128x128x66x45, voxel spacing 2x2x2x1, datatype Float32LE
tckgen: [DEBUG] memory-mapping file "WM_FODs.mif"...
tckgen: [DEBUG] file "WM_FODs.mif" mapped at 0x2b87e0bd4000, size 194641920 (read-only)
tckgen: [DEBUG] image "WM_FODs.mif" loaded
tckgen: [DEBUG] image "WM_FODs.mif" initialised with strides = [ -45 5760 737280 1 ], start = 5715, using direct IO
tckgen: [INFO] opening image "5TT.mif"...
tckgen: [DEBUG] reading key/value file "5TT.mif"...
tckgen: [DEBUG] sanitising image information...
tckgen: [INFO] image "5TT.mif" opened with dimensions 128x128x66x5, voxel spacing 2x2x2xnan, datatype Float32LE
tckgen: [DEBUG] memory-mapping file "5TT.mif"...
tckgen: [DEBUG] file "5TT.mif" mapped at 0x2b87ec576000, size 21626880 (read-only)
tckgen: [DEBUG] image "5TT.mif" loaded
tckgen: [DEBUG] image "5TT.mif" initialised with strides = [ 5 640 81920 1 ], start = 0, using direct IO
tckgen: [INFO] step size = 1 mm
tckgen: [INFO] maximum deviation angle = 45 deg
tckgen: [INFO] minimum radius of curvature = 1.9999999443449312 mm
tckgen: [INFO] iFOD2 internal step size = 0.333333343 mm
tckgen: [DEBUG] creating empty file "10M.tck"
tckgen: [INFO] rejection sampling will use 7 directions with a ratio of 2.15373945 (predicted number of samples per step = 12.9595909)

tckgen: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access
(py27) -bash-4.2$ 

I can successfully run it on my local computer
64 bit release version, built Nov 10 2016, using Eigen 3.2.10

However this kind of defeats the purpose of trying to put the whole pipeline together in a Jupyter notebook to run on our cluster :). Please tell me if I am just being dense and cant see something obvious.

Best,

I’d love to… :wink: – but I’m sure I can in this instance.

Given that the same command works fine for some datasets but not others, it’s definitely worth having a good look at the command’s inputs to verify that there is nothing immediately erroneous about them. Maybe @rsmith will be able to give you some pointers as to what to look out for.

But regardless, we view any unexpected crash like this as a bug – we should check that all our assumptions are met and provide an informative error message if there is an issue with the data. But we need to figure out what’s causing the issue first, and I guess this is going to take some debugging… Can you try prefixing your command with catchsegv (I only just found out about this gem), i.e.:

catchsegv tckgen -nthreads 0 WM_FODs.mif 10M.tck -act 5TT.mif ...

See what that reports…

If you’re feeling adventurous, you could try compiling a debug build, and run it again with the catchgsegv prefix. That will run much slower, but give us a much more precise location for where the problem occurs.

And if you’re feeling very patient, you could also try running the debug version with a valgrind prefix (if it’s installed). It’ll run very slow, but will hopefully tell us straight away if there are memory handling bugs in our code…

Dear Donald and other developers,

With my Ubuntu 16.04 computer centrally managed by the Aalto University (although with sudo rights), mrview is constantly crashing (mrview: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access). This happens approximately every 5 minutes during routine zoom / change of view operations (from single to ortho e.g.). This causes a lot of trouble, especially when making connectome figures to restart every time from the scratch. The mrtrix3 build I use is brand new, and I just checked there are no further updates available.

Here’s the configure log and debug information. I would appreciate any tips on this matter, as currently I am forced to use TeamViewer to connect to my home computer to make any figures.

Cheers,
Timo

mrview -version
== mrview 3.0_RC3-135-g2b8e7d0c ==
64 bit release version, built Mar 12 2019, using Eigen 3.2.92
ldd $(which mrview)
	linux-vdso.so.1 =>  (0x00007ffc38997000)
	libmrtrix.so => /m/home/home7/72/tjroine/unix/mrtrix3/bin/../lib/libmrtrix.so (0x00007f0515294000)
	libQt5Widgets.so.5 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5 (0x00007f0514a63000)
	libQt5Gui.so.5 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5 (0x00007f05142c8000)
	libQt5Core.so.5 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libQt5Core.so.5 (0x00007f0513ba8000)
	libGL.so.1 => /usr/lib/nvidia-384/libGL.so.1 (0x00007f0513866000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0513649000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f05132c7000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0512fbe000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0512da8000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f05129de000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f05156bc000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f05127c4000)
	libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f051254f000)
	libicui18n.so.56 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libicui18n.so.56 (0x00007f05120b6000)
	libicuuc.so.56 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libicuuc.so.56 (0x00007f0511cfe000)
	libicudata.so.56 => /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib/libicudata.so.56 (0x00007f051031b000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0510117000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f050ff0f000)
	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f050fd0d000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f050f9fc000)
	libnvidia-tls.so.384.130 => /usr/lib/nvidia-384/tls/libnvidia-tls.so.384.130 (0x00007f050f7f8000)
	libnvidia-glcore.so.384.130 => /usr/lib/nvidia-384/libnvidia-glcore.so.384.130 (0x00007f050d93c000)
	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f050d602000)
	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f050d3f0000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f050d1ce000)
	libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f050cfc0000)
	libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f050cd67000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f050caf7000)
	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f050c8d5000)
	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f050c6d1000)
	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f050c4cb000)

<CONFIGURE.LOG STARTS>

REPORT: 
MRtrix build type requested: release version

REPORT: Detecting OS: linux

REPORT: Looking for compiler [clang++]:
EXEC <<
CMD: clang++ --version
error invoking command "clang++": No such file or directory
>>


REPORT: not found

REPORT: Looking for compiler [g++]:
EXEC <<
CMD: g++ --version
EXIT: 0
STDOUT:
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>


REPORT: g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609

REPORT: Checking for C++11 compliance:

COMPILE /tmp/tmpwsdj2X.cpp:
---

#include <cstddef>
struct Base {
    Base (int);
};
struct Derived : Base {
    using Base::Base;
};

int main() {
  Derived D (int); // check for contructor inheritance
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC /tmp/tmpwsdj2X.cpp -o /tmp/tmpwsdj2X.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpwsdj2X.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking shared library generation:
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC /tmp/tmpG9Epnn.cpp -o /tmp/tmpG9Epnn.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpG9Epnn.o -shared -Wl,--sort-common,--as-needed -pthread -o libtest.so
EXIT: 0
>>


REPORT: ok

REPORT: Detecting pointer size:

COMPILE /tmp/tmpUDeNpr.cpp:
---

#include <iostream>
int main() {
  std::cout << sizeof(void*);
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC /tmp/tmpUDeNpr.cpp -o /tmp/tmpUDeNpr.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpUDeNpr.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
8
>>


REPORT: 64 bit

REPORT: Detecting byte order:

REPORT: little-endian

REPORT: Checking for variable-length array support:

COMPILE /tmp/tmpDuuqQV.cpp:
---

int main(int argc, char* argv[]) {
  int x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 /tmp/tmpDuuqQV.cpp -o /tmp/tmpDuuqQV.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpDuuqQV.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking for non-POD variable-length array support:

COMPILE /tmp/tmpN1nguI.cpp:
---

#include <string>

class X {
  int x;
  double y;
  std::string s;
};

int main(int argc, char* argv[]) {
  X x[argc];
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 /tmp/tmpN1nguI.cpp -o /tmp/tmpN1nguI.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpN1nguI.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok

REPORT: Checking for ::max_align_t:

COMPILE /tmp/tmpGIES3K.cpp:
---

#include <iostream>
#include <cstddef>
using ::max_align_t;
int main() {
  std::cout << alignof (max_align_t) << " bytes\n";
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 /tmp/tmpGIES3K.cpp -o /tmp/tmpGIES3K.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpGIES3K.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
16 bytes
>>


REPORT: 16 bytes

REPORT: Checking for std::max_align_t:

COMPILE /tmp/tmpDnOwwX.cpp:
---

#include <iostream>
#include <cstddef>
using std::max_align_t;
int main() {
  std::cout << alignof (max_align_t) << " bytes\n";
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 /tmp/tmpDnOwwX.cpp -o /tmp/tmpDnOwwX.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpDnOwwX.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
16 bytes
>>


REPORT: 16 bytes
EXEC <<
CMD: pkg-config --cflags eigen3
EXIT: 0
STDOUT:
-I/usr/include/eigen3
>>


REPORT: Checking for Eigen3 library:

COMPILE /tmp/tmpRDZx3E.cpp:
---

#include <cstddef>
#include <Eigen/Core>
#include <iostream>

int main (int argc, char* argv[]) {
  std::cout << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << "\n";
  return 0;
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -isystem /usr/include/eigen3 /tmp/tmpRDZx3E.cpp -o /tmp/tmpRDZx3E.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpRDZx3E.o -Wl,--sort-common,--as-needed -pthread -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
3.2.92
>>


REPORT: 3.2.92
EXEC <<
CMD: pkg-config --cflags zlib
EXIT: 0
>>

EXEC <<
CMD: pkg-config --libs zlib
EXIT: 0
STDOUT:
-lz
>>


REPORT: Checking for zlib compression library:

COMPILE /tmp/tmp9wBlOO.cpp:
---

#include <iostream>
#include <zlib.h>

int main() {
  std::cout << zlibVersion();
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 /tmp/tmp9wBlOO.cpp -o /tmp/tmp9wBlOO.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmp9wBlOO.o -Wl,--sort-common,--as-needed -pthread -lz -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
1.2.8
>>


REPORT: 1.2.8

REPORT: Checking for "JSON for Modern C++" requirements:

COMPILE /tmp/tmprhAYEt.cpp:
---

#include "file/json.h"
int main (int argc, char* argv[])
{
  nlohmann::json json;
  json["key"] = "value";
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -I/m/home/home7/72/tjroine/unix/mrtrix3/core /tmp/tmprhAYEt.cpp -o /tmp/tmprhAYEt.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmprhAYEt.o -Wl,--sort-common,--as-needed -pthread -lz -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
>>


REPORT: ok
EXEC <<
CMD: pkg-config --cflags libtiff-4
EXIT: 0
STDOUT:
-I/usr/include/x86_64-linux-gnu
>>

EXEC <<
CMD: pkg-config --libs libtiff-4
EXIT: 0
STDOUT:
-ltiff
>>


REPORT: Checking for TIFF library:

COMPILE /tmp/tmp_Fn8II.cpp:
---

#include <iostream>
#include <tiffio.h>

int main() {
  std::cout << TIFFGetVersion();
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -isystem /usr/include/x86_64-linux-gnu /tmp/tmp_Fn8II.cpp -o /tmp/tmp_Fn8II.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmp_Fn8II.o -Wl,--sort-common,--as-needed -pthread -lz -ltiff -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
LIBTIFF, Version 4.0.6
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
>>


REPORT: LIBTIFF, Version 4.0.6
EXEC <<
CMD: pkg-config --cflags fftw3
EXIT: 0
>>

EXEC <<
CMD: pkg-config --libs fftw3
EXIT: 0
STDOUT:
-lfftw3
>>


REPORT: Checking for FFTW library:

COMPILE /tmp/tmpI204e4.cpp:
---

#include <iostream>
#include <fftw3.h>

int main() {
  std::cout << fftw_version << "\n";
  return (0);
}

---
EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_TIFF_SUPPORT -isystem /usr/include/x86_64-linux-gnu /tmp/tmpI204e4.cpp -o /tmp/tmpI204e4.o
EXIT: 0
>>

EXEC <<
CMD: g++ /tmp/tmpI204e4.o -Wl,--sort-common,--as-needed -pthread -lz -ltiff -lfftw3 -o a.out
EXIT: 0
>>

EXEC <<
CMD: ./a.out
EXIT: 0
STDOUT:
fftw-3.3.4-sse2-avx
>>


REPORT: fftw-3.3.4-sse2-avx

REPORT: Checking for Qt moc:
EXEC <<
CMD: moc -v
EXIT: 0
STDOUT:
moc 5.8.0
>>


REPORT: moc (version 5.8.0)

REPORT: Checking for Qt qmake:
EXEC <<
CMD: qmake -v
EXIT: 0
STDOUT:
QMake version 3.1
Using Qt version 5.8.0 in /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib
>>


REPORT: qmake (version 5.8.0)

REPORT: Checking for Qt rcc:
EXEC <<
CMD: rcc -v
EXIT: 0
STDOUT:
rcc 5.8.0
>>


REPORT: rcc (version 5.8.0)

REPORT: Checking for Qt:

source file "qt.h":
---
#include <QObject>

class Foo: public QObject {
  Q_OBJECT;
  public:
    Foo();
    ~Foo();
  public slots:
    void setValue(int value);
  signals:
    void valueChanged (int newValue);
  private:
    int value_;
};
---

source file "qt.cpp":
---
#include <iostream>
#include "qt.h"

Foo::Foo() : value_ (42) { connect (this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); }

Foo::~Foo() { std::cout << qVersion() << "\n"; }

void Foo::setValue (int value) { value_ = value; }

int main() { Foo f; }
---

project file "qt.pro":
---
CONFIG += c++11
QT += core gui opengl svg
HEADERS += qt.h
SOURCES += qt.cpp
---
EXEC <<
CMD: qmake
EXIT: 0
STDOUT:
Info: creating stash file /tmp/tmpPvRRqS/.qmake.stash
>>

EXEC <<
CMD: moc qt.h -o qt_moc.cpp
EXIT: 0
>>

EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_TIFF_SUPPORT -isystem /usr/include/x86_64-linux-gnu -DEIGEN_FFTW_DEFAULT -pipe -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtOpenGL -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtSvg -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtWidgets -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtGui -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtCore -isystem /usr/include/libdrm -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/mkspecs/linux-g++ qt.cpp -o qt.o
EXIT: 0
>>

EXEC <<
CMD: g++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -pthread -fPIC -DMRTRIX_WORD64 -DMRTRIX_TIFF_SUPPORT -isystem /usr/include/x86_64-linux-gnu -DEIGEN_FFTW_DEFAULT -pipe -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtOpenGL -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtSvg -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtWidgets -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtGui -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/include/QtCore -isystem /usr/include/libdrm -isystem /work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/mkspecs/linux-g++ qt_moc.cpp -o qt_moc.o
EXIT: 0
>>

EXEC <<
CMD: g++ -Wl,--sort-common,--as-needed -pthread -lz -ltiff -lfftw3 qt_moc.o qt.o -o qt -Wl,-O1 -Wl,-rpath,/work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib -lQt5OpenGL -L/work/modules/Ubuntu/16.04/amd64/common/qt/5.8.0/5.8/gcc_64/lib -lQt5Svg -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
EXIT: 0
>>

EXEC <<
CMD: /tmp/tmpPvRRqS/qt
EXIT: 0
STDOUT:
5.8.0
>>


REPORT: 5.8.0
mrview -debug
mrview: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrview: [DEBUG] No config file found at "/u/72/tjroine/unix/.mrtrix.conf"
mrview: [INFO] GL renderer:  Quadro K2200/PCIe/SSE2
mrview: [INFO] GL version:   3.3.0 NVIDIA 384.130
mrview: [INFO] GL vendor:    NVIDIA Corporation
mrview: [DEBUG] loading font into OpenGL texture...
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec2 pos;
layout(location = 1) in vec2 font_pos;
uniform float scale_x;
uniform float scale_y;
out vec2 tex_coord;
void main () {
  gl_Position = vec4 (pos[0]*scale_x-1.0, pos[1]*scale_y-1.0, 0.0, 1.0);
  tex_coord = font_pos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in vec2 tex_coord;
uniform sampler2D sampler;
uniform float red, green, blue;
out vec4 color;
void main () {
  color.ra = texture (sampler, tex_coord).rg;
  color.rgb = color.r * vec3 (red, green, blue);
}

mrview: [DEBUG] font loaded

(mrview:262049): Gtk-WARNING **: Invalid input string

(mrview:262049): Gtk-WARNING **: Invalid input string
mrview: [INFO] opening image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz"...
mrview: [DEBUG] transforms_match: FOV difference in scanner coordinates: 2.0854681425767421
mrview: [WARNING] qform and sform are inconsistent in NIfTI image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" - using qform
mrview: [DEBUG] sanitising image information...
mrview: [INFO] Axes and transform of image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" altered to approximate RAS coordinate system
mrview: [DEBUG] searching for suitable phase encoding data...
mrview: [INFO] image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" opened with dimensions 165x242x160, voxel spacing 1.0104923248291016x1.0245541334152222x1.0062757730484009, datatype Float32LE
mrview: [DEBUG] loading image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz"...
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz"
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" [done]
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" loaded
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/anat_masked_crop.nii.gz" initialised with strides = [ -1 165 39930 ], start = 164, using indirect IO
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
  gl_Position = vec4 (data.x*scale_x-1.0, data.y*scale_y-1.0, 0.0, 1.0);
  amplitude = data.z;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3(1.0, 1.0, 0.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [INFO] opening image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz"...
mrview: [DEBUG] transforms_match: FOV difference in scanner coordinates: 2.1091758115057311
mrview: [WARNING] qform and sform are inconsistent in NIfTI image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" - using qform
mrview: [DEBUG] sanitising image information...
mrview: [INFO] Axes and transform of image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" altered to approximate RAS coordinate system
mrview: [DEBUG] searching for suitable phase encoding data...
mrview: [INFO] image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" opened with dimensions 334x496x323x3, voxel spacing 0.5x0.5x0.5xnan, datatype Float32LE
mrview: [DEBUG] loading image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz"...
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz"
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" [done]
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" loaded
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/tckmap_ifod2_10M_gmwmi_act_0.5mm_dec.nii.gz" initialised with strides = [ -1 334 165664 53509472 ], start = 333, using indirect IO
mrview: [INFO] mrview: loading image data
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = length (color.rgb);
  if (isnan(amplitude) || isinf(amplitude)) discard;
  if (amplitude < alpha_offset) discard;
  color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
color.rgb = scale * (abs(color.rgb) - offset);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [INFO] mrview: loading image data
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 vertpos;
uniform mat4 M;
out vec3 texcoord;
uniform mat4 overlay_M0;
out vec3 overlay_texcoord0;
void main () {
  texcoord = vertpos;
  gl_Position =  M * vec4 (vertpos,1);
  overlay_texcoord0 = (overlay_M0 * vec4 (vertpos,1)).xyz;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D image_sampler;
in vec3 texcoord;
uniform float overlay0_offset;
uniform float overlay0_scale;
uniform float overlay0_alpha_scale;
uniform float overlay0_alpha_offset;
uniform float overlay0_alpha;
uniform sampler3D overlay_sampler0;
uniform vec3 overlay_ray0;
uniform vec3 overlay0_colourmap_colours;
in vec3 overlay_texcoord0;
uniform sampler2D depth_sampler;
uniform mat4 M;
uniform float ray_z, selection_thickness;
uniform vec3 ray;
out vec4 final_color;
void main () {
  float amplitude;
  vec4 color;
  final_color = vec4 (0.0);
  float dither = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
  vec3 coord = texcoord + ray * dither;
  vec3 overlay_coord0 = overlay_texcoord0 + overlay_ray0 * dither;
  float depth = texelFetch (depth_sampler, ivec2(gl_FragCoord.xy), 0).r;
  float current_depth = gl_FragCoord.z + ray_z * dither;
  int nmax = 10000;
  if (ray.x < 0.0) nmax = int (-texcoord.s/ray.x);
  else if (ray.x > 0.0) nmax = int ((1.0-texcoord.s) / ray.x);
  if (ray.y < 0.0) nmax = min (nmax, int (-texcoord.t/ray.y));
  else if (ray.y > 0.0) nmax = min (nmax, int ((1.0-texcoord.t) / ray.y));
  if (ray.z < 0.0) nmax = min (nmax, int (-texcoord.p/ray.z));
  else if (ray.z > 0.0) nmax = min (nmax, int ((1.0-texcoord.p) / ray.z));
  nmax = min (nmax, int ((depth - current_depth) / ray_z));
  if (nmax <= 0) return;
  for (int n = 0; n < nmax; ++n) {
    coord += ray;
      color = texture (image_sampler, coord);
      amplitude = color.r;
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= alpha_offset) {
        color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
        amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
        color.rgb = vec3 (amplitude);
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    overlay_coord0 += overlay_ray0;
    if (overlay_coord0.s >= 0.0 && overlay_coord0.s <= 1.0 &&
        overlay_coord0.t >= 0.0 && overlay_coord0.t <= 1.0 &&
        overlay_coord0.p >= 0.0 && overlay_coord0.p <= 1.0) {
      color = texture (overlay_sampler0, overlay_coord0);
      amplitude = length (color.rgb);
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= overlay0_alpha_offset) {
        color.rgb = overlay0_scale * (abs(color.rgb) - overlay0_offset);
        color.a = amplitude * overlay0_alpha;
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    }
    if (final_color.a > 0.95) break;
  }
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 vertpos;
uniform mat4 M;
out vec3 texcoord;
uniform mat4 overlay_M0;
out vec3 overlay_texcoord0;
void main () {
  texcoord = vertpos;
  gl_Position =  M * vec4 (vertpos,1);
  overlay_texcoord0 = (overlay_M0 * vec4 (vertpos,1)).xyz;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D image_sampler;
in vec3 texcoord;
uniform float overlay0_offset;
uniform float overlay0_scale;
uniform float overlay0_alpha_scale;
uniform float overlay0_alpha_offset;
uniform float overlay0_alpha;
uniform sampler3D overlay_sampler0;
uniform vec3 overlay_ray0;
uniform vec3 overlay0_colourmap_colours;
in vec3 overlay_texcoord0;
uniform sampler2D depth_sampler;
uniform mat4 M;
uniform float ray_z, selection_thickness;
uniform vec3 ray;
out vec4 final_color;
void main () {
  float amplitude;
  vec4 color;
  final_color = vec4 (0.0);
  float dither = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
  vec3 coord = texcoord + ray * dither;
  vec3 overlay_coord0 = overlay_texcoord0 + overlay_ray0 * dither;
  float depth = texelFetch (depth_sampler, ivec2(gl_FragCoord.xy), 0).r;
  float current_depth = gl_FragCoord.z + ray_z * dither;
  int nmax = 10000;
  if (ray.x < 0.0) nmax = int (-texcoord.s/ray.x);
  else if (ray.x > 0.0) nmax = int ((1.0-texcoord.s) / ray.x);
  if (ray.y < 0.0) nmax = min (nmax, int (-texcoord.t/ray.y));
  else if (ray.y > 0.0) nmax = min (nmax, int ((1.0-texcoord.t) / ray.y));
  if (ray.z < 0.0) nmax = min (nmax, int (-texcoord.p/ray.z));
  else if (ray.z > 0.0) nmax = min (nmax, int ((1.0-texcoord.p) / ray.z));
  nmax = min (nmax, int ((depth - current_depth) / ray_z));
  if (nmax <= 0) return;
  for (int n = 0; n < nmax; ++n) {
    coord += ray;
      color = texture (image_sampler, coord);
      amplitude = color.r;
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= alpha_offset) {
        color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
        amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
        color.rgb = vec3 (amplitude);
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    overlay_coord0 += overlay_ray0;
    if (overlay_coord0.s >= 0.0 && overlay_coord0.s <= 1.0 &&
        overlay_coord0.t >= 0.0 && overlay_coord0.t <= 1.0 &&
        overlay_coord0.p >= 0.0 && overlay_coord0.p <= 1.0) {
      color = texture (overlay_sampler0, overlay_coord0);
      amplitude = length (color.rgb);
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= overlay0_alpha_offset) {
        color.rgb = overlay0_scale * (abs(color.rgb) - overlay0_offset);
        color.a = amplitude * overlay0_alpha;
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    }
    if (final_color.a > 0.95) break;
  }
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 vertpos;
uniform mat4 M;
out vec3 texcoord;
uniform mat4 overlay_M0;
out vec3 overlay_texcoord0;
void main () {
  texcoord = vertpos;
  gl_Position =  M * vec4 (vertpos,1);
  overlay_texcoord0 = (overlay_M0 * vec4 (vertpos,1)).xyz;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D image_sampler;
in vec3 texcoord;
uniform float overlay0_offset;
uniform float overlay0_scale;
uniform float overlay0_alpha_scale;
uniform float overlay0_alpha_offset;
uniform float overlay0_alpha;
uniform sampler3D overlay_sampler0;
uniform vec3 overlay_ray0;
uniform vec3 overlay0_colourmap_colours;
in vec3 overlay_texcoord0;
uniform sampler2D depth_sampler;
uniform mat4 M;
uniform float ray_z, selection_thickness;
uniform vec3 ray;
out vec4 final_color;
void main () {
  float amplitude;
  vec4 color;
  final_color = vec4 (0.0);
  float dither = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
  vec3 coord = texcoord + ray * dither;
  vec3 overlay_coord0 = overlay_texcoord0 + overlay_ray0 * dither;
  float depth = texelFetch (depth_sampler, ivec2(gl_FragCoord.xy), 0).r;
  float current_depth = gl_FragCoord.z + ray_z * dither;
  int nmax = 10000;
  if (ray.x < 0.0) nmax = int (-texcoord.s/ray.x);
  else if (ray.x > 0.0) nmax = int ((1.0-texcoord.s) / ray.x);
  if (ray.y < 0.0) nmax = min (nmax, int (-texcoord.t/ray.y));
  else if (ray.y > 0.0) nmax = min (nmax, int ((1.0-texcoord.t) / ray.y));
  if (ray.z < 0.0) nmax = min (nmax, int (-texcoord.p/ray.z));
  else if (ray.z > 0.0) nmax = min (nmax, int ((1.0-texcoord.p) / ray.z));
  nmax = min (nmax, int ((depth - current_depth) / ray_z));
  if (nmax <= 0) return;
  for (int n = 0; n < nmax; ++n) {
    coord += ray;
      color = texture (image_sampler, coord);
      amplitude = color.r;
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= alpha_offset) {
        color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
        amplitude = clamp (1.0 - scale * (amplitude - offset), 0.0, 1.0);
        color.rgb = vec3 (amplitude);
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    overlay_coord0 += overlay_ray0;
    if (overlay_coord0.s >= 0.0 && overlay_coord0.s <= 1.0 &&
        overlay_coord0.t >= 0.0 && overlay_coord0.t <= 1.0 &&
        overlay_coord0.p >= 0.0 && overlay_coord0.p <= 1.0) {
      color = texture (overlay_sampler0, overlay_coord0);
      amplitude = length (color.rgb);
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= overlay0_alpha_offset) {
        color.rgb = overlay0_scale * (abs(color.rgb) - overlay0_offset);
        color.a = amplitude * overlay0_alpha;
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    }
    if (final_color.a > 0.95) break;
  }
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 vertpos;
uniform mat4 M;
out vec3 texcoord;
uniform mat4 overlay_M0;
out vec3 overlay_texcoord0;
void main () {
  texcoord = vertpos;
  gl_Position =  M * vec4 (vertpos,1);
  overlay_texcoord0 = (overlay_M0 * vec4 (vertpos,1)).xyz;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D image_sampler;
in vec3 texcoord;
uniform float overlay0_offset;
uniform float overlay0_scale;
uniform float overlay0_alpha_scale;
uniform float overlay0_alpha_offset;
uniform float overlay0_alpha;
uniform sampler3D overlay_sampler0;
uniform vec3 overlay_ray0;
uniform vec3 overlay0_colourmap_colours;
in vec3 overlay_texcoord0;
uniform sampler2D depth_sampler;
uniform mat4 M;
uniform float ray_z, selection_thickness;
uniform vec3 ray;
out vec4 final_color;
void main () {
  float amplitude;
  vec4 color;
  final_color = vec4 (0.0);
  float dither = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
  vec3 coord = texcoord + ray * dither;
  vec3 overlay_coord0 = overlay_texcoord0 + overlay_ray0 * dither;
  float depth = texelFetch (depth_sampler, ivec2(gl_FragCoord.xy), 0).r;
  float current_depth = gl_FragCoord.z + ray_z * dither;
  int nmax = 10000;
  if (ray.x < 0.0) nmax = int (-texcoord.s/ray.x);
  else if (ray.x > 0.0) nmax = int ((1.0-texcoord.s) / ray.x);
  if (ray.y < 0.0) nmax = min (nmax, int (-texcoord.t/ray.y));
  else if (ray.y > 0.0) nmax = min (nmax, int ((1.0-texcoord.t) / ray.y));
  if (ray.z < 0.0) nmax = min (nmax, int (-texcoord.p/ray.z));
  else if (ray.z > 0.0) nmax = min (nmax, int ((1.0-texcoord.p) / ray.z));
  nmax = min (nmax, int ((depth - current_depth) / ray_z));
  if (nmax <= 0) return;
  for (int n = 0; n < nmax; ++n) {
    coord += ray;
      color = texture (image_sampler, coord);
      amplitude = color.r;
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= alpha_offset) {
        color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
        amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
        color.rgb = vec3 (amplitude);
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    overlay_coord0 += overlay_ray0;
    if (overlay_coord0.s >= 0.0 && overlay_coord0.s <= 1.0 &&
        overlay_coord0.t >= 0.0 && overlay_coord0.t <= 1.0 &&
        overlay_coord0.p >= 0.0 && overlay_coord0.p <= 1.0) {
      color = texture (overlay_sampler0, overlay_coord0);
      amplitude = length (color.rgb);
      if (!isnan(amplitude) && !isinf(amplitude) && amplitude >= overlay0_alpha_offset) {
        color.rgb = overlay0_scale * (abs(color.rgb) - overlay0_offset);
        color.a = amplitude * overlay0_alpha;
        final_color.rgb += (1.0 - final_color.a) * color.rgb * color.a;
        final_color.a += color.a;
      }
    }
    if (final_color.a > 0.95) break;
  }
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [INFO] opening image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz"...
mrview: [DEBUG] transforms_match: FOV difference in scanner coordinates: 2.0854681425767421
mrview: [WARNING] qform and sform are inconsistent in NIfTI image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" - using qform
mrview: [DEBUG] sanitising image information...
mrview: [INFO] Axes and transform of image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" altered to approximate RAS coordinate system
mrview: [DEBUG] searching for suitable phase encoding data...
mrview: [INFO] image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" opened with dimensions 165x242x160, voxel spacing 1.0104923248291016x1.0245541334152222x1.0062757730484009, datatype Float32LE
mrview: [DEBUG] loading image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz"...
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz"
mrview: [INFO] mrview: uncompressing image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" [done]
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" loaded
mrview: [DEBUG] image "/m/nbe/work/tjroine/tbi/default_labels_crop.nii.gz" initialised with strides = [ -1 165 39930 ], start = 164, using indirect IO
mrview: [INFO] mrview: loading image data
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  if (amplitude < alpha_offset) discard;
  color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
  gl_Position = vec4 (data.x*scale_x-1.0, data.y*scale_y-1.0, 0.0, 1.0);
  amplitude = data.z;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
  color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3(1.0, 1.0, 0.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3 (0.1);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}


(mrview:262049): Gtk-WARNING **: Invalid input string

(mrview:262049): Gtk-WARNING **: Invalid input string

mrview: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

Hi,

Same seems to happen also on my Windows machine (MSYS2 build) with the same mrtrix3 version and the same data. Might be related to the sform/qform inconsistencies?

Cheers,
Timo

Segfaults are an absolute nightmare to fix remotely; even with the logs provided, I really have no indication of where to even start looking in the code.

If you’re able to recreate the fault while following the advanced debugging instructions, particularly providing the backtrace once the segfault occurs, that would help immensely.

Otherwise, if you have a particular set of data that reliably reproduces the fault on multiple systems, you can send me those data directly.

Hi Rob,

The mrview GUI doesn’t show when using the gdb command. Is there a way to use gdb with mrview or just the command line commands?

While running the debug version without gdb, it doesn’t seem to crash but captures this error while rotating/zooming the image.

**mrview: [ERROR] [src/gui/opengl/font.cpp: 215] OpenGL error: operation not allowed given current state
mrview: [ERROR] [src/gui/opengl/font.cpp: 215] OpenGL error: operation not allowed given current state
mrview: [ERROR] [src/gui/opengl/font.cpp: 215] OpenGL error: operation not allowed given current state
**

Does this help? I will use the debug build for now, as it seems to work well enough :wink:

Cheers,
Timo

OK, this looks like an OpenGL bug on our side. I’ll see if I can reproduce and investigate…

@tjroine: can you confirm whether your MSYS2 install is also using Qt5? Mine is using Qt4 and I can’t get it to crash… I’ll try with Qt5 now just in case.

Also: does this happen when you’re rendering something heavy, or even with a single image? It might be related to subtle timing issues between GL updates and event handling.

Hi Donald,

Thanks! Yes, I have also Qt5 (5.12.1) on MSYS. The crash happens often when rendering the connectome visualizations, when e.g. changing the view or zooming, so yes I believe it’s quite heavy (but not millions of streamlines heavy).

Cheers,
Timo

Ok, that’s good to know. Given the warning you showed, the error would have occurred just before the font render call, which IIRC happens after all tools have done their rendering. So the most likely problem is that one of the tools left the OpenGL stack in an unexpected state. It would really help to narrow down a sequenced of actions that lead to that warning (it’ll only be shown in debug or assert builds, BTW).

Hi,

For some reason, I can’t reproduce the error through rotation/zoom operations, maybe a reboot/bios update performed yesterday on my Ubuntu computer helped. With the Windows machine, I can’t reproduce it either. It also had a forced Windows update last night, so maybe it is related to those updates or to the use of the university network file storage system (which is the only thing common on the two machines). I’ll let you know if I manage to reproduce it again.

However, the debug version seems to crash every time I change the LOD in the connectome-tab. I don’t know whether this is related to the previous problem though or a different one…

‘mrview: [WARNING] qform and sform are inconsistent in NIfTI image “/data/tbi/anat_masked_crop.nii.gz” - using qform
mrview: src/gui/opengl/gl.h:79: void MR::GUI::GL::CheckContext::check_context() const: Assertion `__context == QOpenGLContext::currentContext()’ failed.
Aborted

Yes, bugs have an irritating habit of only manifesting when you don’t want them to… In any case, a failed assertion is definitely something to look into, and could very well be related to the other warnings. I’ll have a look when I have a minute…

I’ve been trying to reproduce the issues you’ve raised here, and nothing I’m doing is raising any issues… I’m running a debug / assert build under valgrind, which is excruciatingly slow, but should pick up just about any issue… I’m running a similar setup to yours (Arch Linux 64 bit):

mrview: [INFO] GL renderer:  GeForce GTX 780/PCIe/SSE2
mrview: [INFO] GL version:   3.3.0 NVIDIA 418.43
mrview: [INFO] GL vendor:    NVIDIA Corporation

and pretty much the same version:

$ mrview --version
== mrview 3.0_RC3-137-g5d6b3a6f-dirty ==
64 bit debug version with asserts, nooptim, built Mar 21 2019, using Eigen 3.3.7

Can you pinpoint a particular sequence of events that gives rise to the problem? I need some way to reproduce this issue…

Hi,

Unfortunately, I haven’t been able to reproduce this error. The sequence was pretty much just adding a t1, nodes, edges, and doing some rotations/zooms. I believe this was related to I/O of the university network storage and/or RAM issues with the computer, as now everything seems to run smoothly after some updates (e.g. BIOS update and RAM upgrade).

The error with the debug version still persists and the sequence is simply changing the LOD of the nodes and/or edges in the connectome visualization tool. (load t1, load nodes, change LOD up/down).

Cheers,
Timo