Skip to content

Commit

Permalink
Merge pull request #1232 from MRtrix3/dev
Browse files Browse the repository at this point in the history
Tag 3.0_RC3
  • Loading branch information
jdtournier committed May 11, 2018
2 parents e27b120 + 9c2e52b commit 57e351e
Show file tree
Hide file tree
Showing 965 changed files with 17,870 additions and 11,129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build.*
/configure.log
/build.log
/core/version.cpp
/src/exec_version.cpp
/src/project_version.h
/lib/mrtrix3/_version.py
/test/src/project_version.h
Expand Down
141 changes: 122 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,133 @@
sudo: false
language: cpp
cache:
apt: true
packages: true
directories:
- $HOME/.cache/pip
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- g++-7
- clang-6.0
- zlib1g-dev
- libqt4-opengl-dev
- g++-4.8
- python3
compiler:
- clang
env:
- py=python2
- py=python3
install:
- export NUMBER_OF_PROCESSORS=4
- export PATH=`pwd`/release/bin:`pwd`/scripts:${PATH}
- export EIGEN_CFLAGS=-I`pwd`/../eigen
- (cd ..; hg clone --insecure https://bitbucket.org/eigen/eigen/; cd eigen; hg update 3.3)
- python-pip
- python3-pip
matrix:
include:
#################################################
# Run a single OSX job to test compilation only #
#################################################
- os: osx
env: CFLAGS="-Werror" TRAVIS_CXX=clang++ py=python test=build
###############################################
# All subsequent tests are performed on Linux #
###############################################
#####################################################################
# Build binaries, run tests and check documentation: Clang, Python3 #
# (Note: Run this one first, since it'll be the longest job) #
#####################################################################
- os: linux
env: CFLAGS="-Werror" TRAVIS_CXX=clang++-6.0 py=python3 test=run
#######################################################################
# Build binaries (without optimisation): GCC, Python2 #
# (Also ensures both Python 2 and 3 are tested for configure & build) #
#######################################################################
- os: linux
env: CFLAGS="-Werror" TRAVIS_CXX=g++-7 py=python2 test=build
#######################################################################
# Generate documentation through Sphinx; Use both Python2 and Python3 #
#######################################################################
- os: linux
env: py=python2 test=sphinx
- os: linux
env: py=python3 test=sphinx
###########################################################
# Run the check_syntax script; only needs to be done once #
###########################################################
- os: linux
env: test=syntax
##############################################
# Run PyLint tests; both Python2 and Python3 #
##############################################
- os: linux
env: py=python2 test=pylint
- os: linux
env: py=python3 test=pylint
install:
##################################################
# OSX build requires explicit installation of QT #
##################################################
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew install qt5
brew link --force qt5
fi
#########################################
# Installation requirements for MRtrix3 #
#########################################
- export NUMBER_OF_PROCESSORS=2
- export PATH=`pwd`/bin:${PATH}
- export PYTHONPATH=`pwd`/lib:${PYTHONPATH}
- |
if [[ "${test}" == "sphinx" ]]; then
if [[ "${py}" == "python2" ]]; then
pip install urllib3[secure];
pip install --user recommonmark sphinx sphinx-rtd-theme;
else
pip3 install --user recommonmark sphinx sphinx-rtd-theme;
fi
fi
- |
if [[ "${test}" == "pylint" ]]; then
if [[ "${py}" == "python2" ]]; then
pip install --user pylint;
else
pip3 install --user pylint;
fi
fi
- |
if [[ "${test}" == "build" || "${test}" == "run" ]]; then
export EIGEN_CFLAGS=-I`pwd`/../eigen;
(cd ..; hg clone https://bitbucket.org/eigen/eigen/; cd eigen; hg update 3.3);
fi
before_script:
#######################################################################################################################
# TravisCI sets CXX based on what it thinks the compiler should be; therefore we need to set it as late as possible #
# Since this is not needed for the installation section, only for the travis.sh script, moved this to "before_script" #
#######################################################################################################################
- |
if [[ -n "${TRAVIS_CXX}" ]]; then
export CXX=${TRAVIS_CXX}
fi
script:
- ./check_memalign && $py ./configure -assert && $py ./build -nowarnings && ./run_tests

after_failure:
- cat memalign.log
- cat configure.log
- cat build.log
- cat testing.log
- ./travis.sh
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
after_failure:
- |
case "${test}" in # CLICK HERE TO FIND REPORTED ERRORS
"sphinx")
cat sphinx.log
;;
"syntax")
cat syntax.log
;;
"pylint")
cat pylint.log
;;
"build")
cat configure.log
cat build.log
;;
*)
cat configure.log
cat build.log
cat testing.log
cat gitdiff.log
esac
- sleep 10
13 changes: 7 additions & 6 deletions bin/5ttgen
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Make the corresponding MRtrix3 Python libraries available
import inspect, os, sys
lib_folder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile(inspect.currentframe()))[0], os.pardir, 'lib')))
lib_folder = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(inspect.getfile(inspect.currentframe()))), os.pardir, 'lib'))
if not os.path.isdir(lib_folder):
sys.stderr.write('Unable to locate MRtrix3 Python libraries')
sys.exit(1)
Expand Down Expand Up @@ -46,10 +46,11 @@ app.gotoTempDir()

