示例#1
0
 def build(self):
     needDeps(self)
     with BRAINSTools.env(self.bthash):
         from pnlscripts.util.scripts import epi_py
         epi_py('--force', '--dwi', self.dwi.output(), '--dwimask',
                self.dwimask.output(), '--t2', self.t2.output(), '--t2mask',
                self.t2mask.output(), '-o', self.output())
示例#2
0
 def build(self):
     needDeps(self)
     fssubjdir = self.fs.output().dirname.dirname
     with TemporaryDirectory() as tmpdir, BRAINSTools.env(self.bthash):
         tmpoutdir = tmpdir / (self.caseid + '-fsindwi')
         dwi = tmpdir / 'dwi.nrrd'
         dwimask = tmpdir / 'dwimask.nrrd'
         fs = tmpdir / 'fs'
         t2 = tmpdir / 't2.nrrd'
         t1 = tmpdir / 't1.nrrd'
         t1mask = tmpdir / 't1mask.nrrd'
         t2mask = tmpdir / 't2mask.nrrd'
         fssubjdir.copy(fs)
         dwiconvert_py('-i', self.dwi.output(), '-o', dwi)
         convertImage(self.dwimask.output(), dwimask, self.bthash)
         convertImage(self.t2.output(), t2, self.bthash)
         convertImage(self.t1.output(), t1, self.bthash)
         convertImage(self.t2mask.output(), t2mask, self.bthash)
         convertImage(self.t1mask.output(), t1mask, self.bthash)
         script = local['pnlpipe_pipelines/pnlscripts/old/fs2dwi_T2.sh']
         script['--fsdir', fs, '--dwi', dwi, '--dwimask', dwimask, '--t2',
                t2, '--t2mask', t2mask, '--t1', t1, '--t1mask', t1mask,
                '-o', tmpoutdir] & FG
         convertImage(tmpoutdir / 'wmparc-in-bse.nrrd', self.output(),
                      self.bthash)
示例#3
0
 def static_build(self):
     fssubjdir = self.fs
     with local.tempdir() as tmpdir, BRAINSTools.env(
             self.BRAINSTools_hash):
         tmpoutdir = tmpdir / 'fsindwi'
         dwi = tmpdir / 'dwi.nrrd'
         dwimask = tmpdir / 'dwimask.nrrd'
         fs = tmpdir / 'fs'
         t2 = tmpdir / 't2.nrrd'
         t1 = tmpdir / 't1.nrrd'
         t1mask = tmpdir / 't1mask.nrrd'
         t2mask = tmpdir / 't2mask.nrrd'
         fssubjdir.copy(fs)
         dwiconvert_py('-i', self.dwi, '-o', dwi)
         convertImage(self.dwimask, dwimask, self.BRAINSTools_hash)
         convertImage(self.t2, t2, self.BRAINSTools_hash)
         convertImage(self.t1, t1, self.BRAINSTools_hash)
         convertImage(self.t2mask, t2mask, self.BRAINSTools_hash)
         convertImage(self.t1mask, t1mask, self.BRAINSTools_hash)
         script = local['pnlscripts/old/fs2dwi_T2.sh']
         script['--fsdir', fs, '--dwi', dwi, '--dwimask', dwimask, '--t2',
                t2, '--t2mask', t2mask, '--t1', t1, '--t1mask', t1mask,
                '-o', tmpoutdir] & FG
         convertImage(tmpoutdir / 'wmparc-in-bse.nrrd', self.output(),
                      self.BRAINSTools_hash)
示例#4
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash):
         slicecmd = unu["slice", "-a", "3", "-p", 0, "-i", self.dwi]
         binarizecmd = unu["3op", "ifelse", "-", 1, 0]
         gzipcmd = unu["save", "-e", "gzip", "-f", "nrrd", "-o",
                       self.output()]
         (slicecmd | binarizecmd | gzipcmd) & FG
