def LoadConnections(self, connectionType, regionName, iteration): # loads connections (can be more then one) self.dumpFolderPath = os.path.splitext( self.databaseFilePath)[0] + "_dumpData" if connectionType != '': connectionType = "_" + connectionType try: with open( os.path.join(self.dumpFolderPath, str(regionName) + "_" + str(iteration)) + connectionType + ".dump", "rb") as f: connections = Connections.load(f.read()) except FileNotFoundError: connections = None return connections
data = [] for cell in range(connections.numCells()): for seg in connections.segmentsForCell(cell): for syn in connections.synapsesForSegment(seg): datum = connections.permanenceForSynapse(syn) data.append(datum) plt.figure("Histogram of Synapse Permanences") plt.hist(data, bins=100, range=(0, 1)) plt.axvline(connections.connectedThreshold, color='red') plt.title("Histogram of Synapse Permanences") plt.ylabel("Number of Synapses") plt.xlabel("Permanence of Synapse") if show: plt.show() if __name__ == '__main__': import argparse # Accept location of data dump from command line parser = argparse.ArgumentParser() parser.add_argument('connections_save_file') args = parser.parse_args() # Load and run the connections object. with open(args.connections_save_file, 'rb') as data_file: data = data_file.read() # TODO: Try both pickle and load, use whichever works. C = Connections.load(data) main(C)