#finds the field potential variables by searching for the string "FP" #puts these into a new list, FP_variables variables = list(doc.ContinuousNames()) FP_variables = [] for x in variables: if x[:2] == 'FP': FP_variables.append(x) #variable selection #first deselects all, then adds only the variables cued by FP_variables nex.DeselectAll(doc) for i in FP_variables: x = nex.GetVarByName(doc, i) nex.Select(doc, x) #moves into the destination directory os.chdir(os.path.join(destination, newdir)) #modifies the analysis to te specified start and end times nex.ModifyTemplate(doc, template, "Select Data From (sec)", str(start)) nex.ModifyTemplate(doc, template, "Select Data To (sec)", str(end)) #ensures no other interval filters are specified nex.ModifyTemplate(doc, template, "Interval Filter", 'None') #creates a new folder for each interval #sets the analysis to for the correct interval
for i in range(n): # get a matching file name (recognizes indexes from 1) fileName = nex.GetFileName(i + 1) # open the file doc = nex.OpenDocument(fileName) # if file was opened successfully if doc > 0: print "Opened ", fileName nex.DeselectAll(doc) for n in range(len(continuousVarNames)): nex.Select(doc, doc[continuousVarNames[n]]) # calculate spectrograms nex.ApplyTemplate(doc, templateName) # we need analysis parameters values to specify times startTime = float( nex.GetTemplateParValue(templateName, 'Start (sec)')) # find new var sampling rate shift = float(nex.GetTemplateParValue(templateName, 'Shift (sec)')) samplingRate = 1.0 / shift # get numerical results column names colNames = doc.GetNumResColumnNames() # skip first column if it contains frequency values