Skip to content

Conversation

MichaelHuth
Copy link
Collaborator

This PR adds Sutter amplifier support to MIES

@MichaelHuth MichaelHuth self-assigned this May 31, 2024
@MichaelHuth MichaelHuth requested review from t-b and timjarsky as code owners May 31, 2024 11:54
@MichaelHuth
Copy link
Collaborator Author

MichaelHuth commented Jun 4, 2024

@t-b Here is a table with the settable IPA options:

		 CCMode // Sets headstage to Current Clamp
		 VCMode // Sets headstage to Voltage Clamp
		 IHold  // Sets the holding current in Current clamp to value
		 VHold // Sets the holding potential in Voltage clamp to value
		 Filter // Sets the amplifier filter setting (same for CC and VC).
                   Possible settings are (500;1kHz;2kHz;5kHz;10kHz;20kHz).
                   Function will set to the closest setting given an actual value.
                   Thus, either 5000 or 4900 will set the filter to 5kHz
		 IFilter // see above
		 VFilter // see above
		 VGain // Sets the input gain in Current clamp mode. Possible settings are 10;20;50;100;200;500 mV/mV).
		 IGain // Sets the input gain in Current clamp mode. Possible settings are (0.5;1;2.5;5;10;25 mV/pA).
// remark: Shouldn't that be a different clamp mode here?
		 Offset  // Sets the offset (in Volts)
		 OffsetLock // Toggles the offset lock
		 ECompMag // Sets electrode compensation magnitude (SI units, so value is between 0 and 25e-12).
		 ECompTau // Sets electrode compensation tau value (SI units, between 0.1e-6 and 4.5e-6).
		 RsComp  // Sets the whole-cell compensation Rs value (between 0 and 100e6).
		 CmComp // Sets the whole-cell compensation Cm value (between 0 and 100e-12).
		 RsPred // Sets the series resistance prediction value (% between 0 and 1). 
		 RsCorr  // Sets the series resistance correction value (% between 0 and 1).
		 RsLag // Sets the series resistance correction lag time (between 0 and 200e-6).
		 Bridge // Sets current clamp bridge balance (between 0 to 200e6).
		 BridgeOn // Enables/disables bridge balance.
		 AutoEComp // Activates the automatic electrode compensation routine
		 AutoCellComp // Activates the automatic cell compensation routine.
		 RsCompOn	// Rs Compensation enabled
		 RsCorrOn	//Prediction/Correction enabled
		 DynHold // Sets the dynamic hold voltage (between -1 and 1 V) for slow voltage control in CC mode.
		 DynHoldOn		// Enables/disables dynamic hold.
		 ECompOn		// Enables/disables electrode compensation (capacitance neutralization) in current clamp mode.
		 VHoldOn		//  Enables/disables holding potential in VC mode
		 IHoldOn		// Enables/disables holding current in CC mode.
		 AutoOffset // Calls the automatic offset control 
		 SealTest // Sets the HS#1 seal test. Value=0 off; otherwise value is amplitude in mV 
// (scaled 20 pA/unit in CC). SealTest automatically turns off if the amplifier is switched from VC to CC 
// (or vice versa), or if the headstage tab is changed (on the dIPA or multiple amplifiers). Seal test has a 
// 100ms duration which cannot be changed. Note: the seal test is not functional on headstage 2 of 
// the dIPA. If you require a seal test for the dIPA, please contact Sutter Instrument for a software solution.
		 Buzz

@t-b
Copy link
Collaborator

t-b commented Jun 4, 2024

Note to self: Figure out mapping between MCC controls and IPA names. Only support IPA ones which are on the MCC GUI window.

@MichaelHuth MichaelHuth force-pushed the feature/2126-sutter-amplifier-support branch from ae2068c to 9880788 Compare June 7, 2024 14:51
Sutter IPA control procedures and Sutter XOP 2.60 are
Copyright Sutter Instrument Corp. 2015 - 2024

The package was provided by Telly Galiatsatos
[email protected]
@MichaelHuth MichaelHuth force-pushed the feature/2126-sutter-amplifier-support branch 4 times, most recently from d309547 to 4754f7b Compare June 10, 2024 10:37
- Moved MCC specific Amplifier functions to MIES_AmplifierInteraction_MolecularDevices.ipf
- prefixed these functions with AIMCC_
- For all non-static AI_ functions, added abstraction that depending on device
  the MCC functions is called or a placeholder for Sutter amplifier is used.
