示例#1
0
def execute():
    import os, sys
    from mrtrix3 import app, path, run

    lut_input_path = 'LUT.txt'
    if not os.path.exists('LUT.txt'):
        gif3_home = os.environ.get('GIFDB_HOME', '')
        if not gif3_home:
            app.error(
                'Environment variable GIFDB_HOME is not set. Please set this variable manually, or provide script with path to file GIF3ColourLUT.txt using -lut option.'
            )
        lut_input_path = os.path.join(gif_home, 'GIF3ColourLUT.txt')
        if not os.path.isfile(lut_input_path):
            app.error(
                'Could not find GIF3 lookup table file (expected location: ' +
                lut_input_path + '), and none provided using -lut')

    if app.args.sgm_amyg_hipp:
        lut_output_file_name = 'GIF32ACT_sgm_amyg_hipp.txt'
    else:
        lut_output_file_name = 'GIF32ACT.txt'
    lut_output_path = os.path.join(path.sharedDataPath(),
                                   path.scriptSubDirName(),
                                   lut_output_file_name)
    if not os.path.isfile(lut_output_path):
        app.error(
            'Could not find lookup table file for converting GIF3 parcellation output to tissues (expected location: '
            + lut_output_path + ')')

    # Initial conversion from GIF3 parcellation to five principal tissue types
    run.command('labelconvert input.mif ' + lut_input_path + ' ' +
                lut_output_path + ' indices.mif')

    # Use mrcrop to reduce file size
    if app.args.nocrop:
        image = 'indices.mif'
    else:
        image = 'indices_cropped.mif'
        run.command(
            'mrthreshold indices.mif - -abs 0.5 | mrcrop indices.mif ' +
            image + ' -mask -')

    # Convert into the 5TT format for ACT
    run.command('mrcalc ' + image + ' 1 -eq cgm.mif')
    run.command('mrcalc ' + image + ' 2 -eq sgm.mif')
    run.command('mrcalc ' + image + ' 3 -eq  wm.mif')
    run.command('mrcalc ' + image + ' 4 -eq csf.mif')
    run.command('mrcalc ' + image + ' 5 -eq path.mif')

    run.command(
        'mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - result.mif -datatype float32'
    )


# Created by Neil Oxtoby on 2018-03-02
# Modified from freesurfer.py in MRtrix3 v3.0
示例#2
0
def initialise():
  import importlib, pkgutil
  from mrtrix3 import app, path
  initlist = [ ]
  base_parser = app.Parser(description='Base parser for construction of subparsers', parents=[app.cmdline])
  subparsers = app.cmdline.add_subparsers(title='Algorithm choices', help='Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: ' + ', '.join(getList()), dest='algorithm')
  for importer, package_name, ispkg in pkgutil.iter_modules( [ _algorithmsPath() ] ):
    module = importlib.import_module('mrtrix3.' + path.scriptSubDirName() + '.' + package_name)
    module.initialise(base_parser, subparsers)
    initlist.extend(package_name)
  app.debug('Initialised algorithms: ' + str(initlist))
示例#3
0
def initialise(): #pylint: disable=unused-variable
  import importlib, pkgutil
  from mrtrix3 import app, path
  initlist = [ ]
  base_parser = app.Parser(description='Base parser for construction of subparsers', parents=[app.cmdline])
  subparsers = app.cmdline.add_subparsers(title='Algorithm choices', help='Select the algorithm to be used to complete the script operation; additional details and options become available once an algorithm is nominated. Options are: ' + ', '.join(getList()), dest='algorithm')
  for dummy_importer, package_name, dummy_ispkg in pkgutil.iter_modules( [ _algorithmsPath() ] ):
    module = importlib.import_module('mrtrix3.' + path.scriptSubDirName() + '.' + package_name)
    module.initialise(base_parser, subparsers)
    initlist.extend(package_name)
  app.debug('Initialised algorithms: ' + str(initlist))
示例#4
0
def execute():
    import os, sys
    from mrtrix3 import app, path, run

    lut_input_path = 'LUT.txt'
    if not os.path.exists('LUT.txt'):
        freesurfer_home = os.environ.get('FREESURFER_HOME', '')
        if not freesurfer_home:
            app.error(
                'Environment variable FREESURFER_HOME is not set; please run appropriate FreeSurfer configuration script, set this variable manually, or provide script with path to file FreeSurferColorLUT.txt using -lut option'
            )
        lut_input_path = os.path.join(freesurfer_home,
                                      'FreeSurferColorLUT.txt')
        if not os.path.isfile(lut_input_path):
            app.error(
                'Could not find FreeSurfer lookup table file (expected location: '
                + freesurfer_lut + '), and none provided using -lut')

    if app.args.sgm_amyg_hipp:
        lut_output_file_name = 'FreeSurfer2ACT_sgm_amyg_hipp.txt'
    else:
        lut_output_file_name = 'FreeSurfer2ACT.txt'
    lut_output_path = os.path.join(path.sharedDataPath(),
                                   path.scriptSubDirName(),
                                   lut_output_file_name)
    if not os.path.isfile(lut_output_path):
        app.error(
            'Could not find lookup table file for converting FreeSurfer parcellation output to tissues (expected location: '
            + lut_output_path + ')')

    # Initial conversion from FreeSurfer parcellation to five principal tissue types
    run.command('labelconvert input.mif ' + lut_input_path + ' ' +
                lut_output_path + ' indices.mif')

    # Use mrcrop to reduce file size
    if app.args.nocrop:
        image = 'indices.mif'
    else:
        image = 'indices_cropped.mif'
        run.command(
            'mrthreshold indices.mif - -abs 0.5 | mrcrop indices.mif ' +
            image + ' -mask -')

    # Convert into the 5TT format for ACT
    run.command('mrcalc ' + image + ' 1 -eq cgm.mif')
    run.command('mrcalc ' + image + ' 2 -eq sgm.mif')
    run.command('mrcalc ' + image + ' 3 -eq  wm.mif')
    run.command('mrcalc ' + image + ' 4 -eq csf.mif')
    run.command('mrcalc ' + image + ' 5 -eq path.mif')

    run.command(
        'mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - result.mif -datatype float32'
    )
示例#5
0
def execute(): #pylint: disable=unused-variable
  import os.path #pylint: disable=unused-variable
  from mrtrix3 import app, path, run

  lut_input_path = 'LUT.txt'
  if not os.path.exists('LUT.txt'):
    freesurfer_home = os.environ.get('FREESURFER_HOME', '')
    if not freesurfer_home:
      app.error('Environment variable FREESURFER_HOME is not set; please run appropriate FreeSurfer configuration script, set this variable manually, or provide script with path to file FreeSurferColorLUT.txt using -lut option')
    lut_input_path = os.path.join(freesurfer_home, 'FreeSurferColorLUT.txt')
    if not os.path.isfile(lut_input_path):
      app.error('Could not find FreeSurfer lookup table file (expected location: ' + lut_input_path + '), and none provided using -lut')

  if app.args.sgm_amyg_hipp:
    lut_output_file_name = 'FreeSurfer2ACT_sgm_amyg_hipp.txt'
  else:
    lut_output_file_name = 'FreeSurfer2ACT.txt'
  lut_output_path = os.path.join(path.sharedDataPath(), path.scriptSubDirName(), lut_output_file_name)
  if not os.path.isfile(lut_output_path):
    app.error('Could not find lookup table file for converting FreeSurfer parcellation output to tissues (expected location: ' + lut_output_path + ')')

  # Initial conversion from FreeSurfer parcellation to five principal tissue types
  run.command('labelconvert input.mif ' + lut_input_path + ' ' + lut_output_path + ' indices.mif')

  # Use mrcrop to reduce file size
  if app.args.nocrop:
    image = 'indices.mif'
  else:
    image = 'indices_cropped.mif'
    run.command('mrthreshold indices.mif - -abs 0.5 | mrcrop indices.mif ' + image + ' -mask -')

  # Convert into the 5TT format for ACT
  run.command('mrcalc ' + image + ' 1 -eq cgm.mif')
  run.command('mrcalc ' + image + ' 2 -eq sgm.mif')
  run.command('mrcalc ' + image + ' 3 -eq  wm.mif')
  run.command('mrcalc ' + image + ' 4 -eq csf.mif')
  run.command('mrcalc ' + image + ' 5 -eq path.mif')

  run.command('mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - result.mif -datatype float32')
示例#6
0
def _algorithmsPath():
  import os
  from mrtrix3 import path
  return os.path.join(os.path.dirname(__file__), path.scriptSubDirName())
示例#7
0
def getModule(name):
  import sys
  from mrtrix3 import path
  return sys.modules['mrtrix3.' + path.scriptSubDirName() + '.' + name]
示例#8
0
def _algorithmsPath():
    import os
    from mrtrix3 import path
    return os.path.join(os.path.dirname(__file__), path.scriptSubDirName())
示例#9
0
def getModule(name):
    import sys
    from mrtrix3 import path
    return sys.modules['mrtrix3.' + path.scriptSubDirName() + '.' + name]
示例#10
0
def getModule(name): #pylint: disable=unused-variable
  import sys
  from mrtrix3 import path
  return sys.modules['mrtrix3.' + path.scriptSubDirName() + '.' + name]