alg.execute()

(stdout,stderr) = run.command('5ttcheck result.mif', False)
if len(stderr) and 'ERROR' in stderr:
app.warn('Generated image does not perfectly conform to 5TT format')
stderr = run.command('5ttcheck result.mif')[1]
if stderr:
app.warn('Generated image does not perfectly conform to 5TT format:')
for line in stderr:
app.warn(line)

run.command('mrconvert result.mif ' + path.fromUser(app.args.output, True) + (' -force' if app.force else ''))
run.command('mrconvert result.mif ' + path.fromUser(app.args.output, True) + (' -force' if app.forceOverwrite else ''))
app.complete()

22 changes: 11 additions & 11 deletions bin/average_response
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#!/usr/bin/env python
import sys
import string

def errorMessage (msg):
print (msg)
def errorMessage(msg):
sys.stderr.write(msg + '\n')
exit(1)

if len(sys.argv) < 3 :
print("example usage: average_response input_response1.txt input_response2.txt input_response3.txt ... output_average_response.txt")
sys.stderr.write("example usage: average_response input_response1.txt input_response2.txt input_response3.txt ... output_average_response.txt\n")
exit(1)

num_bvals = 0
num_coeff = 0
num_subjects = len(sys.argv) - 2
print ("Number of subjects: " + str(num_subjects))
sys.stdout.write("Number of subjects: " + str(num_subjects) + '\n')

for i in range(1, num_subjects + 1):
with open(sys.argv[i], 'r') as f:
Expand All @@ -23,17 +22,18 @@ for i in range(1, num_subjects + 1):
num_coeff = len(lines[0].split())
for l in lines:
if len(l.split()) != num_coeff:
errorMessage ("Error in file " + sys.argv[i] + ": multi-shell response functions must have the same number of coefficients per b-value (line)")
errorMessage("Error in file " + sys.argv[i] + ": multi-shell response functions must have the same number of coefficients per b-value (line)")
else:
if len(lines) != num_bvals:
errorMessage ("Error in file " + sys.argv[i] + ": Input files do not contain the same number of b-values")
errorMessage("Error in file " + sys.argv[i] + ": Input files do not contain the same number of b-values")
for l in lines:
if len(l.split()) != num_coeff:
errorMessage ("Error in file " + sys.argv[i] + ": multi-shell response functions must have the same number of coefficients per b-value (line)")
errorMessage("Error in file " + sys.argv[i] + ": multi-shell response functions must have the same number of coefficients per b-value (line)")

print ("Number of b-values: " + str(num_bvals))
sys.stdout.write("Number of b-values: " + str(num_bvals) + '\n')

average_response = [[0 for x in range(num_coeff)] for y in range(num_bvals)]
# Can't use multiplication operator in outer loop since it duplicates by reference rather than value
average_response = [[0] * num_coeff for _ in range(num_bvals)] #pylint: disable=unused-variable
for i in range(1, num_subjects + 1):
with open(sys.argv[i], 'r') as f:
lines = f.readlines()
Expand All @@ -44,7 +44,7 @@ for i in range(1, num_subjects + 1):

f = open(sys.argv[len(sys.argv)-1], 'w')
line_out = ''
for l in range(num_bvals):
for l in range(num_bvals):
line_out = ''
for c in range(0, num_coeff):
line_out = line_out + "{0:.5f}".format(average_response[l][c]) + ' '
Expand Down
36 changes: 16 additions & 20 deletions bin/blend
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/usr/bin/env python2
import os
import sys
import string
import math

if len(sys.argv) <= 1:
print 'A script to blend two sets of movie frames together with a desired overlap.'
print 'The input arguments are two folders containing the movie frames (eg. output from the MRview screenshot tool), and the desired number of overlapping frames.'
print 'eg: blend folder1 folder2 20 output_folder'
sys.exit(1)
sys.stderr.write('A script to blend two sets of movie frames together with a desired overlap.\n')
sys.stderr.write('The input arguments are two folders containing the movie frames (eg. output from the MRview screenshot tool), and the desired number of overlapping frames.\n')
sys.stderr.write('eg: blend folder1 folder2 20 output_folder\n')
sys.exit(1)

input_folder1 = sys.argv[1]
input_folder2 = sys.argv[2]
Expand All @@ -18,19 +16,17 @@ num_overlap = int(sys.argv[3])
output_folder = sys.argv[4]

if not os.path.exists(output_folder):
os.mkdir(output_folder)
os.mkdir(output_folder)

