Skip to content

Commit 790c39d

Browse files
authored
Merge pull request #518 from open-ephys/patch-estim-dialog
Update ElectricalStimulator dialog to match OpticalStimulator behavior
2 parents 85c569d + 325a7b5 commit 790c39d

6 files changed

+42
-20
lines changed

OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorOptions.Designer.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorOptions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,21 @@ public Headstage64ElectricalStimulatorOptions(ConfigureHeadstage64ElectricalStim
3737
textBoxTrainBurstCount.Text = electricalStimulator.TrainBurstCount.ToString();
3838
textBoxTrainDelay.Text = electricalStimulator.TriggerDelay.ToString();
3939
}
40+
41+
void BurstPulseCountChanged(object sender, System.EventArgs e)
42+
{
43+
if (int.TryParse(textBoxBurstPulseCount.Text, out int result))
44+
{
45+
textBoxPulsePeriod.Enabled = result > 1;
46+
}
47+
}
48+
49+
void TrainBurstCountChanged(object sender, System.EventArgs e)
50+
{
51+
if (int.TryParse(textBoxTrainBurstCount.Text, out int result))
52+
{
53+
textBoxInterBurstInterval.Enabled = result > 1;
54+
}
55+
}
4056
}
4157
}

OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorSequenceDialog.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,9 @@ static bool AnyCurrentIsSet(ConfigureHeadstage64ElectricalStimulator sequence)
231231
SetTextBoxBackgroundError(StimulusSequenceOptions.textBoxPhaseTwoDuration);
232232
return false;
233233
}
234-
else if (AnyCurrentIsSet(electricalStimulator) && electricalStimulator.InterPulseInterval == 0)
235-
{
236-
reason = "Pulse period has not been set.";
237-
SetTextBoxBackgroundError(StimulusSequenceOptions.textBoxPulsePeriod);
238-
return false;
239-
}
240-
else if (AnyCurrentIsSet(electricalStimulator) && electricalStimulator.InterPulseInterval < electricalStimulator.PhaseOneDuration + electricalStimulator.InterPhaseInterval + electricalStimulator.PhaseTwoDuration)
234+
else if (AnyCurrentIsSet(electricalStimulator) && electricalStimulator.BurstPulseCount > 1
235+
&& (electricalStimulator.InterPulseInterval == 0
236+
|| electricalStimulator.InterPulseInterval < electricalStimulator.PhaseOneDuration + electricalStimulator.InterPhaseInterval + electricalStimulator.PhaseTwoDuration))
241237
{
242238
reason = "Pulse period is too short.";
243239
SetTextBoxBackgroundError(StimulusSequenceOptions.textBoxPulsePeriod);

OpenEphys.Onix1.Design/Headstage64OpticalStimulatorOptions.Designer.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenEphys.Onix1.Design/Headstage64OpticalStimulatorOptions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,21 @@ internal void UpdateSequenceParameters(ConfigureHeadstage64OpticalStimulator opt
4949

5050
internal readonly double channelOneScalingFactor;
5151
internal readonly double channelTwoScalingFactor;
52+
53+
void PulsesPerBurstChanged(object sender, System.EventArgs e)
54+
{
55+
if (int.TryParse(textBoxPulsesPerBurst.Text, out int result))
56+
{
57+
textBoxPulsePeriod.Enabled = result > 1;
58+
}
59+
}
60+
61+
void BurstsPerTrainChanged(object sender, System.EventArgs e)
62+
{
63+
if (int.TryParse(textBoxBurstsPerTrain.Text, out int result))
64+
{
65+
textBoxInterBurstInterval.Enabled = result > 1;
66+
}
67+
}
5268
}
5369
}

OpenEphys.Onix1.Design/Headstage64OpticalStimulatorSequenceDialog.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,12 @@ public Headstage64OpticalStimulatorSequenceDialog(ConfigureHeadstage64OpticalSti
100100
{ StimulusSequenceOptions.textBoxPulsesPerBurst,
101101
new TextBoxBinding<uint>(
102102
StimulusSequenceOptions.textBoxPulsesPerBurst,
103-
value =>
104-
{
105-
OpticalStimulator.PulsesPerBurst = value;
106-
StimulusSequenceOptions.textBoxPulsePeriod.Enabled = OpticalStimulator.PulsesPerBurst > 1;
107-
return OpticalStimulator.PulsesPerBurst;
108-
},
103+
value => { OpticalStimulator.PulsesPerBurst = value; return OpticalStimulator.PulsesPerBurst; },
109104
uint.Parse) },
110105
{ StimulusSequenceOptions.textBoxBurstsPerTrain,
111106
new TextBoxBinding<uint>(
112107
StimulusSequenceOptions.textBoxBurstsPerTrain,
113-
value =>
114-
{
115-
OpticalStimulator.BurstsPerTrain = value;
116-
StimulusSequenceOptions.textBoxInterBurstInterval.Enabled = OpticalStimulator.BurstsPerTrain > 1;
117-
return OpticalStimulator.BurstsPerTrain;
118-
},
108+
value => { OpticalStimulator.BurstsPerTrain = value; return OpticalStimulator.BurstsPerTrain; },
119109
uint.Parse) }
120110
};
121111

@@ -180,7 +170,7 @@ void TextBoxChanged(object sender, EventArgs e)
180170
}
181171
else
182172
{
183-
throw new NotImplementedException($"No valid text box found when updating parameters in {nameof(Headstage64ElectricalStimulatorSequenceDialog)}");
173+
throw new NotImplementedException($"No valid text box found when updating parameters in {nameof(Headstage64OpticalStimulatorSequenceDialog)}");
184174
}
185175

186176
SetTextBoxBackgroundDefault(textBox);

0 commit comments

Comments
 (0)