예제 #1
0
def GetSteadyBlock(Num_Steady, TrialTs, first_AfterSwitch, TrialType):
    #Get steady block from pro/anti trials
    for i in range(Num_Steady):
        steady_all_ts = [ts for ts in TrialTs if ts <= first_AfterSwitch[i]]
        steady_ts = steady_all_ts[-20:]
        #get the steady timestamp from last 20 trials
        print('1st ' + TrialType + ' trial after switch: ' +
              str(first_AfterSwitch[i]))
        print(
            'the timestamps for the last 20 previous kind of trials before switch: '
            + str(steady_ts))

        #add the timestamp as event in the file with name formated as pre/anti_steady_block_num_trial
        name_steady_block = TrialType + '_steady_block_' + str(i)
        doc[name_steady_block] = nex.NewEvent(doc, 0)
        for j in steady_ts:
            temp = nex.GetVarByName(doc, name_steady_block)
            nex.AddTimestamp(temp, j)
            doc[name_steady_block + '_Trial'] = nex.MakeIntervals(
                doc[name_steady_block], 0, 1)
#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
예제 #3
0
# converted from NexScript 'C:\Users\309i7\Documents\NeuroExplorer 5\Scripts\Shifting\ExtractEvents.nsc'
from __future__ import division
import nex
import math
import sys
import json

doc = nex.GetActiveDocument()
filename = nex.GetDocTitle(doc)
print('You are extracting steady trials from this file: ' + filename)

#usually the first channel is 1st_Anti_AfterPro
#The second channel is 1st_Pro_AfterAnti
first_Anti_AfterSwitch = nex.GetVarByName(doc,
                                          '1st_Anti_AfterPro').Timestamps()
first_Pro_AfterSwitch = nex.GetVarByName(doc, '1st_Pro_AfterAnti').Timestamps()
ProTs = nex.GetVarByName(doc, 'Pro').Timestamps()
AntiTs = nex.GetVarByName(doc, 'Anti').Timestamps()

Num_Pro_Steady = len(first_Anti_AfterSwitch)
Num_Anti_Steady = len(first_Pro_AfterSwitch)
print('Steady Trials in Pro Task has ' + str(Num_Pro_Steady) + ' blocks')
print('Steady Trials in Anti Task has ' + str(Num_Anti_Steady) + ' blocks')


#This is event based on pro and anti cue.
def GetSteadyBlock(Num_Steady, TrialTs, first_AfterSwitch, TrialType):
    #Get steady block from pro/anti trials
    for i in range(Num_Steady):
        steady_all_ts = [ts for ts in TrialTs if ts <= first_AfterSwitch[i]]
        steady_ts = steady_all_ts[-20:]
예제 #4
0
        for i in range(len(values2subtract1)):
            diff = values2subtract1[i] - values2subtract2[i]
            nex.AddContValue(doc[newcontinuousVarName], timestamps4newVar[i],
                             diff)

        print newcontinuousVarName

        ####################################
        # Create Peak Event in Timestamps #
        ####################################

        # create a new column in Timestamps
        doc[newEventName] = nex.NewEvent(doc, 0)
        # select a column to add timestamps
        eventVar = nex.GetVarByName(doc, newEventName)

        # how many local sections are there
        bin_No = int(len(values2subtract1) / my_bin)
        start_i = 0
        next_i = 0
        initial_peaks = []
        filtered = []
        for i in range(bin_No):
            start_i = next_i
            next_i = start_i + my_bin
            temp_list = values2subtract1[start_i:next_i]
            loc_max = max(temp_list)
            if (loc_max > treshold):
                indexes = [
                    loc_i for loc_i, j in enumerate(temp_list) if j == loc_max