def topup(imain, datain, **kwargs): """Wrapper for the ``topup`` command.""" valmap = {'verbose': wutils.SHOW_IF_TRUE} asrt.assertFileExists(datain) asrt.assertIsNifti(imain) cmd = ['topup', '--imain={}'.format(imain), '--datain={}'.format(datain)] cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs) return cmd
def concatxfm(atob, btoc, atoc): """Use ``convert_xfm`` to concatenate two affines. Note that the order of the input matrices is the opposite of the order expected by ``convert_xfm``. :arg atob: Input matrix, transforming from "A" to "B". :arg btoc: Input matrix, transforming from "B" to "C". :arg atoc: Output matrix, transforming from "A" to "C". """ asrt.assertFileExists(atob, btoc) cmd = ['convert_xfm', '-omat', atoc, '-concat', btoc, atob] return cmd
def applytopup(imain, datain, index, **kwargs): """Wrapper for the ``applytopup`` command.""" valmap = {'verbose': wutils.SHOW_IF_TRUE} asrt.assertFileExists(datain) for fn in imain.split(','): asrt.assertIsNifti(fn) cmd = [ 'applytopup', '--imain={}'.format(imain), '--inindex={}'.format(index), '--datain={}'.format(datain), ] cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs) return cmd
def eddy_cuda(imain, mask, index, acqp, bvecs, bvals, out, **kwargs): """Wrapper for the ``eddy_cuda`` command.""" valmap = { 'fep': wutils.SHOW_IF_TRUE, 'initrand': wutils.SHOW_IF_TRUE, 'repol': wutils.SHOW_IF_TRUE, 'ol_pos': wutils.SHOW_IF_TRUE, 'ol_sqr': wutils.SHOW_IF_TRUE, 'dont_sep_offs_move': wutils.SHOW_IF_TRUE, 'dont_peas': wutils.SHOW_IF_TRUE, 'data_is_shelled': wutils.SHOW_IF_TRUE, 'b0_only': wutils.SHOW_IF_TRUE, 'dont_mask_output': wutils.SHOW_IF_TRUE, 'cnr_maps': wutils.SHOW_IF_TRUE, 'residuals': wutils.SHOW_IF_TRUE, 'estimate_move_by_susceptibility': wutils.SHOW_IF_TRUE, 'verbose': wutils.SHOW_IF_TRUE, 'very_verbose': wutils.SHOW_IF_TRUE, } asrt.assertFileExists(imain, mask, index, acqp, bvecs, bvals) asrt.assertIsNifti(imain, mask) kwargs.update({ 'imain': imain, 'mask': mask, 'index': index, 'acqp': acqp, 'bvecs': bvecs, 'bvals': bvals, 'out': out }) cmd = ['eddy_cuda'] + wutils.applyArgStyle('--=', valmap=valmap, **kwargs) return cmd
def test_assertFileExists(): with tempdir.tempdir(): open('file.txt', 'wt').close() os.makedirs(op.join('path', 'to', 'some', 'dir')) open(op.join('path', 'to', 'file.txt'), 'wt').close() assertions.assertFileExists('file.txt') assertions.assertFileExists(op.join('path', 'to', 'some', 'dir')) assertions.assertFileExists(op.join('path', 'to', 'file.txt')) assertions.assertFileExists('file.txt', op.join('path')) with pytest.raises(AssertionError): assertions.assertFileExists(op.join('not', 'a', 'directory')) with pytest.raises(AssertionError): assertions.assertFileExists('notafile.txt') with pytest.raises(AssertionError): assertions.assertFileExists('file.txt', 'notafile.txt')
def test_disabled(): with assertions.disabled(): assertions.assertFileExists('NOT', 'A', 'FILE', 'NO', 'WAY') assertions.assertIsNifti('boo.txt')
def invxfm(inmat, omat): """Use ``convert_xfm`` to invert an affine.""" asrt.assertFileExists(inmat) return ['convert_xfm', '-omat', omat, '-inverse', inmat]
def func(): asrt.assertFileExists('file') return ['echo', 'hello']