示例#1
0
parser.add_argument("-f", "--flop", help="Horizontally flip the ultrasound data", action="store_true")
parser.add_argument("-c", "--convert", help="Scan-convert the data before analysis", action="store_true")
parser.add_argument("-v", "--visualize", help="Produce plots of PC loadings on fan",action="store_true")
args = parser.parse_args()

# check for appropriate directory
try:
    expdir = args.directory
except IndexError:
    print("\tDirectory provided doesn't exist")
    ArgumentParser.print_usage
    ArgumentParser.print_help
    sys.exit(2)

# assemble experiment object and do setup
e = Exp(expdir=args.directory)
e.gather()

# check for appropriate number of components
if args.num_components > (len(e.acquisitions) - 1):
    print("EXITING: Number of components requested definitely exceeds number to be produced")
    sys.exit(2)

# subset data: create boolean arrays to ID acquisitions as part of certain sets.
exp_length = len(e.acquisitions)
L_bool = np.zeros([exp_length], dtype=bool)
R_bool = np.zeros([exp_length], dtype=bool)
ER_bool = np.zeros([exp_length], dtype=bool)

for idx, st in enumerate(e.acquisitions):
    with open (st.abs_stim_file, "r") as mystim:
示例#2
0
    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)
示例#3
0
WORDS = str.split(w.read(), "\n")
tarlist = []
tarlist = ['R']

#subjects = [d for d in os.listdir(PARENTDIR) if os.path.isdir(os.path.join(PARENTDIR,d))]

# create a logfile
time = datetime.datetime.now()
ts = str(time.year * 100000000 + time.month * 1000000 + time.day * 10000 +
         time.hour * 100 + time.minute)
logfile = "./log_" + ts + ".txt"
log = open(logfile, 'wb')

expdir = os.path.join(PARENTDIR, SUB)

e = Exp(expdir=expdir)
e.gather()
for a in e.acquisitions:
    print(a)
    tp = a.timestamp
    if tp == '2015-11-17T103748-0800':
        continue
#   print(tp)
    stimfile = a.abs_stim_file
    stim = open(stimfile)
    stimtext = stim.read()
    #   outfile = a.abspath+'/'+tp+'.TextGrid'
    outfile = expdir + '/' + tp + '/' + tp + '.TextGrid'
    print(outfile)
    bprtg = expdir + '/' + tp + '/' + tp + '.bpr.sync.TextGrid'
    if not os.path.isfile(bprtg):
示例#4
0
                frmind = midfrm

                testinds = [frmind, frmind - 1,
                            frmind + 1]  # one-frame tolerance
                for t in range(0, len(testinds)):
                    thisind = testinds[t]
                    theframe = timestamp + '.' + str(thisind) + '.jpg'
                    # theframe = dirjpgs[thisind]
                    if not os.path.isfile(os.path.join(bmpdir, theframe)):
                        bmp2cp = os.path.join(
                            utildir, timestamp,
                            timestamp + '.' + str(thisind) + '.bmp')
                        if os.path.isfile(bmp2cp):
                            shutil.copy(bmp2cp, bmpdir)
                        else:
                            e = Exp(expdir=bmpdir)
                            e.gather()
                            for a in e.acquisitions:
                                print(a.timestamp)
                                # bprtg = os.path.join(bmpdir,timestamp+'.bpr.sync.TextGrid' )
                                for l in a.pulse_idx.tslice(t1=t1, t2=t2):
                                    print(l)
                                    try:
                                        d = a.frame_at(l.t1, convert=True)
                                        if d[0] is None:
                                            print('skipping ' + str(l.text))
                                            continue
                                    except ValueError:
                                        print('what is a struct.error')
                                        continue
                                    d = d[0]