def test_neo(self):
     tester = HrlNeuralAnalysisNEO(
         neo.io.PlexonIO(filename='../../test/data/NEO/File_plexon_3.plx'))
     tester.buildDataStructures()
     spikes = tester.getSpikeTimes()
     data = libHrlAnalysisData.AnalysisData()
     data.fillRasterData('../../test/data/NEO/neo_plexon.dat')
     self.assertTrue(data.compareRasterDataDim(spikes.time, 1))
     self.assertTrue(data.compareRasterDataDim(spikes.spikes, 2))
    def test_getCOV(self):
        fileNames = libHrlAnalysis.vector_string()
        fileNames.append('../../test/data/CA1/spikes_0001.bin')
        fileNames.append('../../test/data/CA1/spikes_0002.bin')

        analysis = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 4000, 26200, 28199, fileNames)
        covInfo = analysis.getCOV()

        data = libHrlAnalysisData.AnalysisData()
        self.assertTrue(data.fillCOV('../../test/data/CA1/CA1_cov.dat'))
        self.assertTrue(data.compareCOV(covInfo.cov))
    def test_GetWindowRates(self):
        fileNames = libHrlAnalysis.vector_string()
        fileNames.append('../../test/data/CA1/spikes_0001.bin')
        fileNames.append('../../test/data/CA1/spikes_0002.bin')

        analysis = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 4000, 26200, 28199, fileNames)
        rates = analysis.getWindowRate(10, 10)

        data = libHrlAnalysisData.AnalysisData()
        self.assertTrue(
            data.fillWindowRates('../../test/data/CA1/CA1_window_rates.dat'))

        self.assertTrue(data.compareWindowRates_double(rates.rates))
    def test_getRasterResult(self):
        fileNames = libHrlAnalysis.vector_string()
        fileNames.append('../../test/data/CA1/spikes_0001.bin')
        fileNames.append('../../test/data/CA1/spikes_0002.bin')

        analysis = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 4000, 26200, 28199, fileNames)
        spikes = analysis.getSpikeTimes()

        data = libHrlAnalysisData.AnalysisData()
        data.fillRasterData('../../test/data/CA1/CA1_raster.dat')

        self.assertTrue(data.compareRasterDataDim(spikes.time, 1))
        self.assertTrue(data.compareRasterDataDim(spikes.spikes, 2))
    def test_GetRateBins(self):
        fileNames = libHrlAnalysis.vector_string()
        fileNames.append('../../test/data/CA1/spikes_0001.bin')
        fileNames.append('../../test/data/CA1/spikes_0002.bin')

        analysis = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 4000, 26200, 28199, fileNames)
        rateBinInfo = analysis.getRateBins(100)

        data = libHrlAnalysisData.AnalysisData()
        self.assertTrue(
            data.fillSpikeBins('../../test/data/CA1/CA1_spike_bins.dat'))

        self.assertTrue(data.compareSpikeBinsAt(rateBinInfo.counts, 0))
        self.assertTrue(data.compareSpikeBinsAt(rateBinInfo.counts, 1))
    def test_Voltages(self):
        fileNames = libHrlAnalysis.vector_string()
        for i in range(20):
            fileNames.append("../../test/data/VOLT/voltages_%04d.dat" %
                             (i + 1))

        data = libHrlAnalysisData.AnalysisData()
        self.assertTrue(
            data.fillVoltageData("../../test/data/VOLT/VOLT_TEST.dat"))

        analysis = libHrlAnalysis.HrlNeuralAnalysisVoltage(
            0, 2000, 0, 61, fileNames, 62, False, -49.0)

        voltageInfo = analysis.voltages()
        #print "\n\n",len(voltageInfo.voltage),"\n\n"
        self.assertTrue(data.compareVoltageData(voltageInfo.voltage, 0.0001))
    def test_serialize(self):
        fileNames = libHrlAnalysis.vector_string()
        fileNames.append('../../test/data/CA1/spikes_0001.bin')
        fileNames.append('../../test/data/CA1/spikes_0002.bin')

        analysisIn = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 4000, 26200, 28199, fileNames)
        analysisIn.buildDataStructures()
        analysisIn.save("./ser.bin")

        analysisOut = libHrlAnalysis.HrlNeuralAnalysisHRLSim(
            0, 0, 0, 0, libHrlAnalysis.vector_string())
        analysisOut.load("./ser.bin")

        spikes = analysisOut.getSpikeTimes()

        data = libHrlAnalysisData.AnalysisData()
        data.fillRasterData('../../test/data/CA1/CA1_raster.dat')

        self.assertTrue(data.compareRasterDataDim(spikes.time, 1))
        self.assertTrue(data.compareRasterDataDim(spikes.spikes, 2))