Skip to content

Commit

Permalink
Merge pull request #1920 from AllenInstitute/feature/1920-mh_add_chan…
Browse files Browse the repository at this point in the history
…nel_type_dependent_si

SI: Introduce channel type dependent sampling interval (SUTTER preparation 2)
  • Loading branch information
t-b authored Oct 23, 2023
2 parents 3e9e96b + ae2f37c commit 65bd735
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
20 changes: 9 additions & 11 deletions Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1608,13 +1608,11 @@ End
///
/// @param[in] device device
/// @param[in] dataAcqOrTP one of @ref DataAcqModes
/// @param[in] channelType channel type, one of @ref XopChannelConstants
/// @param[out] valid [optional] returns if the choosen
/// sampling interval is valid or not (DAQ only)
/// @see SI_CalculateMinSampInterval()
Function DAP_GetSampInt(device, dataAcqOrTP, [valid])
string device
variable dataAcqOrTP
variable &valid
Function DAP_GetSampInt(string device, variable dataAcqOrTP, variable channelType, [variable &valid])

variable multiplier, sampInt
string fixedFreqkHzStr
Expand All @@ -1629,16 +1627,16 @@ Function DAP_GetSampInt(device, dataAcqOrTP, [valid])
sampInt = 1 / (str2num(fixedFreqkHzStr) * KILO_TO_ONE) * ONE_TO_MICRO

if(!ParamIsDefault(valid))
valid = sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE)
valid = sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE, channelType)
endif

return sampInt
else
multiplier = str2num(DAG_GetTextualValue(device, "Popup_Settings_SampIntMult"))
return SI_CalculateMinSampInterval(device, dataAcqOrTP) * multiplier
return SI_CalculateMinSampInterval(device, dataAcqOrTP, channelType) * multiplier
endif
elseif(dataAcqOrTP == TEST_PULSE_MODE)
return SI_CalculateMinSampInterval(device, dataAcqOrTP)
return SI_CalculateMinSampInterval(device, dataAcqOrTP, channelType)
else
ASSERT(0, "unknown mode")
endif
Expand Down Expand Up @@ -1982,7 +1980,7 @@ Function DAP_CheckSettings(device, mode)
return 1
endif

DAP_GetSampInt(device, mode, valid=validSampInt)
DAP_GetSampInt(device, mode, XOP_CHANNEL_TYPE_DAC, valid=validSampInt)
if(!validSampInt)
printf "%s: The selected sampling interval is not possible with your hardware.\r", device
ControlWindowToFront()
Expand Down Expand Up @@ -2891,7 +2889,7 @@ static Function DAP_CheckEpochLengthsOfStimset(string device, string setName)
return 1
endif

sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI
sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI

numEntries = DimSize(epochLengths, ROWS)
for(i = 0; i < numEntries; i += 1)
Expand Down Expand Up @@ -4459,7 +4457,7 @@ Function DAP_LockDevice(string win)
WB_UpdateChangedStimsets(device=deviceLocked)
DAP_UnlockCommentNotebook(deviceLocked)
DAP_ToggleAcquisitionButton(deviceLocked, DATA_ACQ_BUTTON_TO_DAQ)
SI_CalculateMinSampInterval(deviceLocked, DATA_ACQUISITION_MODE)
SI_CalculateMinSampInterval(deviceLocked, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC)

// deliberately not using the GUIState wave
headstage = GetSliderPositionIndex(deviceLocked, "slider_DataAcq_ActiveHeadstage")
Expand Down Expand Up @@ -4881,7 +4879,7 @@ Function DAP_UpdateDAQControls(device, updateFlag)
endif

if(updateFlag & REASON_HEADSTAGE_CHANGE)
SetValDisplay(device, "ValDisp_DataAcq_SamplingInt", var=DAP_GetSampInt(device, DATA_ACQUISITION_MODE))
SetValDisplay(device, "ValDisp_DataAcq_SamplingInt", var=DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC))
endif

if((updateFlag & REASON_HEADSTAGE_CHANGE) || (updateFlag & REASON_STIMSET_CHANGE))
Expand Down
12 changes: 6 additions & 6 deletions Packages/MIES/MIES_DataConfigurator.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,6 @@ static Function DC_PlaceDataInDAQConfigWave(device, dataAcqOrTP)

AddEntryIntoWaveNoteAsList(DAQConfigWave, CHANNEL_UNIT_KEY, str = unitList, replaceEntry = 1)

DAQConfigWave[][%SamplingInterval] = DAP_GetSampInt(device, dataAcqOrTP)
DAQConfigWave[][%DecimationMode] = 0
DAQConfigWave[][%Offset] = 0