- Added device argument to AI_ functions that did not used one, adapted depending
  call sites
- Kept checks of optional arguments in public AI_ functions
- Changed function declaration of public AIMCC_ functions to not use optional arguments
  The reason is that optional arguments can not easily promoted through function calls.
- Added updateView argument to AIMCC_UpdateAmpModel as ParamIsDefault state of value was
  used also for decision for updating the AmpView. This does not change the previous behavior.
- Adapted function declaration of all AIMCC_ functions to use modern syntax
@MichaelHuth MichaelHuth force-pushed the feature/2126-sutter-amplifier-support branch from 4754f7b to fefd7fd Compare June 10, 2024 14:01
@MichaelHuth
Copy link
Collaborator Author

MichaelHuth commented Jun 11, 2024

Control MCC func const or AIMCC_* function Sutter ID Sutter Comment
Radio_ClampMode_1 AIMCC_SetClampMode CCMode Sets headstage to Current Clamp
Radio_ClampMode_0 AIMCC_SetClampMode VCMode Sets headstage to Voltage Clamp
setvar_DataAcq_Hold_IC MCC_SETHOLDING_FUNC Ihold Sets the holding current in Current clamp to value
setvar_DataAcq_Hold_VC MCC_SETHOLDING_FUNC Vhold Sets the holding potential in Voltage clamp to value
Filter Sets the amplifier filter setting (same for CC and VC). Possible settings are (500;1kHz;2kHz;5kHz;10kHz;20kHz). Function will set to the closest setting given an actual value. Thus, either 5000 or 4900 will set the filter to 5kHz
Ifilter see above
Vfilter see above
Gain_AD_00 AIMCC_RetrieveGains Vgain Sets the input gain in Current clamp mode. Possible settings are 10;20;50;100;200;500 mV/mV).
Gain_AD_00 AIMCC_RetrieveGains Igain Sets the input gain in Current clamp mode. Possible settings are (0.5;1;2.5;5;10;25 mV/pA).
setvar_DataAcq_PipetteOffset_IC MCC_SETPIPETTEOFFSET_FUNC Offset Sets the offset (in Volts)
OffsetLock Toggles the offset lock
EcompMag Sets electrode compensation magnitude (SI units, so value is between 0 and 25e-12).
EcompTau Sets electrode compensation tau value (SI units, between 0.1e-6 and 4.5e-6).
MCC_SETWHOLECELLCOMPRESIST_FUNC RsComp Sets the whole-cell compensation Rs value (between 0 and 100e6).
MCC_SETWHOLECELLCOMPCAP_FUNC CmComp Sets the whole-cell compensation Cm value (between 0 and 100e-12).
setvar_DataAcq_RsPred MCC_SETRSCOMPPREDICTION_FUNC RsPred Sets the series resistance prediction value (% between 0 and 1).
setvar_DataAcq_RsCorr MCC_SETRSCOMPCORRECTION_FUNC RsCorr Sets the series resistance correction value (% between 0 and 1).
RsLag Sets the series resistance correction lag time (between 0 and 200e-6).
setvar_DataAcq_BB MCC_SETBRIDGEBALRESIST_FUNC Bridge Sets current clamp bridge balance (between 0 to 200e6).
check_DatAcq_BBEnable BridgeOn Enables/disables bridge balance.
AutoEComp Activates the automatic electrode compensation routine
AutoCellComp Activates the automatic cell compensation routine.
check_DatAcq_RsCompEnable MCC_SETRSCOMPENABLE_FUNC RsCompOn Rs Compensation enabled
RsCorrOn Prediction/Correction enabled
DynHold Sets the dynamic hold voltage (between -1 and 1 V) for slow voltage control in CC mode.
DynHoldOn Enables/disables dynamic hold.
check_DatAcq_CNEnable EcompOn Enables/disables electrode compensation (capacitance neutralization) in current clamp mode.
check_DatAcq_HoldEnableVC MCC_SETHOLDINGENABLE_FUNC VholdOn Enables/disables holding potential in VC mode
check_DatAcq_HoldEnable MCC_SETHOLDINGENABLE_FUNC IholdOn Enables/disables holding current in CC mode.
button_DataAcq_AutoPipOffset_IC AutoOffset Calls the automatic offset control
SealTest Sets the HS#1 seal test. Value=0 off; otherwise value is amplitude in mV (scaled 20 pA/unit in CC). SealTest automatically turns off if the amplifier is switched from VC to CC (or vice versa), or if the headstage tab is changed (on the dIPA or multiple amplifiers). Seal test has a 100ms duration which cannot be changed. Note: the seal test is not functional on headstage 2 of the dIPA. If you require a seal test for the dIPA, please contact Sutter Instrument for a software solution.
Buzz
button_DataAcq_AutoBridgeBal_IC MCC_AUTOBRIDGEBALANCE_FUNC
setvar_DataAcq_CN MCC_SETNEUTRALIZATIONCAP_FUNC
setvar_DataAcq_AutoBiasV sets a value
setvar_DataAcq_AutoBiasVrange sets a value
setvar_DataAcq_IbiasMax sets a value
check_DataAcq_AutoBias sets a value
check_DatAcq_WholeCellEnable MCC_SETWHOLECELLCOMPENABLE_FUNC
setvar_DataAcq_WCC MCC_SETWHOLECELLCOMPCAP_FUNC
setvar_DataAcq_WCR MCC_SETWHOLECELLCOMPRESIST_FUNC
button_DataAcq_WCAuto MCC_AUTOWHOLECELLCOMP_FUNC
check_DataAcq_Amp_Chain
button_DataAcq_FastComp_VC MCC_AUTOFASTCOMP_FUNC
button_DataAcq_SlowComp_VC MCC_AUTOSLOWCOMP_FUNC

