Home | Trees | Indices | Help |
---|
|
1 # PyVision License 2 # 3 # Copyright (c) 2006-2008 David S. Bolme 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # 1. Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # 13 # 2. Redistributions in binary form must reproduce the above copyright 14 # notice, this list of conditions and the following disclaimer in the 15 # documentation and/or other materials provided with the distribution. 16 # 17 # 3. Neither name of copyright holders nor the names of its contributors 18 # may be used to endorse or promote products derived from this software 19 # without specific prior written permission. 20 # 21 # 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 26 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 ''' 34 Created on May 10, 2011 35 36 @author: bolme 37 38 Reads in two sigsets and computes overlap statistics. 39 ''' 40 import pyvision as pv 41 import optparse 42 #import csv 43 #import os.path 44 4547 usage = "usage: %prog [options] <SIGSET_A.xml> <SIGSET_B.xml> \nReads in two sigsets and computes overlap statistics." 48 49 parser = optparse.OptionParser(usage) 50 #parser.add_option("-v", "--verbose", 51 # action="store_true", dest="verbose", 52 # help="Turn on more verbose output.") 53 (options, args) = parser.parse_args() 54 55 if len(args) not in [2]: 56 parser.error("This program requires two sigset arguments.") 57 58 return options, args59 60 61 62 if __name__ == '__main__': 63 # Parse command line arguments 64 options,args = parseOptions() 65 sigset_a = args[0] 66 sigset_b = args[1] 67 68 # Read in sigsets 69 a = pv.parseSigSet(sigset_a) 70 b = pv.parseSigSet(sigset_b) 71 72 # Compute the set of recordings and subjects in A 73 sub_a = [] 74 rec_a = [] 75 for row in a: 76 sub_id = row[0] 77 rec_id = row[1][0]['name'] 78 sub_a.append(sub_id) 79 rec_a.append(rec_id) 80 sub_a = set(sub_a) 81 rec_a = set(rec_a) 82 83 # Compute the set of recordings and subjects in B 84 sub_b = [] 85 rec_b = [] 86 for row in b: 87 sub_id = row[0] 88 rec_id = row[1][0]['name'] 89 sub_b.append(sub_id) 90 rec_b.append(rec_id) 91 sub_b = set(sub_b) 92 rec_b = set(rec_b) 93 94 95 # Print overlap statistics 96 print "Total Subjects A: ",len(sub_a) 97 print "Total Subjects B: ",len(sub_b) 98 print "Common Subjects: ",len(sub_a&sub_b) 99 print "Unique Subjects A: ",len(sub_a-sub_b) 100 print "Unique Subjects B: ",len(sub_b-sub_a) 101 print "Total Recordings A:",len(rec_a) 102 print "Total Recordings B:",len(rec_b) 103 print "Common Recordings: ",len(rec_a&rec_b) 104 print "Unique Recordings A:",len(rec_a-rec_b) 105 print "Unique Recordings B:",len(rec_b-rec_a) 106
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Apr 21 14:32:00 2015 | http://epydoc.sourceforge.net |