示例#5
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash):
         epi_py('--force',
                '--dwi', self.dwi,
                '--dwimask', self.dwimask,
                '--t2', self.t2,
                '--t2mask', self.t2mask,
                '-o', self.output())
示例#6
0
文件: _pnl.py 项目: pnlbwh/pnlpipe
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), ANTs.env(self.ANTs_hash):
         epi_py('--force', '--typeCast',
                '--dwi', self.dwi,
                '--dwimask', self.dwimask,
                '--t2', self.t2,
                '--t2mask', self.t2mask,
                '-o', self.output(),
                '-n', NCPU)
示例#7
0
 def static_build(self):
     fssubjdir = self.fs
     with local.tempdir() as tmpdir, BRAINSTools.env(self.BRAINSTools_hash):
         tmpoutdir = tmpdir / 'fsindwi'
         tmpdwi = tmpdir / 'dwi.nrrd'
         tmpdwimask = tmpdir / 'dwimask.nrrd'
         dwiconvert_py('-i', self.dwi, '-o', tmpdwi)
         convertImage(self.dwimask, tmpdwimask, self.BRAINSTools_hash)
         fs2dwi_py['-f', fssubjdir, '-t', tmpdwi, '-m', tmpdwimask, '-o',
                   tmpoutdir, 'direct'] & FG
         local.path(tmpoutdir / 'wmparcInDwi1mm.nii.gz').copy(self.output())
示例#8
0
 def build(self, db):
     needDeps(self, self.deps, db)
     fssubjdir = self.fs.output().dirname.dirname
     with TemporaryDirectory() as tmpdir, BRAINSTools.env(self.bthash):
         tmpoutdir = tmpdir / (self.caseid + '-fsindwi')
         tmpdwi = tmpdir / 'dwi.nrrd'
         tmpdwimask = tmpdir / 'dwimask.nrrd'
         dwiconvert_py('-i', self.dwi.output(), '-o', tmpdwi)
         convertImage(self.dwimask.output(), tmpdwimask, self.bthash)
         fs2dwi_py['-f', fssubjdir, '-t', tmpdwi, '-m', tmpdwimask, '-o',
                   tmpoutdir, 'direct'] & FG
         local.path(tmpoutdir / 'wmparcInDwi1mm.nii.gz').copy(self.output())
示例#9
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), local.tempdir() as tmpdir:
         moving = tmpdir / 'moving.nrrd'
         movingmask = tmpdir / 'movingmask.nrrd'
         fixed = tmpdir / 'fixed.nrrd'
         out = tmpdir / 'fixedmask.nrrd'
         convertImage(self.moving, moving, self.BRAINSTools_hash)
         convertImage(self.moving_mask, movingmask, self.BRAINSTools_hash)
         convertImage(self.fixed, fixed, self.BRAINSTools_hash)
         makeRigidMask_py('-i', moving, '--labelmap', movingmask,
                          '--target', fixed, '-o', out)
         out.move(self.output())
示例#10
0
文件: _pnl.py 项目: pnlbwh/pnlpipe
 def static_build(self):
     with local.tempdir() as tmpdir, BRAINSTools.env(self.BRAINSTools_hash), ANTs.env(self.ANTs_hash):
         tmpdir = local.path(tmpdir)
         tmpt1 = tmpdir / ('t1' + ''.join(self.t1.suffixes))
         from plumbum.cmd import ConvertBetweenFileFormats
         ConvertBetweenFileFormats[self.t1, tmpt1] & FG
         trainingCsv = soft.trainingDataT1AHCC.get_path(
             self.trainingDataT1AHCC_hash) / 'trainingDataT1AHCC-hdr.csv'
         outPrefix= tmpdir / 'trainingDataT1'
         atlas_py['csv', '--fusion', 'avg', '-t', tmpt1, '-o', tmpdir / 'trainingDataT1', '-n', NCPU,
                  trainingCsv] & FG
         (tmpdir / 'trainingDataT1-mask.nrrd').copy(self.output())