@MichaelHuth MichaelHuth assigned t-b and unassigned MichaelHuth Jun 11, 2024
@t-b t-b removed their assignment Feb 21, 2025
@timjarsky timjarsky requested a review from Copilot August 7, 2025 17:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Sutter amplifier support to MIES by restructuring the amplifier interaction code to support multiple amplifier types. The main change involves splitting the existing amplifier code that was specifically designed for Molecular Devices/Axon amplifiers into device-specific implementations.

  • Refactors amplifier interaction functions to dispatch based on device type
  • Extracts Molecular Devices specific code into a dedicated module
  • Updates function signatures to include device parameter and return value tuples

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Packages/MIES/MIES_AmplifierInteraction_MolecularDevices.ipf New file containing all Molecular Devices/Axon specific amplifier code extracted from the main module
Packages/MIES/MIES_AmplifierInteraction.ipf Refactored to be a generic dispatcher that routes to device-specific implementations
Packages/MIES_Include.ipf Adds include for the new Molecular Devices amplifier module
Packages/MIES/MIES_Constants.ipf Updates comment references from AI_SendToAmp to AIMCC_SendToAmp
Multiple test files Updates function calls to include device parameter
Packages/MIES/MIES_DAEphys.ipf Updates function calls and handles new return value format
Packages/MIES/MIES_Configuration.ipf Updates AI_OpenMCCs call to include device parameter

value = AI_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPRESIST_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
AmpStorageWave[%WholeCellRes][0][i] = value
AIMCC_UpdateAmpView(device, i, ctrl = "setvar_DataAcq_WCR")
value = AI_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPENABLE_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_SendToAmp but should use AIMCC_SendToAmp to match the module prefix and avoid potential circular dependencies.

Suggested change
value = AI_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPENABLE_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_SETHOLDING_FUNC, value, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
TP_UpdateHoldCmdInTPStorage(device, headstage)
break
case "check_DatAcq_HoldEnableVC":
AmpStorageWave[1][0][i] = value
AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_SETHOLDINGENABLE_FUNC, value, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
TP_UpdateHoldCmdInTPStorage(device, headstage)
break
case "setvar_DataAcq_WCC":
AmpStorageWave[2][0][i] = value
AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_SETWHOLECELLCOMPCAP_FUNC, value, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
break
case "setvar_DataAcq_WCR":
AmpStorageWave[3][0][i] = value
AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_SETWHOLECELLCOMPRESIST_FUNC, value, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
break
case "button_DataAcq_WCAuto":
AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_AUTOWHOLECELLCOMP_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
value = AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPCAP_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
AmpStorageWave[%WholeCellCap][0][i] = value
AIMCC_UpdateAmpView(device, i, ctrl = "setvar_DataAcq_WCC")
value = AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPRESIST_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)
AmpStorageWave[%WholeCellRes][0][i] = value
AIMCC_UpdateAmpView(device, i, ctrl = "setvar_DataAcq_WCR")
value = AIMCC_SendToAmp(device, i, V_CLAMP_MODE, MCC_GETWHOLECELLCOMPENABLE_FUNC, NaN, checkBeforeWrite = checkBeforeWrite, selectAmp = 0)

