Example #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)
Example #2
0
                'R:\\Autobots Roll Out\\%s\\JSON_Files\\%s' % (username, name),
                "r") as read_file:
            data = json.load(read_file)

        fileName = data['FileName'][:]  # Get file name
        print("Converting %s to a neuroexplorer format." % fileName)

        # Create event variables
        allEvents = data['Events']  # Get data for events
        for n in range(len(allEvents)):
            evtData = data['Events'][n]  # Get data for one event

            tempVar0 = str.split(str(evtData),
                                 '[')  # Split event data whereever "[" exists
            evtName = tempVar0[0][3:-3]  # Keep event name
            doc["Event"] = nex.NewEvent(
                doc, 0)  # Create new event with no timestamps

            tempVar1 = tempVar0[1][:-2]  # Keep only the timestamps for event
            tempVar2 = str.split(
                tempVar1, ', ')  # Split event timestamps whereever ", " exists
            for n in range(len(tempVar2)):  # For all timestamps
                evtTime = (float(tempVar2[n]))  # Convert from string to float
                nex.AddTimestamp(doc["Event"],
                                 evtTime)  # Add timestamps to event

            nex.Rename(doc, doc["Event"],
                       evtName)  # Change name of event to current event name
        print(name)

        # Create spike timestamps for each neuron
        allSpikes = data['Neurons']  # Get data for neurons
Example #3
0
        values2subtract2 = doc[continuousVarName2].ContinuousValues()

        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):