# Create a condition for a variable portion of another condition

## Recommended Posts

• Seeq Team

FAQ:

I have a condition for events of variable duration. I would like to create a new condition that comprises the first third of the time (or 4th, or 10th) of the original condition.

Solution:

A stepwise approach can be taken to achieve this functionality.

2. Create a new Signal using Signal from Condition that calculates the total duration of each of your event capsules, interpolated as a step signal.

3. Create a new signal that is your total event duration multiplied by the proportion of the event that you would like to capture. e.g. for the first 1/3 of the event, divide your total duration signal by 3, as shown below.

4. Create an arbitrary discrete signal with a sample at the start of each of your event capsules.

5. Shift the arbitrary discrete signal in time by the value of your signal calculated in step 3. In this example, the 1/3 duration signal. Note, depending on your version of Seeq, the function to do this may be called move() or delay().

6. Use the toCapsules() function in Formula to create a tiny (zero duration) capsule at each of your shifted, discrete samples.

7. Join the start of your original condition with the capsules created in step 6 using the composite condition tool. • 3
##### Share on other sites

• Seeq Team

For those Formula-savvy users, a one Formula approach to this would be as follows where you would define your percentage of the capsule in the first line:

```\$percent = 10%.tosignal().resample(1s)
\$condition.transform(\$capsule ->{
\$movetime = \$capsule.duration()*\$percent.toScalars(\$capsule).first()
capsule(\$capsule.startKey(),\$capsule.startKey()+\$movetime)})```

• 4