total_num_output_frames = len(file_list1) + len(file_list2) - num_overlap
for i in range(total_num_output_frames):
file_name = 'frame' + '%0*d' % (5, i) + '.png'
if (i <= (len(file_list1) - num_overlap)):
os.system('cp -L ' + input_folder1 + '/' + file_list1[i] + ' ' + output_folder + '/' + file_name)
if (i > (len(file_list1) - num_overlap)) and (i < (len(file_list1))):
i2 = i - (len(file_list1) - num_overlap) - 1
blend_amount = 100 * float(i2 + 1) / float(num_overlap)
os.system('convert ' + input_folder1 + '/' + file_list1[i] + ' ' + input_folder2 + '/' + file_list2[i2] + ' -alpha on -compose blend -define compose:args=' + str(blend_amount) + ' -gravity South -composite ' + output_folder + '/' + file_name)
if (i >= (len(file_list1))):
i2 = i - (len(file_list1) - num_overlap) - 1
os.system('cp -L ' + input_folder2 + '/' + file_list2[i2] + ' ' + output_folder + '/' + file_name)


file_name = 'frame' + '%0*d' % (5, i) + '.png'
if i <= (len(file_list1) - num_overlap):
os.system('cp -L ' + input_folder1 + '/' + file_list1[i] + ' ' + output_folder + '/' + file_name)
if i > (len(file_list1) - num_overlap) and i < (len(file_list1)):
i2 = i - (len(file_list1) - num_overlap) - 1
blend_amount = 100 * float(i2 + 1) / float(num_overlap)
os.system('convert ' + input_folder1 + '/' + file_list1[i] + ' ' + input_folder2 + '/' + file_list2[i2] + ' -alpha on -compose blend -define compose:args=' + str(blend_amount) + ' -gravity South -composite ' + output_folder + '/' + file_name)
if i >= (len(file_list1)):
i2 = i - (len(file_list1) - num_overlap) - 1
os.system('cp -L ' + input_folder2 + '/' + file_list2[i2] + ' ' + output_folder + '/' + file_name)
44 changes: 21 additions & 23 deletions bin/convert_bruker
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys, os.path

if len (sys.argv) != 3:
print ("usage: convert_bruker 2dseq header.mih")
sys.stderr.write("usage: convert_bruker 2dseq header.mih\n")
sys.exit (0)


Expand All @@ -12,21 +12,21 @@ if len (sys.argv) != 3:
#sys.exit (1)

if not sys.argv[2].endswith ('.mih'):
print ("expected .mih suffix as the second argument")
sys.stderr.write("expected .mih suffix as the second argument\n")
sys.exit (1)

with open (os.path.join (os.path.dirname (sys.argv[1]), 'reco')) as f:
lines = f.read().split ('##$');
lines = f.read().split ('##$')

with open (os.path.join (os.path.dirname (sys.argv[1]), '../../acqp')) as f:
lines += f.read().split ('##$');
lines += f.read().split ('##$')

with open (os.path.join (os.path.dirname (sys.argv[1]), '../../method')) as f:
lines += f.read().split ('##$');
lines += f.read().split ('##$')


for line in lines:
line = line.lower();
line = line.lower()
if line.startswith ('reco_size='):
mat_size = line.splitlines()[1].split()
print ('mat_size', mat_size)
Expand Down Expand Up @@ -62,28 +62,28 @@ with open (sys.argv[2], 'w') as f:
f.write (',' + str(mat_size[2]))
else:
try:
nslices
nslices #pylint: disable=pointless-statement
f.write (',' + str(nslices))
except:
pass

try:
nacq
nacq #pylint: disable=pointless-statement
f.write (',' + str(nacq))
except:
pass

f.write ('\nvox: ' + str(res[0]) + ',' + str(res[1]));
if len(res) > 2:
f.write (',' + str(res[2]));
f.write ('\nvox: ' + str(res[0]) + ',' + str(res[1]))
if len(res) > 2:
f.write (',' + str(res[2]))
else:
try:
slicethick
slicethick #pylint: disable=pointless-statement
f.write (',' + str(slicethick))
except:
pass
try:
nacq
nacq #pylint: disable=pointless-statement
f.write (',')
except:
pass
Expand All @@ -101,24 +101,22 @@ with open (sys.argv[2], 'w') as f:

f.write ('\nlayout: +0,+1')
try:
nslices
nslices #pylint: disable=pointless-statement
f.write (',+2')
except:
pass
try:
nacq
nacq #pylint: disable=pointless-statement
f.write (',+3')
except:
pass

f.write ('\nfile: ' + sys.argv[1] + '\n')
f.write ('\nfile: ' + sys.argv[1] + '\n')

try:
bvec
bval
for n in range (0, len (bval)):
f.write ('dw_scheme: ' + bvec[3*n] + ',' + bvec[3*n+1] + ',' + str(-float(bvec[3*n+2])) + ',' + bval[n] + '\n')
assert len(bvec) == 3*len(bval)
bvec = [ bvec[n:n+3] for n in range(0,len(bval),3) ]
for direction, value in zip(bvec, bval):
f.write ('dw_scheme: ' + direction[0] + ',' + direction[1] + ',' + str(-float(direction[2])) + ',' + value + '\n')
except:
pass


Loading

0 comments on commit 57e351e

Please sign in to comment.