Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions schema/aind_behavior_dynamic_foraging.json
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,18 @@
"title": "Quiescence Period Duration",
"type": "number"
},
"quiescence_period_refractory_duration": {
"default": null,
"description": "Duration of the refractory period after a lick is detected during the quiescence period (in seconds).",
"oneOf": [
{
"$ref": "#/$defs/Distribution"
},
{
"type": "null"
}
]
},
"inter_trial_interval_duration": {
"default": 5.0,
"description": "Duration of the inter-trial interval (in seconds).",
Expand Down
23 changes: 23 additions & 0 deletions src/Extensions/AindBehaviorDynamicForaging.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6278,6 +6278,8 @@ public partial class Trial

private double _quiescencePeriodDuration;

private AllenNeuralDynamics.AindBehaviorServices.Distributions.Distribution _quiescencePeriodRefractoryDuration;

private double _interTrialIntervalDuration;

private bool? _isAutoRewardRight;
Expand Down Expand Up @@ -6310,6 +6312,7 @@ protected Trial(Trial other)
_responseDeadlineDuration = other._responseDeadlineDuration;
_quickRetractSettings = other._quickRetractSettings;
_quiescencePeriodDuration = other._quiescencePeriodDuration;
_quiescencePeriodRefractoryDuration = other._quiescencePeriodRefractoryDuration;
_interTrialIntervalDuration = other._interTrialIntervalDuration;
_isAutoRewardRight = other._isAutoRewardRight;
_lickspoutOffsetDelta = other._lickspoutOffsetDelta;
Expand Down Expand Up @@ -6474,6 +6477,25 @@ public double QuiescencePeriodDuration
}
}

/// <summary>
/// Duration of the refractory period after a lick is detected during the quiescence period (in seconds).
/// </summary>
[System.Xml.Serialization.XmlIgnoreAttribute()]
[Newtonsoft.Json.JsonPropertyAttribute("quiescence_period_refractory_duration")]
[System.ComponentModel.DescriptionAttribute("Duration of the refractory period after a lick is detected during the quiescence " +
"period (in seconds).")]
public AllenNeuralDynamics.AindBehaviorServices.Distributions.Distribution QuiescencePeriodRefractoryDuration
{
get
{
return _quiescencePeriodRefractoryDuration;
}
set
{
_quiescencePeriodRefractoryDuration = value;
}
}