if(dataAcqOrTP == DATA_ACQUISITION_MODE)
variable hardwareType = GetHardwareType(device)
switch(hardwareType)
Expand Down Expand Up @@ -714,6 +710,10 @@ static Function DC_PlaceDataInDAQConfigWave(device, dataAcqOrTP)
break
endswitch
endif

DAQConfigWave[][%SamplingInterval] = DAP_GetSampInt(device, dataAcqOrTP, DAQConfigWave[p][%ChannelType])
DAQConfigWave[][%DecimationMode] = 0
DAQConfigWave[][%Offset] = 0
End

/// @brief Get the decimation factor for the current channel configuration
Expand All @@ -727,7 +727,7 @@ static Function DC_GetDecimationFactor(device, dataAcqOrTP)
string device
variable dataAcqOrTP

return DAP_GetSampInt(device, dataAcqOrTP) / (WAVEBUILDER_MIN_SAMPINT * MILLI_TO_MICRO)
return DAP_GetSampInt(device, dataAcqOrTP, XOP_CHANNEL_TYPE_DAC) / (WAVEBUILDER_MIN_SAMPINT * MILLI_TO_MICRO)
End

/// @brief Returns the longest sweep in a stimulus set across the given channel type
Expand Down Expand Up @@ -1318,7 +1318,7 @@ static Function [STRUCT DataConfigurationResult s] DC_GetConfiguration(string de
// MH: note with NI the decimationFactor can now be < 1, like 0.4 if a single NI ADC channel runs with 500 kHz
// whereas the source data generated waves for ITC min sample rate are at 200 kHz
s.decimationFactor = DC_GetDecimationFactor(device, dataAcqOrTP)
s.samplingInterval = DAP_GetSampInt(device, dataAcqOrTP)
s.samplingInterval = DAP_GetSampInt(device, dataAcqOrTP, XOP_CHANNEL_TYPE_DAC)
WAVE/T allSetNames = DAG_GetChannelTextual(device, CHANNEL_TYPE_DAC, CHANNEL_CONTROL_WAVE)
s.hardwareType = GetHardwareType(device)

Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_Oscilloscope.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Function SCOPE_CreateGraph(device, dataAcqOrTP)
if(gotDAQChan)
Label/W=$graph bottomDAQ "Time DAQ (\\U)"
NVAR stopCollectionPoint = $GetStopCollectionPoint(device)
sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI
sampInt = DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_ADC) * MICRO_TO_MILLI
SetAxis/W=$graph bottomDAQ, 0, stopCollectionPoint * sampInt
ModifyGraph/W=$graph freePos(bottomDAQ)=-35
endif
Expand Down
5 changes: 2 additions & 3 deletions Packages/MIES/MIES_SamplingInterval.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,10 @@ End
///
/// @param device device
/// @param dataAcqOrTP one of @ref DataAcqModes, ignores TTL channels for #TEST_PULSE_MODE
/// @param channelType channel type @sa XopChannelConstants
///
/// @returns sampling interval in microseconds (1e-6)
Function SI_CalculateMinSampInterval(device, dataAcqOrTP)
string device
variable dataAcqOrTP
Function SI_CalculateMinSampInterval(string device, variable dataAcqOrTP, variable channelType)

variable hardwareType = GetHardwareType(device)
switch(hardwareType)
Expand Down
4 changes: 2 additions & 2 deletions Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,8 @@ Function TP_UpdateTPSettingsCalculated(string device)
calculated[%baselineFrac] = TPSettings[%baselinePerc][INDEP_HEADSTAGE] * PERCENT_TO_ONE

calculated[%pulseLengthMS] = TPSettings[%durationMS][INDEP_HEADSTAGE] // here for completeness
calculated[%pulseLengthPointsTP] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, TEST_PULSE_MODE) * MICRO_TO_MILLI))
calculated[%pulseLengthPointsDAQ] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, DATA_ACQUISITION_MODE) * MICRO_TO_MILLI))
calculated[%pulseLengthPointsTP] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, TEST_PULSE_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI))
calculated[%pulseLengthPointsDAQ] = trunc(TPSettings[%durationMS][INDEP_HEADSTAGE] / (DAP_GetSampInt(device, DATA_ACQUISITION_MODE, XOP_CHANNEL_TYPE_DAC) * MICRO_TO_MILLI))

calculated[%totalLengthMS] = TP_CalculateTestPulseLength(calculated[%pulseLengthMS], calculated[%baselineFrac])
calculated[%totalLengthPointsTP] = trunc(TP_CalculateTestPulseLength(calculated[%pulseLengthPointsTP], calculated[%baselineFrac]))
Expand Down

0 comments on commit 65bd735

Please sign in to comment.