コード例 #1
0
def save_data (outdir, prefix, dataname, otype, excluding, leave, feats, labels, exclfeats, exclulabels, dmin, dmax, scale, scale_min, scale_max, lthr, uthr, thrp, absolute):

    #setting output file name
    ofname = au.feats_str()

    if leave > -1:
        ofname += '.' + au.excluded_str() + str(leave)

    if absolute:  ofname += '.' + au.abs_str()
    if lthr:      ofname += '.lthr_' + str(lthr)
    if uthr:      ofname += '.uthr_' + str(uthr)
    if thrp:      ofname += '.thrP_' + str(thrp)
    if scale:     ofname += '.' + au.scaled_str()

    if excluding:
        excl_ofname  = au.excluded_str() + '_' + ofname
        exclfilename = get_filepath (outdir, excl_ofname , otype)

    if prefix:
        ofname = prefix + '_' + ofname
        excl_ofname = prefix + '_' + excl_ofname

    filename = get_filepath (outdir, ofname, otype)

    #writing in a text file the scaling values of this training set
    if scale:
        write_scalingrange_file (outdir + os.path.sep + ofname + '.scaling_range', dmin, dmax, scale_min, scale_max)

    #saving binary file depending on output type
    if otype == 'numpybin':
        np.save (filename, feats)

        if excluding:
            np.save (exclfilename, exclfeats)

    elif otype == 'octave':
        sio.savemat (filename, {au.feats_str(): feats, au.labels_str(): labels})
        if excluding:
            exclulabels[exclulabels == 0] = -1
            sio.savemat (exclfilename, {au.feats_str(): exclfeats, au.labels_str(): exclulabels})

    elif otype == 'svmperf':
        labels[labels == 0] = -1
        ae.write_svmperf_dat(filename, dataname, feats, labels)

        if excluding:
            exclulabels[exclulabels == 0] = -1
            ae.write_svmperf_dat(exclfilename, dataname, exclfeats, exclulabels)

    elif otype == 'arff':
        featnames = np.arange(nfeats) + 1
        ae.write_arff (filename, dataname, featnames, feats, labels)

        if excluding:
            ae.write_arff (exclfilename, dataname, featnames, exclfeats, exclulabels)

    else:
        err = 'Output method not recognised!'
        au.log.error(err)
        sys.exit(-1)

    return [filename, exclfilename]
コード例 #2
0
    scale_min = args.scale_min
    scale_max = args.scale_max

    verbose = args.verbosity

    au.setup_logger(verbose)

    #checking number of files processed
    nmasks = len(masklst)
    nouts = 0
    m = 0
    for maskf in masklst:
        if not scale:
            ofname = au.features_str() + get_out_extension(otype)
        else:
            ofname = au.features_str() + '.' + au.scaled_str(
            ) + get_out_extension(otype)

        if prefixes[m]:
            ofname = prefixes[m] + '_' + ofname

        oc = len(au.find(os.listdir(outdir), ofname))
        nouts += oc
        m += 1

    if nouts >= nmasks:
        au.log.debug('Nothing to do in ' + outdir + '. All files processed.')
        return -1
    else:
        au.log.debug('Processing to output in: ' + outdir)

    #number of subjects
コード例 #3
0
    scale_min = args.scale_min
    scale_max = args.scale_max

    verbose = args.verbosity

    au.setup_logger(verbose)

    # checking number of files processed
    nmasks = len(masklst)
    nouts = 0
    m = 0
    for maskf in masklst:
        if not scale:
            ofname = au.features_str() + get_out_extension(otype)
        else:
            ofname = au.features_str() + "." + au.scaled_str() + get_out_extension(otype)

        if prefixes[m]:
            ofname = prefixes[m] + "_" + ofname

        oc = len(au.find(os.listdir(outdir), ofname))
        nouts += oc
        m += 1

    if nouts >= nmasks:
        au.log.debug("Nothing to do in " + outdir + ". All files processed.")
        return -1
    else:
        au.log.debug("Processing to output in: " + outdir)

    # number of subjects