Starting with the custom calculation shown below, we can add a second output by dragging an Output Node from the Function Library to the canvas. The new output can be placed anywhere you like but in general, outputs should be on the right side of the canvas area.
Multiple inputs and outputs
We will now make a custom calculation with two inputs and two outputs. Using the data shown below, we add a custom calculation by left mouse clicking on one of the signals in Chart View and clicking on the add calculated signal button.
We start with a single input and output, and add an additional input and output. The signal that is the sum of the two inputs is created by dragging an Add Function Node to the canvas with the two Input Nodes as its sources. The difference between the input signals is calculated by using a Subtract Function Node with the two inputs as its sources. The Add Function Node is connected to the top output node, and the Subtract Function Node is connected to the bottom Output Node. There will now be four signals shown in the preview. We can remove some of the clutter in the preview by left mouse clicking on the eye icon in both of the input nodes.
Left mouse clicking on the "Add Calculation" button applies the calculation. The two new output signals will now be visible in Chart View. An autoscale may be required to view the signals.
Using parameters and saving calculations for reuse.
Many times, we will want to reuse Custom Channel Calculations across different recordings in a Project. LabChart Lightning allows Custom Calculations to be saved for reuse across an entire Project. Once saved, they can be used as many times as needed quickly and easily without the need to redefine them.
Calculation parameters add an extra level of flexibility to this reuse pattern by allowing saved calculations to accept inputs via Node Input Fields.
To demonstrate these two features, we’ll start with a previous example where we created a custom calculation using two outputs with differing degrees of signal smoothing.
When the value in the Parameter Node is changed, the bottom SmoothSeconds Node always uses a double of the value.
To save this calculation for reuse, left mouse click on the "Save a Copy To Function Library..." button at the bottom right of the Custom Calculation dialog. A unique name must be given to the calculation. This is how it will be found in the Function Library and the simple Calculation drop down menu. In the example below, the calculation is named 'MultiSmooth'. While the description is optional, it is often a good idea to provide one as it will be used to form documentation for the calculation. Once the "Save To Library" button is clicked, the calculation is available to be used in all recordings in the Project.
Documentation available for the saved custom calculation can be viewed by clicking on the "Information" (circle with an italicized " i " in it) button at the top of the node.
Note: The saved function can be used in other custom calculations as is being demonstrated in the image below. It can be found by typing a partial or complete name into the Function Library search field.