示例#11
0
 def build(self, db):
     needDeps(self, self.deps, db)
     with TemporaryDirectory() as tmpdir, BRAINSTools.env(self.bthash):
         tmpdir = local.path(tmpdir)
         # antsRegistration can't handle a non-conventionally named file, so
         # we need to pass in a conventionally named one
         tmpt1 = tmpdir / ('t1' + ''.join(self.t1.output().suffixes))
         from plumbum.cmd import ConvertBetweenFileFormats
         ConvertBetweenFileFormats[self.t1.output(), tmpt1] & FG
         trainingCsv = trainingDataT1AHCC.get_path(
             self.trainingDataT1AHCC) / 'trainingDataT1AHCC-hdr.csv'
         atlas_py['csv', '--fusion', 'avg', '-t', tmpt1, '-o', tmpdir,
                  trainingCsv] & FG
         (tmpdir / 'mask.nrrd').copy(self.output())
示例#12
0
 def static_build(self):
     with local.tempdir() as tmpdir, BRAINSTools.env(self.BRAINSTools_hash):
         tmpdir = local.path(tmpdir)
         # antsRegistration can't handle a non-conventionally named file, so
         # we need to pass in a conventionally named one
         # TODO needed any more?
         tmpt1 = tmpdir / ('t1' + ''.join(self.t1.suffixes))
         from plumbum.cmd import ConvertBetweenFileFormats
         ConvertBetweenFileFormats[self.t1, tmpt1] & FG
         trainingCsv = soft.trainingDataT1AHCC.get_path(
             self.trainingDataT1AHCC_hash) / 'trainingDataT1AHCC-hdr.csv'
         atlas_py['csv', '--fusion', 'avg', '-t', tmpt1, '-o', tmpdir,
                  trainingCsv] & FG
         (tmpdir / 'mask.nrrd').copy(self.output())
示例#13
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), local.tempdir() as tmpdir:
         tmpdir = local.path(tmpdir)
         tmpdwi = tmpdir / 'dwi.nrrd'
         tmpdwimask = tmpdir / 'dwimask.nrrd'
         dwiconvert_py('-i', self.dwi, '-o', tmpdwi)
         convertImage(self.dwimask, tmpdwimask, self.BRAINSTools_hash)
         params = ['--dwiFile', tmpdwi, '--maskFile', tmpdwimask,
                   '--seedsFile', tmpdwimask, '--recordTensors', '--tracts',
                   self.output()] + list(self.ukfparams)
         ukfpath = soft.UKFTractography.get_path(self.UKFTractography_hash)
         log.info(' Found UKF at {}'.format(ukfpath))
         ukfbin = local[ukfpath]
         # ukfbin(*params)
         ukfbin.bound_command(*params) & FG
示例#14
0
 def build(self, db):
     needDeps(self, self.deps, db)
     with BRAINSTools.env(self.bthash), TemporaryDirectory() as tmpdir:
         from pnlscripts.util.scripts import makeRigidMask_py
         moving = tmpdir / 'moving.nrrd'
         movingmask = tmpdir / 'movingmask.nrrd'
         fixed = tmpdir / 'fixed.nrrd'
         out = tmpdir / 'fixedmask.nrrd'
         convertImage(self.movingStrct.output(), moving, self.bthash)
         convertImage(self.movingStrctMask.output(), movingmask,
                      self.bthash)
         convertImage(self.fixedStrct.output(), fixed, self.bthash)
         makeRigidMask_py('-i', moving, '--labelmap', movingmask,
                          '--target', fixed, '-o', out)
         out.move(self.output())
