Skip to content
Snippets Groups Projects
Commit 270f7f8e authored by Matthew Webster's avatar Matthew Webster
Browse files

MNT: Use python re rather than sed

parent 3fa7cdca
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import glob
import nibabel as nb
import numpy as np
import hashlib
import re
import shutil
def run(cmd):
......@@ -34,12 +35,13 @@ newFeatDir = op.join(outDir, op.basename(origFeatDir))
cmd = "./cleanFSF.py {0} {1} {2} {3} {4} {5}".format(
origFSF, newFSF, origDataDir, dataDir, outDir, origFSLDir)
run(cmd)
cmd = """sed -ie 's|set feat_files(1).*|set feat_files(1) "{0}"|g' {1}""".format(newFeatDir,newFSF)
print(cmd)
run(cmd)
#The output FEAT directory will be the copied input, so update fsf
text = open(newFSF, 'rt').read()
text = re.sub('set feat_files\(1\).*', f'set feat_files(1) "{newFeatDir}"', text)
open(newFSF, 'wt').write(text)
# run FEAT
shutil.copytree(origFeatDir,newFeatDir)
run("chmod -R a+w {0}".format(newFeatDir))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment