Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into mrcolour
Browse files Browse the repository at this point in the history
Conflicts:
	testing/data
	testing/tests/mrconvert
  • Loading branch information
Lestropie committed Jul 30, 2019
2 parents e24671d + b1a0b48 commit c38aa27
Show file tree
Hide file tree
Showing 308 changed files with 10,603 additions and 7,410 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ build.*
/dev/
/bin/
/tmp/
/.vscode/
.cproject
.idea
.project
Expand All @@ -43,6 +44,7 @@ build.*
*.creator.user
*.files
*.includes
*.code-workspace
/debug/
/assert/
testing.log
Expand Down
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-8
packages:
- g++-7
- clang-6.0
- g++-9
- clang-8
- zlib1g-dev
- libqt4-opengl-dev
- python3
- python-pip
- python3-pip
- python3-setuptools
matrix:
include:
#################################################
Expand All @@ -32,13 +33,13 @@ matrix:
# (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
env: CFLAGS="-Werror" TRAVIS_CXX=clang++-8 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
env: CFLAGS="-Werror" TRAVIS_CXX=g++-9 py=python2 test=build
#######################################################################
# Generate documentation through Sphinx; Use both Python2 and Python3 #
#######################################################################
Expand Down Expand Up @@ -78,9 +79,9 @@ install:
if [[ "${test}" == "sphinx" ]]; then
if [[ "${py}" == "python2" ]]; then
pip install urllib3[secure];
pip install --user recommonmark sphinx sphinx-rtd-theme;
pip install --user recommonmark sphinx sphinx-rtd-theme typing;
else
pip3 install --user recommonmark sphinx sphinx-rtd-theme;
pip3 install --user recommonmark sphinx sphinx-rtd-theme typing;
fi
fi
- |
Expand All @@ -95,7 +96,7 @@ install:
fi
- |
if [[ "${test}" == "build" || "${test}" == "run" ]]; then
export EIGEN_CFLAGS=-I`pwd`/../eigen;
export EIGEN_CFLAGS="-idirafter `pwd`/../eigen";
( cd ..; git clone https://github.com/eigenteam/eigen-git-mirror.git eigen; cd eigen; git checkout branches/3.3 )
fi
before_script:
Expand Down
67 changes: 35 additions & 32 deletions bin/5ttgen
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,50 @@
# defining the appropriate functions; 5ttgen will automatically make that algorithm available at the command-line


# Make the corresponding MRtrix3 Python libraries available
import inspect, os, sys
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)
sys.path.insert(0, lib_folder)

def usage(cmdline): #pylint: disable=unused-variable
from mrtrix3 import algorithm #pylint: disable=no-name-in-module

from mrtrix3 import algorithm, app, run
cmdline.set_author('Robert E. Smith ([email protected])')
cmdline.set_synopsis('Generate a 5TT image suitable for ACT')
cmdline.add_citation('Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. Anatomically-constrained tractography: Improved diffusion MRI streamlines tractography through effective use of anatomical information. NeuroImage, 2012, 62, 1924-1938')
cmdline.add_description('5ttgen acts as a \'master\' script for generating a five-tissue-type (5TT) segmented tissue image suitable for use in Anatomically-Constrained Tractography (ACT). A range of different algorithms are available for completing this task. When using this script, the name of the algorithm to be used must appear as the first argument on the command-line after \'5ttgen\'. The subsequent compulsory arguments and options available depend on the particular algorithm being invoked.')
cmdline.add_description('Each algorithm available also has its own help page, including necessary references; e.g. to see the help page of the \'fsl\' algorithm, type \'5ttgen fsl\'.')

app.init('Robert E. Smith ([email protected])', 'Generate a 5TT image suitable for ACT')
app.cmdline.addCitation('', 'Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. Anatomically-constrained tractography: Improved diffusion MRI streamlines tractography through effective use of anatomical information. NeuroImage, 2012, 62, 1924-1938', False)
app.cmdline.addDescription('5ttgen acts as a \'master\' script for generating a five-tissue-type (5TT) segmented tissue image suitable for use in Anatomically-Constrained Tractography (ACT). A range of different algorithms are available for completing this task. When using this script, the name of the algorithm to be used must appear as the first argument on the command-line after \'5ttgen\'. The subsequent compulsory arguments and options available depend on the particular algorithm being invoked.')
app.cmdline.addDescription('Each algorithm available also has its own help page, including necessary references; e.g. to see the help page of the \'fsl\' algorithm, type \'5ttgen fsl\'.')
common_options = cmdline.add_argument_group('Options common to all 5ttgen algorithms')
common_options.add_argument('-nocrop', action='store_true', default=False, help='Do NOT crop the resulting 5TT image to reduce its size (keep the same dimensions as the input image)')
common_options.add_argument('-sgm_amyg_hipp', action='store_true', default=False, help='Represent the amygdalae and hippocampi as sub-cortical grey matter in the 5TT image')

