def analyzeOverlaps(activeCoincsFile, encodingsFile, dataset):
lines = activeCoincsFile.readlines()<EOL>inputs = encodingsFile.readlines()<EOL>w = len(inputs[<NUM_LIT:0>].split('<STR_LIT:U+0020>'))-<NUM_LIT:1><EOL>patterns = set([])<EOL>encodings = set([])<EOL>coincs = []    <EOL>reUsedCoincs = []<EOL>firstLine = inputs[<NUM_LIT:0>].split('<STR_LIT:U+0020>')<EOL>size = int(firstLine.pop(<NUM_LIT:0>))<EOL>spOutput = np.zeros((len(lines),<NUM_LIT>))<EOL>inputBits = np.zeros((len(lines),w))<EOL>print('<STR_LIT>', size)<EOL>print('<STR_LIT>', len(lines), '<STR_LIT:\n>')<EOL>print('<STR_LIT>', w)<EOL>count = <NUM_LIT:0><EOL>for x in range(len(lines)):<EOL><INDENT>inputSpace = []     <EOL>spBUout = [int(z) for z in lines[x].split('<STR_LIT:U+0020>')]  <EOL>spBUout.pop(<NUM_LIT:0>)         <EOL>temp = set(spBUout)<EOL>spOutput[x]=spBUout<EOL>input = [int(z) for z in inputs[x].split('<STR_LIT:U+0020>')]    <EOL>input.pop(<NUM_LIT:0>)   <EOL>tempInput = set(input)<EOL>inputBits[x]=input<EOL>for m in range(size):<EOL><INDENT>if m in tempInput:<EOL><INDENT>inputSpace.append(m)<EOL><DEDENT>else:<EOL><INDENT>inputSpace.append('<STR_LIT:|>')  <EOL><DEDENT><DEDENT>repeatedBits = tempInput.intersection(encodings)    <EOL>reUsed = temp.intersection(patterns)  <EOL>if len(reUsed)==<NUM_LIT:0>:<EOL><INDENT>coincs.append((count,temp,repeatedBits,inputSpace, tempInput))  <EOL><DEDENT>else:<EOL><INDENT>reUsedCoincs.append((count,temp,repeatedBits,inputSpace, tempInput))<EOL><DEDENT>patterns=patterns.union(temp)   <EOL>encodings = encodings.union(tempInput)<EOL>count +=<NUM_LIT:1><EOL><DEDENT>overlap = {}<EOL>overlapVal = <NUM_LIT:0><EOL>seen = []<EOL>seen = (printOverlaps(coincs, coincs, seen))<EOL>print(len(seen), '<STR_LIT>')<EOL>seen = printOverlaps(reUsedCoincs, coincs, seen)<EOL>Summ=[]<EOL>for z in coincs:<EOL><INDENT>c=<NUM_LIT:0><EOL>for y in reUsedCoincs:<EOL><INDENT>c += len(z[<NUM_LIT:1>].intersection(y[<NUM_LIT:1>]))<EOL><DEDENT>Summ.append(c)<EOL><DEDENT>print('<STR_LIT>', Summ)<EOL>for m in range(<NUM_LIT:3>):<EOL><INDENT>displayLimit = min(<NUM_LIT>, len(spOutput[m*<NUM_LIT:200>:]))<EOL>if displayLimit><NUM_LIT:0>:<EOL><INDENT>drawFile(dataset, np.zeros([len(inputBits[:(m+<NUM_LIT:1>)*displayLimit]),len(inputBits[:(m+<NUM_LIT:1>)*displayLimit])]), inputBits[:(m+<NUM_LIT:1>)*displayLimit], spOutput[:(m+<NUM_LIT:1>)*displayLimit], w, m+<NUM_LIT:1>)<EOL><DEDENT>else: <EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT><DEDENT>pyl.show()<EOL>
Mirror Image Visualization: Shows the encoding space juxtaposed against the
    coincidence space. The encoding space is the bottom-up sensory encoding and
    the coincidence space depicts the corresponding activation of coincidences in
    the SP. Hence, the mirror image visualization is a visual depiction of the
    mapping of SP cells to the input representations.

    Note:
    * The files spBUOut and sensorBUOut are assumed to be in the output format
    used for LPF experiment outputs.
    * BU outputs for some sample datasets are provided. Specify the name of the
    dataset as an option while running this script.