示例#15
0
 def build(self):
     needDeps(self)
     with BRAINSTools.env(self.bthash), TemporaryDirectory() as tmpdir:
         tmpdir = local.path(tmpdir)
         tmpdwi = tmpdir / 'dwi.nrrd'
         tmpdwimask = tmpdir / 'dwimask.nrrd'
         dwiconvert_py('-i', self.dwi.output(), '-o', tmpdwi)
         convertImage(self.dwimask.output(), tmpdwimask, self.bthash)
         params = [
             '--dwiFile', tmpdwi, '--maskFile', tmpdwimask, '--seedsFile',
             tmpdwimask, '--recordTensors', '--tracts',
             self.output()
         ] + defaultUkfParams
         ukfpath = UKFTractography.get_path(self.ukfhash)
         log.info(' Found UKF at {}'.format(ukfpath))
         ukfbin = local[ukfpath]
         ukfbin(*params)
示例#16
0
def convertImage(i, o, bthash):
    if i.suffixes == o.suffixes:
        i.copy(o)
    with BRAINSTools.env(bthash):
        from plumbum.cmd import ConvertBetweenFileFormats
        ConvertBetweenFileFormats(i, o)
示例#17
0
文件: _pnl.py 项目: pnlbwh/pnlpipe
 def static_build(self):
     soft.FreeSurfer.validate(self.FreeSurfer_version)
     with BRAINSTools.env(self.BRAINSTools_hash), ANTs.env(self.ANTs_hash):
         fs_py['-i', self.t1, '-m', self.t1mask, '-f', '-o', self.output()] & FG
示例#18
0
文件: _pnl.py 项目: pnlbwh/pnlpipe
 def static_build(self):
     self.output().delete()
     with soft.tract_querier.env(self.tract_querier_hash), BRAINSTools.env(self.BRAINSTools_hash):
         wmql_py['-i', self.ukf, '--fsindwi', self.fsindwi, '-o',
                 self.output(), '-n', NCPU] & FG
示例#19
0
 def build(self, db):
     needDeps(self, self.deps, db)
     with BRAINSTools.env(self.bthash):
         eddy_py['-i',
                 self.dwi.output(), '-o',
                 self.output(), '--force'] & FG
示例#20
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), \
          local.tempdir() as tmpdir:
         nrrd = tmpdir / 'strct.nrrd'
         convertImage(self.strct, nrrd, self.BRAINSTools_hash)
         alignAndCenter_py['-i', nrrd, '-o', self.output()] & FG
示例#21
0
 def build(self, db):
     needDeps(self, self.deps, db)
     with BRAINSTools.env(self.bthash), TemporaryDirectory() as tmpdir:
         tmpdwi = tmpdir / (self.caseid + '-dwi.nrrd')
         dwiconvert_py['-f', '-i', self.dwi.output(), '-o', tmpdwi] & FG
         alignAndCenter_py['-i', tmpdwi, '-o', self.output()] & FG
示例#22
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), \
          local.tempdir() as tmpdir:
         bet_py('--force', '-f', self.bet_threshold, '-i', self.dwi, '-o',
                self.output())
示例#23
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash):
         eddy_py['-i', self.dwi, '-o', self.output(), '--force'] & LOG
示例#24
0
 def static_build(self):
     with BRAINSTools.env(self.BRAINSTools_hash), local.tempdir() as tmpdir:
         inputnrrd = tmpdir / 'inputdwi.nrrd'
         dwiconvert_py['-f', '-i', self.dwi, '-o', inputnrrd] & LOG
         alignAndCenter_py['-i', inputnrrd, '-o', self.output()] & LOG
示例#25
0
 def build(self):
     needDeps(self)
     with BRAINSTools.env(self.bthash), TemporaryDirectory() as tmpdir:
         bet_py('--force', '-f', self.threshold, '-i', self.dwi.output(),
                '-o', self.output())
示例#26
0
 def build(self, db):
     needDeps(self, self.deps, db)
     with BRAINSTools.env(self.bthash), TemporaryDirectory() as tmpdir:
         nrrd = tmpdir / 'strct.nrrd'
         convertImage(self.strct.output(), nrrd, self.bthash)
         alignAndCenter_py['-i', nrrd, '-o', self.output()] & FG