ModifyTemplate

Modifies one of the template parameters.

Syntax

ModifyTemplate(doc, templateName, paramName, newParValue)

Parameters

Parameter

Type

Description

doc

documentReference

Reference to the document.

templateName

string

The name of the template. See How To Specify Template Names for details on how to specify template name parameter

paramName

string

The name of the parameter to be modified.

newParValue

string

The new value of the parameter (as a string).

Return

None.

Examples

To set the new bin value in the PerieventHistograms template, you need to write:

Python

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "PerieventHistograms", "Bin (sec)", "0.5")

NexScript

doc = GetActiveDocument()
ModifyTemplate(doc, "PerieventHistograms", "Bin (sec)", "0.5")

Note that parameter name should be specified exactly as it is shown in the left column of the Properties Panel (e.g. not "Bin", but "Bin (sec)" as in the example above). You can select the parameter name in the left column of the Properties Panel and press Ctrl+C to copy the parameter name to the clipboard. Then, paste the name of the parameter into your script.

If you need to use a numeric value as newParValue, you need to convert it to string using str function in Python and NumToStr function in NexScript. For example, if you need to set Select Data From = doc["Start"][1]:

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "Select Data From (sec)", str(doc["Start"][1]))

ModifyTemplate can be used to specify multiple references in Perievent Histograms, Crosscorrelograms and Perievent Rasters by using +:

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "Ref. type", "Table (row)")
nex.ModifyTemplate(doc, "Peri", "Reference", "Event04+Event05+Event06")
nex.ApplyTemplate(doc, "Peri")

You can also use + to specify multiple interval filters in Perievent Histograms, Crosscorrelograms and Perievent Rasters.

In Python, you can also use JSON array notation '["Event04", "Event05", "Event06"]':

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "Reference", '["Event04", "Event05", "Event06"]')

To modify Markers parameter in Perievent Rasters template, you can use the parameter values that start with either Size:, Clear or AddMarker:.

For example, "Size:8" sets the size of all markers at 8 points. "Clear" removes all marker events. See sample code below.

"AddMarker:Event06,Triangle Down,0,0,0,0,255,0" adds new marker event Event06 with marker shape Triangle Down, border color (0,0,0) (meaning red=0,green=0,blue=0) and interior color (0,255,0) (red=0,green=255,blue=0). Color values should be numbers from 0 to 255.

Valid marker shapes are: Triangle Down, Triangle Up, Diamond, Square and Circle.

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "PRaster", "Markers", "Size:8") # specifies marker size in points (8)
nex.ModifyTemplate(doc, "PRaster", "Markers", "Clear") # removes all marker events
nex.ModifyTemplate(doc, "PRaster", "Markers", "AddMarker:Event06,Triangle Down,0,0,0,0,255,0") # adds new marker Event6
nex.ModifyTemplate(doc, "PRaster", "Markers", "AddMarker:Neuron07a,Circle,255,0,0,0,0,255") # adds new marker Neuron07a

ModifyTemplate can be used to specify graphics parameters. To change the Graph parameter, you need to add Graph| before the parameter name:

import nex
doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "Graph|Graph Style", "Histogram")
nex.ModifyTemplate(doc, "Peri", "Graph|Line color", "1")
nex.ModifyTemplate(doc, "Peri", "Graph|Fill under line", "0")

To change the Y Axis parameter, you need to add YAxis| before the parameter name:

doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "YAxis|Max Type", "Fixed")
nex.ModifyTemplate(doc, "Peri", "YAxis|Fixed Max", "50.")

To change the X Axis parameter, you need to add XAxis| before the parameter name.

doc = nex.GetActiveDocument()
nex.ModifyTemplate(doc, "Peri", "XAxis|Show numerics", "Never")