Copilot uses AI. Check for mistakes.

break
case MCC_AUTOBRIDGEBALANCE_FUNC:
MCC_AutoBridgeBal()
ret = AI_SendToAmp(device, headstage, mode, MCC_GETBRIDGEBALRESIST_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_SendToAmp but should use AIMCC_SendToAmp to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
ret = AI_SendToAmp(device, headstage, mode, MCC_GETBRIDGEBALRESIST_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)
ret = AIMCC_SendToAmp(device, headstage, mode, MCC_GETBRIDGEBALRESIST_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)

Copilot uses AI. Check for mistakes.

break
case MCC_AUTOPIPETTEOFFSET_FUNC:
MCC_AutoPipetteOffset()
ret = AI_SendToAmp(device, headStage, mode, MCC_GETPIPETTEOFFSET_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_SendToAmp but should use AIMCC_SendToAmp to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
ret = AI_SendToAmp(device, headStage, mode, MCC_GETPIPETTEOFFSET_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)
ret = AIMCC_SendToAmp(device, headStage, mode, MCC_GETPIPETTEOFFSET_FUNC, NaN, usePrefixes = usePrefixes, selectAmp = 0)

Copilot uses AI. Check for mistakes.


if(setMode != storedMode)
print "There was a mismatch in clamp mode between MIES and the MCC. The MCC mode was switched to match the mode specified by MIES."
AI_SetClampMode(device, headStage, storedMode)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_SetClampMode but should use AIMCC_SetClampMode to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
AI_SetClampMode(device, headStage, storedMode)
AIMCC_SetClampMode(device, headStage, storedMode)

Copilot uses AI. Check for mistakes.

[DAGain, ADGain, DAUnit, ADUnit] = AIMCC_QueryGainsUnitsForClampMode(device, i, clampMode)
AI_UpdateChanAmpAssign(device, i, clampMode, DAGain, ADGain, DAUnit, ADUnit)

AI_SetClampMode(device, i, old_clampMode)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_SetClampMode but should use AIMCC_SetClampMode to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
AI_SetClampMode(device, i, old_clampMode)
AIMCC_SetClampMode(device, i, old_clampMode)

Copilot uses AI. Check for mistakes.

value = offset - vDelta
if(value > MIN_PIPETTEOFFSET && value < MAX_PIPETTEOFFSET)
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_VC", headStage, value = value, checkBeforeWrite = 1)
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_UpdateAmpModel but should use AIMCC_UpdateAmpModel to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)
AIMCC_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_VC", headStage, value = value, checkBeforeWrite = 1)
AIMCC_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)

Copilot uses AI. Check for mistakes.

value = offset - vDelta
if(value > MIN_PIPETTEOFFSET && value < MAX_PIPETTEOFFSET)
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_VC", headStage, value = value, checkBeforeWrite = 1)
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function call uses AI_UpdateAmpModel but should use AIMCC_UpdateAmpModel to maintain consistency with the module naming and avoid circular dependencies.

Suggested change
AI_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)
AIMCC_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_VC", headStage, value = value, checkBeforeWrite = 1)
AIMCC_UpdateAmpModel(device, "setvar_DataAcq_PipetteOffset_IC", headStage, value = value, checkBeforeWrite = 1)

Copilot uses AI. Check for mistakes.

endfor

if(failedToOpenCount > 0)
printf "%g MCCs failed to open on attempt count %g\r", failedTOopenCount, j
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name 'failedTOopenCount' contains a typo. It should be 'failedToOpenCount' (lowercase 'o' in 'To').

Suggested change
printf "%g MCCs failed to open on attempt count %g\r", failedTOopenCount, j
printf "%g MCCs failed to open on attempt count %g\r", failedToOpenCount, j

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants