for w in range(2, len(tempVar0)): # For all waveforms tempVar1 = tempVar0[w][: -3] # Keep points for a single waveform tempVar2 = str.split( tempVar1, ', ') # Split waveform points whereever ", " exists wavePoints = [] # To hold float type points for q in range(len(tempVar2)): # For all waveform points wavePoints.append( float(tempVar2[q]) / 1000 ) # Convert from string to float. Then divide by 1,000 to convert from V to mV waves[w - 2] = [ b[w - 2][1], wavePoints ] # Append the timestamp indexing and all waveforms for neuron waves.sort() for q in range(len(waves)): waves[q] = waves[q][1] try: doc.CreateWaveformVariable(waveName, 40000, spkTimes, waves) # Create waveform variable except: continue nexName = "%s.nex" % fileName # Create neueroexoporer file name print(nexName) nex.SaveDocumentAs(doc, nexName) # Save Nex file ndoc = nex.GetActiveDocument() # Select Nex file nex.CloseDocument(ndoc) # Close Nex file print("All files have been converted to nex files.")
import sys sys.path.append('C:\\ProgramData\\Nex Technologies\\NeuroExplorer 5 x64') import nex InputPl2path = "C:\\Users\\309i7\\Documents\\NeuroExplorer 5\\Data\\TestDataFile5.nex" OutputNexPath = "E:\\Panda\\TestFile.Nex5" #InputUnitspath = ".mat" doc = nex.OpenDocument(InputPl2path) #Msg("Now processing the, GetDocTitle(GetActiveDocument()), files") #run ExtractEvents.nsc to extract events and make intervals nex.RunScript("C:\\Users\\309i7\\Documents\\NeuroExplorer 5\\Scripts\\Shifting\\ExtractEvents.nsc") #open matlab engine nex.ExecuteMenuCommand("Matlab|Get Data From Matlab|Open Matlab As Engine") #load the file contain units nex.ExecuteMatlabCommand("load(E:\Panda\PandaData\ShiftingData\20181220)") #GetVarFromMatlab(doc,"Units",1) nex.SaveDocumentAs(doc, OutputNexPath) nex.CloseDocument(doc)
initial_peaks.append(timestamps4newVar[el]) if (el != 0): nex.AddTimestamp(eventVar, timestamps4newVar[el]) print newEventName # create a new column in Timestamps doc[filteredPeaks] = nex.NewEvent(doc, 0) # select a column to add timestamps nextEventVar = nex.GetVarByName(doc, filteredPeaks) # write filtered peaks into event for i in range(len(initial_peaks)): if (i == 0): filtered.append(initial_peaks[i]) else: if ((initial_peaks[i] - initial_peaks[i - 1]) > delay): filtered.append(initial_peaks[i]) nex.AddTimestamp(nextEventVar, initial_peaks[i]) print filteredPeaks print # save file in .nex format as fileName_Analyzed nex.SaveDocumentAs(doc, getNewPath(fileName)) # close the document nex.CloseDocument(doc) else: print "Could not open ", doc