# generate the rest of the output file # search over .con files in first layer of subdirs glob_exp = os.path.join(basedir,"*","*.con") token_ct = [] for con in glob.glob(glob_exp): parent = os.path.dirname(con) basename = os.path.split(parent)[1] # get TGs tg = os.path.join(parent,str(basename + ".ch1.TextGrid")) sync_tg = os.path.join(parent,str(basename + ".sync.TextGrid")) # get stimulus; other metadata stimfile = os.path.join(parent,"stim.txt") stim = read_stimfile(stimfile) if stim in low_set: tone = "low" else: tone = "high" # get condition ("ba"/"init"), place, aspiration (in that order in md) # replace with your own metadata as needed md = os.path.join(parent,"meta.txt") with open(md) as csvfile: meta = reader(csvfile, delimiter="\t") tbl = [row for row in meta] # a little janky but works condition = tbl[1][0] place = tbl[1][1] aspiration = tbl[1][2]
ann = input("Enter your initials: ") avi_glob_exp = os.path.join(expdir, "*", "*_slow.avi") # write header to file with open(out_file, "w") as out: out.write( '\t'.join(["acq", "stim", "before", "after", "voi", "ann", "label"]) + '\n') # loop through available _slow.avi files for av in glob.glob(avi_glob_exp): # gather metadata strings parent = os.path.dirname(av) stimfile = os.path.join(parent, "stim.txt") stim = read_stimfile(stimfile) beforefile = os.path.join(parent, "before.txt") before = read_stimfile(beforefile) afterfile = os.path.join(parent, "after.txt") after = read_stimfile(afterfile) voicefile = os.path.join(parent, "voice.txt") voice = read_stimfile(voicefile) # find the faster AVI file basename = os.path.split(parent)[1] av_fast = os.path.join(parent, str(basename + "_fast.avi")) # TODO add name to player while True: click = easygui.buttonbox( title="Now playing {}".format(basename),
break if warning == "N": sys.exit() else: copy_str = os.path.split(expdir)[1] + "_distractors" copy_dir = os.path.join(expdir, copy_str) os.mkdir(copy_dir) # TODO create the copy location # iterate over directories within expdir with a *.raw file in them rawfile_glob_exp = os.path.join(os.path.normpath(args.expdir), "*", "*.raw") for rf in glob.glob(rawfile_glob_exp): parent = os.path.dirname(rf) acq = os.path.split(parent)[1] stimfile = os.path.join(parent, "word.txt") try: stim = read_stimfile(stimfile, deaccent=True) except FileNotFoundError: print("No alignment TG in {}; skipping".format(acq)) continue if args.delete: if stim in distractor_list: shutil.rmtree(parent) else: if stim in distractor_list: copy_path = os.path.join(copy_dir, acq) shutil.copytree(parent, copy_path) shutil.rmtree(parent)
class Probe(object): def __init__(self): pass conv = None for rf in glob.glob(rawfile_glob_exp): parent = os.path.dirname(rf) basename = os.path.split(parent)[1] # use stim.txt to skip non-trials, flap.txt to skip words without flaps stimfile = os.path.join(parent, "stim.txt") stim = read_stimfile(stimfile) if stim == "bolus" or stim == "practice": continue flapfile = os.path.join(parent, "flap.txt") flap_set = read_stimfile(flapfile) if flap_set == "N": continue if conv is None: print("Making converter...") nscanlines, npoints, junk = read_echob_metadata(rf) header = Header() header.w = nscanlines # input image width header.h = npoints - junk # input image height, trimmed header.sf = 4000000 # magic number, sorry! probe = Probe()
except FileExistsError: shutil.rmtree(copy_dir) os.mkdir(copy_dir) # desired analysis set; change as required target_list = [ "EBA'", "BV", "EBVUH", "BUW", "BIY", "SHIY", "SHUH", "ESHIH", "GHUH", "KIH", "KUH", "KUW", "KIY" ] # last four for ACAL # differences among all four "elsewhere" high vowels in same frame: # no IH?? # /a/ TA', SA', FA', KA', GHA'; /i/ EFIY, BIY, SIY, KIY, ETIY; /i/ postalveolar ACHIY; # /u/ ZHUW, EFUW, BUW, TUW; /1/ EGHIH, CHIH; /0/ GHUH, NYUH; /0/ postalveolar CHUH; # /0/ labiodental PFUH, EFUH; misc. ETYI, EFYI, BYI', TYI', FYI', KYI', CHI', ETYIH, BYI, BYIH e = Exp(expdir=expdir) # from command line args e.gather() for a in e.acquisitions: stim = read_stimfile(a.abs_stim_file) parent = os.path.dirname(a.abs_stim_file) if args.delete: if stim not in target_list: shutil.rmtree(parent) else: if stim in target_list: copy_path = os.path.join(copy_dir, a.timestamp) shutil.copytree(parent, copy_path)