Esempio n. 1
0
def make(commit=DEFAULT_HASH):

    softdir = getSoftDir()

    if commit != 'master':
        if checkExists(get_path(commit)):
            return

    blddir = softdir / "UKFTractography-build"

    with local.cwd(softdir):
        repo = downloadGithubRepo('pnlbwh/ukftractography', commit)
    sha, date = getCommitInfo(repo)

    outbinary = get_path(sha)

    if checkExists(outbinary):
        return

    logging.info("Build code:")

    blddir.mkdir()
    with local.cwd(blddir):
        cmake(repo)
        import plumbum.cmd
        plumbum.cmd.make['-j', psutil.cpu_count(logical=False)] & FG

    binary1 = blddir / 'ukf/bin/UKFTractography'
    binary2 = blddir / 'UKFTractography-build/UKFTractography/bin/UKFTractography'  # later commits
    binary = binary1 if binary1.exists() else binary2

    outbinary.dirname.mkdir()

    binary.move(outbinary)
    # chmod('a-w', outbinary)

    with open(outbinary.dirname / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH".format(outbinary.dirname))

    symlink = get_path(date).dirname
    print("Make symlink: {} -> {}".format(symlink, get_path(sha).dirname))
    symlink.unlink()
    get_path(sha).dirname.symlink(symlink)

    blddir.delete()

    logging.info("Made '{}'".format(outbinary))
    logging.info("Made '{}'".format(get_path(date)))
Esempio n. 2
0
def make(commit=DEFAULT_HASH):

    softdir = getSoftDir()

    if commit != 'master':
        if checkExists(get_path(commit)):
            return

    blddir = softdir / "dcm2niix-build"

    with local.cwd(softdir):
        repo = downloadGithubRepo('rordenlab/dcm2niix', commit)
    sha, date = getCommitInfo(repo)

    outbinary = get_path(sha)

    if checkExists(outbinary):
        return

    logging.info("Build code:")

    blddir.mkdir()
    with local.cwd(blddir):
        cmake(repo, "-DUSE_STATIC_RUNTIME:BOOL=OFF")
        import plumbum.cmd
        plumbum.cmd.make['-j', psutil.cpu_count(logical=False)] & FG

    binary = blddir / 'bin/dcm2niix'

    outbinary.dirname.mkdir()

    binary.move(outbinary)
    # chmod('a-w', outbinary)

    with open(outbinary.dirname / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH".format(outbinary.dirname))

    symlink = get_path(date).dirname
    print("Make symlink: {} -> {}".format(symlink, get_path(sha).dirname))
    symlink.unlink()
    get_path(sha).dirname.symlink(symlink)

    blddir.delete()

    logging.info("Made '{}'".format(outbinary))
    logging.info("Made '{}'".format(get_path(date)))
Esempio n. 3
0
def installTraining(repo, commit):
    dest = getSoftDir()
    if commit == 'master':
        logging.error(
            'installing master not implemented yet for training repos, specify github hash'
        )
        import sys
        sys.exit(1)

    out = local.path(dest / repo + '-' + commit)
    if checkExists(out):
        return

    archive = downloadGithubArchive('pnlbwh/' + repo, commit)
    archive.move(out)

    with local.cwd(out):
        from plumbum.cmd import bash
        bash('./mktrainingcsv.sh', '.')
Esempio n. 4
0
def make(commit=DEFAULT_HASH):

    softdir = getSoftDir()

    blddir = softdir / "ANTs-build"

    with local.cwd(softdir):
        repo = downloadGithubRepo('ANTsX/ANTs', commit)
    sha, date = getCommitInfo(repo)

    out = get_path(sha)
    # if output binary directory already exists, then return
    if checkExists(out):
        return

    logging.info("Build code:")

    blddir.mkdir()
    with local.cwd(blddir):
        cmake(repo)
        import plumbum.cmd
        plumbum.cmd.make['-j', psutil.cpu_count(logical=False)] & FG

    # copy ANTs scripts
    cp('-a', (softdir / 'ANTs' / 'Scripts').list(),
       blddir / 'ANTS-build' / 'Examples')

    # move binary directory
    (blddir / 'ANTS-build' / 'Examples').move(out)

    # write PATH and ANTSPATH
    with open(out / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH\n".format(out))
        f.write("export ANTSPATH={}\n".format(out))

    # generate symbolink links
    symlink = get_path(date)
    print("Make symlink: {} -> {}".format(symlink, get_path(sha)))
    symlink.unlink()
    get_path(sha).symlink(symlink)

    logging.info("Made '{}'".format(out))
def make(commit=DEFAULT_HASH):
    """Downloads whitematteranalysis. Output is '$soft/whitematteranalysis-<commit>'."""
    dest = getSoftDir()

    if commit != 'master':
        out = get_path(commit)
        if checkExists(out):
            return

    with local.tempdir() as tmpdir, local.cwd(tmpdir):
        repo = downloadGithubRepo(REPO, commit)
        sha, date = getCommitInfo(repo)
        out = get_path(sha)
        if checkExists(out):
            return

        # save space
        (repo / 'tests').delete()
        (repo / '.git').delete()

        logging.info("Make '{out}'".format(**locals()))
        repo.move(out)

    # chmod('-R', 'a-w', out)
    # chmod('a-w', out)
    with open(out / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH\n".format(out / 'bin'))
        f.write("export PYTHONPATH={}:$PYTHONPATH\n".format(out))

    # compile cython files
    with local.cwd(out):
        from plumbum.cmd import python
        python['setup.py', 'build_ext', '--inplace'] & FG

    date_symlink = get_path(date)
    date_symlink.unlink()
    out.symlink(date_symlink)
Esempio n. 6
0
def make(commit=DEFAULT_HASH, delete=False):
    """Downloads and compiles BRAINSTools binaries. Output is '$soft/BRAINSTools-bin-<hash>'."""

    if os.getenv("CONDA_PREFIX"):
        # add CONDA_PREFIX paths to the compiler flags so we prefer conda's includes and libs
        conda_prefix = os.getenv("CONDA_PREFIX")
        build_flags = " -I{conda_prefix}/include -L{conda_prefix}/lib".format(conda_prefix=conda_prefix)

        cflags = os.getenv("CFLAGS") + " " + build_flags
        cxxflags = os.getenv("CXXFLAGS") + " " + build_flags
        local.env["CFLAGS"] = cflags
        local.env["CXXFLAGS"] = cxxflags
        local.env["ICU_ROOT_DIR"] = conda_prefix
        local.env["ICU_ROOT"] = conda_prefix

    dest = getSoftDir()

    if commit != 'master':
        out = dest / ('BRAINSTools-bin-'+commit)
        if checkExists(out):
            return

    blddir = dest / "BRAINSTools-build"
    with local.cwd(dest):
        repo = downloadGithubRepo('BRAINSia/BRAINSTools', commit)
    sha, date = getCommitInfo(repo)

    out = dest / ('BRAINSTools-bin-'+sha)
    symlink = dest / ('BRAINSTools-bin-'+date)
    symlink.unlink()

    log.info("Make '{}'".format(out))
    log.info("Make '{}'".format(symlink))

    if checkExists(out):
        return

    logging.info("Build code:")
    blddir.mkdir()
    with local.cwd(blddir):
        cmake(repo
        ,"-DBRAINSTools_INSTALL_DEVELOPMENT=OFF"
        ,"-DBRAINSTools_MAX_TEST_LEVEL=0"
        ,"-DBRAINSTools_SUPERBUILD=ON"
        ,"-DBRAINSTools_USE_QT=OFF"
        ,"-DBRAINS_DEBUG_IMAGE_WRITE=OFF"
        ,"-DBUILD_STYLE_UTILS=OFF"
        ,"-DBUILD_TESTING=OFF"
        ,"-DCMAKE_BUILD_TYPE=Release"
        ,"-DCMAKE_COLOR_MAKEFILE=ON"
        ,"-DCMAKE_EXE_LINKER_FLAGS=' '"
        ,"-DCMAKE_EXE_LINKER_FLAGS_DEBUG="
        ,"-DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL="
        ,"-DCMAKE_EXE_LINKER_FLAGS_RELEASE="
        ,"-DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="
        ,"-DCMAKE_EXPORT_COMPILE_COMMANDS=OFF"
        ,"-DCMAKE_INSTALL_PREFIX:PATH=/usr/local"
        ,"-DCMAKE_MODULE_LINKER_FLAGS=' '"
        ,"-DCMAKE_MODULE_LINKER_FLAGS_DEBUG="
        ,"-DCMAKE_MODULE_LINKER_FLAGS_MINSIZEREL="
        ,"-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="
        ,"-DCMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO="
        ,"-DCMAKE_PROJECT_NAME:STATIC=SuperBuild_BRAINSTools"
        ,"-DCMAKE_SHARED_LINKER_FLAGS=' '"
        ,"-DCMAKE_SHARED_LINKER_FLAGS_DEBUG="
        ,"-DCMAKE_SHARED_LINKER_FLAGS_MINSIZEREL="
        ,"-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="
        ,"-DCMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="
        ,"-DCMAKE_SKIP_INSTALL_RPATH=NO"
        ,"-DCMAKE_SKIP_RPATH=NO"
        ,"-DCMAKE_STATIC_LINKER_FLAGS="
        ,"-DCMAKE_STATIC_LINKER_FLAGS_DEBUG="
        ,"-DCMAKE_STATIC_LINKER_FLAGS_MINSIZEREL="
        ,"-DCMAKE_STATIC_LINKER_FLAGS_RELEASE="
        ,"-DCMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO="
        ,"-DCMAKE_USE_RELATIVE_PATHS=OFF"
        ,"-DCMAKE_VERBOSE_MAKEFILE=FALSE"
        ,"-DCOVERAGE_EXTRA_FLAGS=-l"
        ,"-DCTEST_SUBMIT_RETRY_COUNT=3"
        ,"-DCTEST_SUBMIT_RETRY_DELAY=5"
        ,"-DDART_TESTING_TIMEOUT=1500"
        ,"-DEXTERNAL_PROJECT_BUILD_TYPE=Release"
        ,"-DFORCE_EXTERNAL_BUILDS=OFF"
        ,"-DITK_VERSION_MAJOR=4"
        ,"-DSuperBuild_BRAINSTools_BUILD_DICOM_SUPPORT=ON"
        ,"-DSuperBuild_BRAINSTools_USE_CTKAPPLAUNCHER=OFF"
        ,"-DSuperBuild_BRAINSTools_USE_GIT_PROTOCOL=ON"
        ,"-DUSE_ANTS=ON"
        ,"-DUSE_AutoWorkup=OFF"
        ,"-DUSE_BRAINSABC=OFF"
        ,"-DUSE_BRAINSConstellationDetector=OFF"
        ,"-DUSE_BRAINSContinuousClass=OFF"
        ,"-DUSE_BRAINSCreateLabelMapFromProbabilityMaps=OFF"
        ,"-DUSE_BRAINSCut=OFF"
        ,"-DUSE_BRAINSDWICleanup=OFF"
        ,"-DUSE_BRAINSDemonWarp=OFF"
        ,"-DUSE_BRAINSFit=OFF"
        ,"-DUSE_BRAINSInitializedControlPoints=OFF"
        ,"-DUSE_BRAINSLabelStats=OFF"
        ,"-DUSE_BRAINSLandmarkInitializer=OFF"
        ,"-DUSE_BRAINSMultiModeSegment=OFF"
        ,"-DUSE_BRAINSMultiSTAPLE=OFF"
        ,"-DUSE_BRAINSMush=OFF"
        ,"-DUSE_BRAINSPosteriorToContinuousClass=OFF"
        ,"-DUSE_BRAINSROIAuto=OFF"
        ,"-DUSE_BRAINSResample=OFF"
        ,"-DUSE_BRAINSSnapShotWriter=OFF"
        ,"-DUSE_BRAINSStripRotation=OFF"
        ,"-DUSE_BRAINSSurfaceTools=OFF"
        ,"-DUSE_BRAINSTalairach=OFF"
        ,"-DUSE_BRAINSTransformConvert=OFF"
        ,"-DUSE_ConvertBetweenFileFormats=ON"
        ,"-DUSE_DWIConvert=ON"
        ,"-DUSE_DebugImageViewer=OFF"
        ,"-DUSE_GTRACT=OFF"
        ,"-DUSE_ICCDEF=OFF"
        ,"-DUSE_ImageCalculator=OFF"
        ,"-DUSE_ReferenceAtlas=OFF"
        ,"-DUSE_SYSTEM_DCMTK=OFF"
        ,"-DUSE_SYSTEM_ITK=OFF"
        ,"-DUSE_SYSTEM_SlicerExecutionModel=OFF"
        ,"-DUSE_SYSTEM_VTK=OFF"
        ,"-DVTK_GIT_REPOSITORY=git://vtk.org/VTK.git"
        )
        import plumbum.cmd
        plumbum.cmd.make['-j', psutil.cpu_count(logical=False)] & FG
    (blddir / 'bin').move(out)
    with open(blddir / 'ANTs/Scripts/antsRegistrationSyN.sh', 'r') as src:
        with open(out / 'antsRegistrationSyN.sh', 'w') as dest:
            for idx, line in enumerate(src):
                if idx == 0:
                    dest.write('#!/usr/bin/env bash')
                else:
                    dest.write(line)
    st = os.stat(str(out / 'antsRegistrationSyN.sh'))
    os.chmod(str(out / 'antsRegistrationSyN.sh'), st.st_mode | stat.S_IEXEC)
    # (blddir / 'ANTs/Scripts/antsRegistrationSyN.sh').copy(out)
    with open(out / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH\n".format(out))
        f.write("export ANTSPATH={}\n".format(out))
    # chmod('a-w', out.glob('*'))
    # chmod('a-w', out)
    symlink.unlink()
    out.symlink(symlink)
    if sys.flags.interactive:
        if input("Delete build directory? [y/N]") == "y":
            blddir.delete()
    log.info("Made '{}'".format(get_path(sha)))
    log.info("Made '{}'".format(symlink))
Esempio n. 7
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / '{}-{}'.format(NAME, hash)
Esempio n. 8
0
def get_path(hash=DEFAULT_HASH):
    return local.path(getSoftDir() / 'trainingDataT1AHCC-' + hash)
Esempio n. 9
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / ('nrrdchecker-' + hash) / 'nrrdchecker'
Esempio n. 10
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / ('mrtrix3-' + hash)
Esempio n. 11
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / ('ANTs-bin-' + hash)
Esempio n. 12
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / ('UKFTractography-' + hash) / 'UKFTractography'
Esempio n. 13
0
def make(commit=DEFAULT_HASH, delete=False):
    """Downloads and compiles BRAINSTools binaries. Output is '$soft/BRAINSTools-bin-<hash>'."""

    dest = getSoftDir()

    if commit != 'master':
        out = dest / ('BRAINSTools-bin-' + commit)
        if checkExists(out):
            return

    blddir = dest / "BRAINSTools-build"
    with local.cwd(dest):
        repo = downloadGithubRepo('BRAINSia/BRAINSTools', commit)

    for line in fileinput.input(repo / 'SuperBuild' / 'External_ITKv5.cmake',
                                inplace=True):
        print(line.replace('itk.org', 'github.com/InsightSoftwareConsortium'),
              end='')

    sha, date = getCommitInfo(repo)

    out = dest / ('BRAINSTools-bin-' + sha)
    symlink = dest / ('BRAINSTools-bin-' + date)
    symlink.unlink()

    log.info("Make '{}'".format(out))
    log.info("Make '{}'".format(symlink))

    if checkExists(out):
        return

    logging.info("Build code:")
    blddir.mkdir()
    with local.cwd(blddir):
        cmake(
            repo, "-DBRAINSTools_BUILD_DICOM_SUPPORT:BOOL=OFF",
            "-DBRAINSTools_MAX_TEST_LEVEL:STRING=0",
            "-DBRAINSTools_REQUIRES_VTK:BOOL=OFF",
            "-DBRAINSTools_USE_CTKAPPLAUNCHER:BOOL=OFF",
            "-DBUILD_TESTING:BOOL=OFF", "-DUSE_ANTS:BOOL=OFF",
            "-DUSE_AutoWorkup:BOOL=OFF", "-DUSE_BRAINSABC:BOOL=OFF",
            "-DUSE_BRAINSConstellationDetector:BOOL=OFF",
            "-DUSE_BRAINSDWICleanup:BOOL=OFF", "-DUSE_BRAINSFit:BOOL=OFF",
            "-DUSE_BRAINSInitializedControlPoints:BOOL=OFF",
            "-DUSE_BRAINSLabelStats:BOOL=OFF",
            "-DUSE_BRAINSLandmarkInitializer:BOOL=OFF",
            "-DUSE_BRAINSROIAuto:BOOL=OFF", "-DUSE_BRAINSResample:BOOL=OFF",
            "-DUSE_BRAINSSnapShotWriter:BOOL=OFF",
            "-DUSE_BRAINSStripRotation:BOOL=OFF",
            "-DUSE_BRAINSTransformConvert:BOOL=OFF",
            "-DUSE_ImageCalculator:BOOL=OFF", "-DUSE_ReferenceAtlas:BOOL=OFF",
            "-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON", "-DCMAKE_SKIP_RPATH:BOOL=ON")

        import plumbum.cmd
        plumbum.cmd.make['-j', psutil.cpu_count(logical=False)] & FG
    (blddir / 'bin').move(out)

    with open(out / 'env.sh', 'w') as f:
        f.write("export PATH={}:$PATH\n".format(out))
    symlink.unlink()
    out.symlink(symlink)

    log.info("Made '{}'".format(get_path(sha)))
    log.info("Made '{}'".format(symlink))
Esempio n. 14
0
def get_path(hash=DEFAULT_HASH):
    return getSoftDir() / ('dcm2niix-' + hash) / 'dcm2niix'
Esempio n. 15
0
def get_path(bthash=DEFAULT_HASH):
    btpath = getSoftDir() / ('BRAINSTools-bin-' + bthash)
    return btpath
Esempio n. 16
0
def get_path(version=DEFAULT_VERSION):
    return getSoftDir() / ('HCPPipelines-' + version)
Esempio n. 17
0
def getDir(version=DEFAULT_VERSION):
    return getSoftDir() / ('Slicer-' + version + '-linux-amd64')