). This is because when i try to connect with it using the standard NI module it gives me an error about the clock signal value (which i am assuming its because this one doesnt have an internal clock).And inside the SelectMany you have the Sum for each Window:
from System import Randomgenerator = Random()
@returns(float)def process(value): return generator.NextDouble()
In this example there is some kind of condition tested on MouseMove (e.g. if the X position is greater than some value), but we want to impose a refractory period after each positive result.
One way to do this is to use the sequence of combinators DistinctUntilChanged, a simple boolean Condition and GateInterval. In order to understand why, it's easier to go in over what each node is doing to the data stream (it also helps to visualize what each node is sending out):
1) After GreaterThan, we have a constant stream of Boolean values for each mouse movement (this could easily be a camera or any other digital signal).
2) DistinctUntilChanged will now filter the stream such that new values will only be emitted when they are different from the previous value. For example, applying DistinctUntilChanged to the sequence [False, False, True, True, True, False, False, False] will generate the values [False, True, False].
Basically you get the edges of the boolean stream.
3) The Condition simply filters the stream by saying we only want rising edges (i.e. positive, or True values). This works because we know that when DistinctUntilChanged sends out a True, it must mean the signal just changed from False to True; a positive rising edge). Usually it is necessary to specify what is the condition inside the green nested workflow (like an IF statement in programming languages), but in this case because the data stream is already made of Boolean values, we can just place the Condition node in there and it will be happy (Booleans are their own conditions).
4) GateInterval is an interesting beast: as the name implies, it gates the signal according to a time interval. What this means is that after the first value goes through, the gate is closed by the specified amount of time (i.e. any values arriving during that time will be dropped). After the time elapses, the gate is opened again and any new value will be allowed through, and so on.

This was the original answer to the question. The way to think about what Gate is doing here is to visualize it literally as a "gate" or "switch" that opens for a single element to pass through, and then immediately closes until some "master" signal tells it to open again. Once the gate is open, it will remain open until a new element arrives. In the case of GateInterval, the master is a periodic temporal signal. In your case, you can imagine that there is a clock firing every 30s to signal the Gate should open.
The problem with this approach, which you detected, is that the clock is not necessarily aligned with the production of elements. It literally fires every 30s, regardless of when the event actually happens. Now, if you imagine that Gate is in the open state but the event only arrives 27s later, the Gate will only close for 3s, because after that a new clock signal will arrive and make it open again. Clearly not what you might want from a "refractory period".
2) Refractory period as an enforced "silent period" between two trials
This one seems easy at first glance, but there's a catch, which led me to the limitation I was mentioning at the start of the post. The idea here is that you stem the flow of data completely for a given interval, and then resume. Take(1) specifies that only a single element from the data stream will be taken, everything else will be ignored. After this you add a Delay equal to your desired "dead period". After the delay elapses, the sequence will complete, because there is nothing else to propagate. At that point, we want to Repeat the whole sequence, i.e. again Take a single element, Delay for 30s, and so on. In this case, you want to add your stimulation sinks between Take and Delay.
What I've done here is add a single branch after the point that I want to avoid reinitializing. The branch does nothing (MemberSelector by itself is a "no-op"). However, branching in Bonsai has a side effect we can exploit in this case: specifically, it guarantees that until all branches are dead, the source will not be reinitialized. Repeat only applies to the top branch, so because the bottom branch remains alive, the source is prevented from reinitializing.