From b653e3d35bbd4beef0aa779635f0b98298eafc84 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Tue, 22 Oct 2024 17:07:34 -0400 Subject: [PATCH] Allow individual parameters to be changed --- Directory.Build.props | 2 +- .../Rhs2116StimulusSequenceDialog.cs | 134 +++++++----------- 2 files changed, 56 insertions(+), 80 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d12448f..6266d68 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,7 +13,7 @@ LICENSE true icon.png - 0.4.0 + 0.4.1 10.0 strict diff --git a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs index 34de646..44abe81 100644 --- a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs @@ -684,68 +684,46 @@ private void ButtonAddPulses_Click(object sender, EventArgs e) { if (ChannelDialog.SelectedContacts[i]) { - if (textboxDelay.Tag == null) + if (textboxDelay.Tag != null) { - MessageBox.Show("Unable to parse delay."); - return; + Sequence.Stimuli[i].DelaySamples = (uint)textboxDelay.Tag; } - if (textboxAmplitudeAnodic.Tag == null) + if (textboxAmplitudeAnodic.Tag != null) { - MessageBox.Show("Unable to parse anodic amplitude."); - return; + Sequence.Stimuli[i].AnodicAmplitudeSteps = (byte)textboxAmplitudeAnodic.Tag; } - if (textboxPulseWidthAnodic.Tag == null) + if (textboxPulseWidthAnodic.Tag != null) { - MessageBox.Show("Unable to parse anodic pulse width."); - return; + Sequence.Stimuli[i].AnodicWidthSamples = (uint)textboxPulseWidthAnodic.Tag; } - if (textboxInterPulseInterval.Tag == null) + if (textboxInterPulseInterval.Tag != null) { - MessageBox.Show("Unable to parse inter-pulse interval."); - return; + Sequence.Stimuli[i].DwellSamples = (uint)textboxInterPulseInterval.Tag; } - if (textboxAmplitudeCathodic.Tag == null) + if (textboxAmplitudeCathodic.Tag != null) { - MessageBox.Show("Unable to parse cathodic amplitude."); - return; + Sequence.Stimuli[i].CathodicAmplitudeSteps = (byte)textboxAmplitudeCathodic.Tag; } - if (textboxPulseWidthCathodic.Tag == null) + if (textboxPulseWidthCathodic.Tag != null) { - MessageBox.Show("Unable to parse cathodic pulse width."); - return; + Sequence.Stimuli[i].CathodicWidthSamples = (uint)textboxPulseWidthCathodic.Tag; } - if (textboxInterStimulusInterval.Tag == null) + if (textboxInterStimulusInterval.Tag != null) { - MessageBox.Show("Unable to parse inter-stimulus interval."); - return; + Sequence.Stimuli[i].InterStimulusIntervalSamples = (uint)textboxInterStimulusInterval.Tag; } - if (!uint.TryParse(textboxNumberOfStimuli.Text, out uint numberOfStimuliValue)) + if (uint.TryParse(textboxNumberOfStimuli.Text, out uint numberOfStimuliValue)) { - MessageBox.Show("Unable to parse number of stimuli."); - return; + Sequence.Stimuli[i].NumberOfStimuli = numberOfStimuliValue; } - Sequence.Stimuli[i].DelaySamples = (uint)textboxDelay.Tag; - - Sequence.Stimuli[i].AnodicAmplitudeSteps = (byte)textboxAmplitudeAnodic.Tag; - Sequence.Stimuli[i].AnodicWidthSamples = (uint)textboxPulseWidthAnodic.Tag; - - Sequence.Stimuli[i].CathodicAmplitudeSteps = (byte)textboxAmplitudeCathodic.Tag; - Sequence.Stimuli[i].CathodicWidthSamples = (uint)textboxPulseWidthCathodic.Tag; - - Sequence.Stimuli[i].DwellSamples = (uint)textboxInterPulseInterval.Tag; - - Sequence.Stimuli[i].InterStimulusIntervalSamples = (uint)textboxInterStimulusInterval.Tag; - - Sequence.Stimuli[i].NumberOfStimuli = numberOfStimuliValue; - Sequence.Stimuli[i].AnodicFirst = checkBoxAnodicFirst.Checked; } } @@ -853,6 +831,18 @@ private void Samples_TextChanged(object sender, EventArgs e) else if (textBox.Text == "") { textBox.Tag = null; + + if (textBox.Name == nameof(textboxPulseWidthAnodic) && checkboxBiphasicSymmetrical.Checked) + { + textboxPulseWidthCathodic.Text = ""; + textboxPulseWidthCathodic.Tag = null; + } + else if (textBox.Name == nameof(textboxPulseWidthCathodic) && checkboxBiphasicSymmetrical.Checked) + { + textboxPulseWidthAnodic.Text = ""; + textboxPulseWidthAnodic.Tag = null; + } + return; } @@ -944,6 +934,21 @@ private void Amplitude_TextChanged(object sender, EventArgs e) if (textBox.Text == "") { textBox.Tag = null; + + if (checkboxBiphasicSymmetrical.Checked) + { + if (textBox.Name == nameof(textboxAmplitudeAnodic)) + { + textboxAmplitudeCathodic.Text = ""; + textboxAmplitudeCathodic.Tag = null; + } + else if (textBox.Name == nameof(textboxAmplitudeCathodic)) + { + textboxAmplitudeAnodic.Text = ""; + textboxAmplitudeAnodic.Tag = null; + } + } + return; } @@ -981,47 +986,6 @@ private void Amplitude_TextChanged(object sender, EventArgs e) textboxAmplitudeAnodic.Tag = textBox.Tag; } } - else - { - if (textBox.Name == nameof(textboxAmplitudeAnodic) && double.TryParse(textboxAmplitudeCathodic.Text, out var cathodicAmplitude)) - { - if (!GetSampleFromAmplitude(cathodicAmplitude, out var samples) || samples == 0) - { - MessageBox.Show("Invalid amplitude chosen for the anodic pulse. The step-size required " + - "for this amplitude is incompatible with the step-size required for the cathodic pulse.", "Invalid Anodic Amplitude"); - textBox.Text = ""; - textBox.Tag = null; - - textboxAmplitudeCathodic.Text = ""; - textboxAmplitudeCathodic.Tag = null; - return; - } - else - { - textboxAmplitudeCathodic.Text = GetAmplitudeString(samples); - textboxAmplitudeCathodic.Tag = samples; - } - } - else if (textBox.Name == nameof(textboxAmplitudeCathodic) && double.TryParse(textboxAmplitudeAnodic.Text, out var anodicAmplitude)) - { - if (!GetSampleFromAmplitude(anodicAmplitude, out var samples) || samples == 0) - { - MessageBox.Show("Invalid amplitude chosen for the cathodic pulse. The step-size required " + - "for this amplitude is incompatible with the step-size required for the anodic pulse.", "Invalid Cathodic Amplitude"); - textBox.Text = ""; - textBox.Tag = null; - - textboxAmplitudeAnodic.Text = ""; - textboxAmplitudeAnodic.Tag = null; - return; - } - else - { - textboxAmplitudeAnodic.Text = GetAmplitudeString(samples); - textboxAmplitudeAnodic.Tag = samples; - } - } - } } /// @@ -1087,11 +1051,23 @@ private void Checkbox_CheckedChanged(object sender, EventArgs e) { groupBoxCathode.Visible = false; groupBoxAnode.Visible = true; + + textboxPulseWidthCathodic.Text = textboxPulseWidthAnodic.Text; + textboxPulseWidthCathodic.Tag = textboxPulseWidthAnodic.Tag; + + textboxAmplitudeCathodic.Text = textboxAmplitudeAnodic.Text; + textboxAmplitudeCathodic.Tag = textboxAmplitudeAnodic.Tag; } else { groupBoxCathode.Visible = true; groupBoxAnode.Visible = false; + + textboxPulseWidthAnodic.Text = textboxPulseWidthCathodic.Text; + textboxPulseWidthAnodic.Tag = textboxPulseWidthCathodic.Tag; + + textboxAmplitudeAnodic.Text = textboxAmplitudeCathodic.Text; + textboxAmplitudeAnodic.Tag = textboxAmplitudeCathodic.Tag; } } else