/// <summary>
/// Duration of the inter-trial interval (in seconds).
/// </summary>
Expand Down Expand Up @@ -6566,6 +6588,7 @@ protected virtual bool PrintMembers(System.Text.StringBuilder stringBuilder)
stringBuilder.Append("ResponseDeadlineDuration = " + _responseDeadlineDuration + ", ");
stringBuilder.Append("QuickRetractSettings = " + _quickRetractSettings + ", ");
stringBuilder.Append("QuiescencePeriodDuration = " + _quiescencePeriodDuration + ", ");
stringBuilder.Append("QuiescencePeriodRefractoryDuration = " + _quiescencePeriodRefractoryDuration + ", ");
stringBuilder.Append("InterTrialIntervalDuration = " + _interTrialIntervalDuration + ", ");
stringBuilder.Append("IsAutoRewardRight = " + _isAutoRewardRight + ", ");
stringBuilder.Append("LickspoutOffsetDelta = " + _lickspoutOffsetDelta + ", ");
Expand Down
184 changes: 138 additions & 46 deletions src/Extensions/TaskEngine.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -260,59 +260,132 @@
<Name>QuiescentPeriod</Name>
<Workflow>
<Nodes>
<Expression xsi:type="Unit" />
<Expression xsi:type="SubscribeSubject">
<Name>ThisTrial</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>QuiescencePeriodDuration</Selector>
</Expression>
<Expression xsi:type="scr:ExpressionTransform">
<scr:Name>it &lt; 0 ? 0 : it</scr:Name>
<scr:Expression>it &lt; 0 ? 0 : it</scr:Expression>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p3:TimeSpanFromSeconds" />
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="DueTime" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Timer">
<rx:DueTime>PT1S</rx:DueTime>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="BooleanProperty">
<Value>true</Value>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>IsRightLickEvent</Name>
</Expression>
<Expression xsi:type="Unit" />
<Expression xsi:type="rx:PublishSubject">
<Name>lickReset</Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="BooleanProperty">
<Value>false</Value>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Merge" />
</Expression>
<Expression xsi:type="rx:CreateObservable">
<Name>CreateTimer</Name>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>ThisTrial</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>QuiescencePeriodRefractoryDuration</Selector>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>RngObject</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="RandomSource" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p4:SampleDistribution" />
</Expression>
<Expression xsi:type="scr:ExpressionTransform">
<scr:Name>it &lt; 0 ? 0 : it</scr:Name>
<scr:Expression>it &lt; 0 ? 0 : it</scr:Expression>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p3:TimeSpanFromSeconds" />
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="DueTime" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Timer">
<rx:DueTime>PT3S</rx:DueTime>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="BooleanProperty">
<Value>false</Value>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>ThisTrial</Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>QuiescencePeriodRefractoryDuration</Selector>
</Expression>
<Expression xsi:type="IncludeWorkflow" Path="AllenNeuralDynamics.Core:FilterNotNull.bonsai" />
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:SubscribeWhen" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Concat" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Repeat" />
</Expression>
<Expression xsi:type="rx:Condition">
<Name>QuiescentCompleted</Name>
<Workflow>
<Nodes>
<Expression xsi:type="SubscribeSubject">
<Name>ThisTrial</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>QuiescencePeriodDuration</Selector>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p3:TimeSpanFromSeconds" />
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="DueTime" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Timer">
<rx:DueTime>PT0S</rx:DueTime>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
<Expression xsi:type="WorkflowInput">
<Name>Source1</Name>
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Switch" />
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="rx:SelectMany">
<Name>SolveSpoutPosition</Name>
Expand Down Expand Up @@ -340,11 +413,6 @@
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="WorkflowOutput" />
<Expression xsi:type="Unit" />
<Expression xsi:type="Combinator">
Expand Down Expand Up @@ -383,7 +451,7 @@
<Selector>TimeToResetDuringQuiescence</Selector>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>RngSeedValue</Name>
<Name>RngObject</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
Expand Down Expand Up @@ -445,23 +513,47 @@
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="4" Label="Source1" />
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="3" Label="Source1" />
<Edge From="3" To="4" Label="Source2" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="6" To="11" Label="Source1" />
<Edge From="7" To="8" Label="Source1" />
<Edge From="8" To="9" Label="Source1" />
<Edge From="10" To="11" Label="Source1" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="11" Label="Source2" />
<Edge From="11" To="12" Label="Source1" />
<Edge From="12" To="28" Label="Source1" />
<Edge From="13" To="14" Label="Source1" />
<Edge From="14" To="15" Label="Source1" />
<Edge From="15" To="19" Label="Source1" />
<Edge From="16" To="17" Label="Source1" />
<Edge From="14" To="17" Label="Source1" />
<Edge From="15" To="16" Label="Source1" />
<Edge From="16" To="17" Label="Source2" />
<Edge From="17" To="18" Label="Source1" />
<Edge From="18" To="19" Label="Source2" />
<Edge From="18" To="19" Label="Source1" />
<Edge From="19" To="20" Label="Source1" />
<Edge From="20" To="21" Label="Source1" />
<Edge From="21" To="22" Label="Source1" />
<Edge From="22" To="27" Label="Source1" />
<Edge From="23" To="24" Label="Source1" />
<Edge From="24" To="25" Label="Source1" />
<Edge From="25" To="26" Label="Source1" />
<Edge From="26" To="27" Label="Source2" />
<Edge From="27" To="28" Label="Source2" />
<Edge From="28" To="29" Label="Source1" />
<Edge From="29" To="30" Label="Source1" />
<Edge From="30" To="31" Label="Source1" />
<Edge From="31" To="32" Label="Source1" />
<Edge From="32" To="33" Label="Source1" />
<Edge From="34" To="35" Label="Source1" />
<Edge From="35" To="36" Label="Source1" />
<Edge From="37" To="38" Label="Source1" />
<Edge From="38" To="39" Label="Source1" />
<Edge From="39" To="43" Label="Source1" />
<Edge From="40" To="41" Label="Source1" />
<Edge From="41" To="42" Label="Source1" />
<Edge From="42" To="43" Label="Source2" />
</Edges>
</Workflow>
</Expression>
Expand Down
4 changes: 4 additions & 0 deletions src/aind_behavior_dynamic_foraging/task_logic/trial_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class Trial(BaseModel):
ge=0,
description="Duration of the quiescence period before trial starts (in seconds). Each lick resets the timer.",
)
quiescence_period_refractory_duration: Optional[Distribution] = Field(
default=None,
description="Duration of the refractory period after a lick is detected during the quiescence period (in seconds).",
)
inter_trial_interval_duration: float = Field(
default=5.0, ge=0.5, description="Duration of the inter-trial interval (in seconds)."
)
Expand Down
Loading