common_options = app.cmdline.add_argument_group('Options common to all 5ttgen algorithms')
common_options.add_argument('-nocrop', action='store_true', default=False, help='Do NOT crop the resulting 5TT image to reduce its size (keep the same dimensions as the input image)')
common_options.add_argument('-sgm_amyg_hipp', action='store_true', default=False, help='Represent the amygdalae and hippocampi as sub-cortical grey matter in the 5TT image')
# Import the command-line settings for all algorithms found in the relevant directory
algorithm.usage(cmdline)

# Import the command-line settings for all algorithms found in the relevant directory
algorithm.initialise()

app.parse()

# Find out which algorithm the user has requested
alg = algorithm.getModule(app.args.algorithm)
def execute(): #pylint: disable=unused-variable
from mrtrix3 import algorithm, app, run #pylint: disable=no-name-in-module

app.checkOutputPath(app.args.output)
alg.checkOutputPaths()
# Find out which algorithm the user has requested
alg = algorithm.get_module(app.ARGS.algorithm)

app.makeTempDir()
alg.getInputs()
app.gotoTempDir()
alg.check_output_paths()

alg.execute()
app.make_scratch_dir()
alg.get_inputs()
app.goto_scratch_dir()

stderr = run.command('5ttcheck result.mif')[1]
if '[WARNING]' in stderr:
app.warn('Generated image does not perfectly conform to 5TT format:')
for line in stderr.splitlines():
app.warn(line)
alg.execute()

app.complete()
stderr = run.command('5ttcheck result.mif').stderr
if '[WARNING]' in stderr:
app.warn('Generated image does not perfectly conform to 5TT format:')
for line in stderr.splitlines():
app.warn(line)






# Execute the script
import mrtrix3
mrtrix3.execute() #pylint: disable=no-member
51 changes: 0 additions & 51 deletions bin/average_response

This file was deleted.

38 changes: 19 additions & 19 deletions bin/blend
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ if len(sys.argv) <= 1:
sys.stderr.write('eg: blend folder1 folder2 20 output_folder\n')
sys.exit(1)

input_folder1 = sys.argv[1]
input_folder2 = sys.argv[2]
file_list1 = sorted(os.listdir(input_folder1))
file_list2 = sorted(os.listdir(input_folder2))
num_overlap = int(sys.argv[3])
output_folder = sys.argv[4]
INPUT_FOLDER_1 = sys.argv[1]
INPUT_FOLDER_2 = sys.argv[2]
FILE_LIST_1 = sorted(os.listdir(INPUT_FOLDER_1))
FILE_LIST_2 = sorted(os.listdir(INPUT_FOLDER_2))
NUM_OVERLAP = int(sys.argv[3])
OUTPUT_FOLDER = sys.argv[4]

if not os.path.exists(output_folder):
os.mkdir(output_folder)
if not os.path.exists(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):
NUM_OUTPUT_FRAMES = len(FILE_LIST_1) + len(FILE_LIST_2) - NUM_OVERLAP
for i in range(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 len(file_list1) - num_overlap < 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)
if i <= len(FILE_LIST_1) - NUM_OVERLAP:
os.system('cp -L ' + INPUT_FOLDER_1 + '/' + FILE_LIST_1[i] + ' ' + OUTPUT_FOLDER + '/' + file_name)
if len(FILE_LIST_1) - NUM_OVERLAP < i < len(FILE_LIST_1):
i2 = i - (len(FILE_LIST_1) - NUM_OVERLAP) - 1
blend_amount = 100 * float(i2 + 1) / float(NUM_OVERLAP)
os.system('convert ' + INPUT_FOLDER_1 + '/' + FILE_LIST_1[i] + ' ' + INPUT_FOLDER_2 + '/' + FILE_LIST_2[i2] + ' -alpha on -compose blend -define compose:args=' + str(blend_amount) + ' -gravity South -composite ' + OUTPUT_FOLDER + '/' + file_name)
if i >= (len(FILE_LIST_1)):
i2 = i - (len(FILE_LIST_1) - NUM_OVERLAP) - 1
os.system('cp -L ' + INPUT_FOLDER_2 + '/' + FILE_LIST_2[i2] + ' ' + OUTPUT_FOLDER + '/' + file_name)
Loading

0 comments on commit c38aa27

Please sign in to comment.