Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make epochs sample point exact #1990

Merged
merged 35 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dbb39f0
Util: Add functions for round, ceil, floor to return also delta to or…
MichaelHuth Jan 26, 2024
539fa2a
Util: Add function that translates indices from a source to a decimat…
MichaelHuth Jan 30, 2024
25994db
WaveGetters: Use ceil for length of WB segmentWave
MichaelHuth Jan 26, 2024
c6b96c3
WB: Add function to determine indices from startTime and duration
MichaelHuth Jan 25, 2024
45b4d08
WB: Add assert in WB_CreatePulse to prevent first == last
MichaelHuth Jan 25, 2024
1a68aa2
WB: Add additional check for cutting off zeroes at the end of pulseTr…
MichaelHuth Jan 25, 2024
8bb5336
WB: Add pulse range indices to stimset wave note
MichaelHuth Jan 26, 2024
104d88b
WB: Add inflection point indices to stimset wavenote
MichaelHuth Jan 29, 2024
d9adfd2
WB: Add length in points of each segment to stimset wavenote
MichaelHuth Jan 29, 2024
5ab0dbf
WB: Add stimset size information to stimset note
MichaelHuth Feb 10, 2024
73ac606
WB: Improve stimset format description of WB_GetWaveNoteEntry
MichaelHuth Jan 29, 2024
8396446
WB: Raise Stimset version to 10
MichaelHuth Jan 29, 2024
d37e520
Tests: Adapt Wavebuilder Regression Tests
MichaelHuth Jan 31, 2024
dcac40b
DC: Correct generated datasize by shift introduced by decimation
MichaelHuth Jan 30, 2024
79f00e1
DC: For decimation of TTL channels use round instead of trunc
MichaelHuth Feb 5, 2024
202abd4
EP: Correct assertion message in EP_AddEpoch
MichaelHuth Feb 1, 2024
7442e87
EP: Correct start offset of TP epoch by 1 sample point to be exact
MichaelHuth Feb 6, 2024
c7dea4d
EP: Rewrite of pulse train epoch creation to be sample exact
MichaelHuth Feb 6, 2024
28d5c3d
EP: Add wave getter for epochs wave as free wave
MichaelHuth Feb 14, 2024
a41e4b6
EP: Use epochs wave as argument for adding epochs
MichaelHuth Feb 14, 2024
fed8d25
EP: Make epoch creation independent of device
MichaelHuth Feb 15, 2024
b90970c
Struct: Move EP_EpochCreationData structure to MIES_Epochs as static …
MichaelHuth Feb 15, 2024
c7cd891
EP: Make inflection epochs sample exact
MichaelHuth Feb 15, 2024
423a424
Util: Add utility function FindFirstNaNIndex
MichaelHuth Mar 4, 2024
8dcfed7
EP: global EndTime reference for epochs is now time of DA wave size + 1
MichaelHuth Mar 4, 2024
d06ec1c
Tests: tighten epochs amplitude test to be sample position exact
MichaelHuth Feb 2, 2024
69c9df8
Tests: Add Square Pulse to epoch amplitude test
MichaelHuth Feb 12, 2024
4e8e2e3
Util: Add function SetDimensionLabelsFromWaveContents
MichaelHuth Feb 23, 2024
50196a6
Tests: Add Epochs tests with all fixed frequencies and multipliers
MichaelHuth Feb 12, 2024
265855a
Tests: Add more description to INFO string in epoch amplitude test
MichaelHuth Feb 13, 2024
e968ab3
Tests: Add amplitude test for epochs between inflection points
MichaelHuth Feb 16, 2024
6ad9e25
Tests: Add more Epoch tests for TTL
MichaelHuth Feb 20, 2024
1f13155
SFH: Adapt SFH_GetSweepsForFormula for new Epoch range standard
MichaelHuth Feb 22, 2024
cf8cec1
Doc: Update documentation for epochs
MichaelHuth Feb 19, 2024
56e908b
BSP: Change precision of epoch traces to double precision
MichaelHuth Mar 21, 2024
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
6 changes: 3 additions & 3 deletions Packages/MIES/MIES_BrowserSettingsPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1686,14 +1686,14 @@ Function BSP_AddTracesForEpochs(string win)

numEpochs = DimSize(epochs, ROWS)

Make/FREE/N=(BSP_EPOCH_LEVELS) currentLevel, indexInLevel
Make/FREE/D/N=(BSP_EPOCH_LEVELS) currentLevel, indexInLevel

sprintf levels_x_name, "levels_x_%s", idpart
Make/O/N=(numEpochs * 3, 5, 2) dfr:$levels_x_name/WAVE=levels_x
Make/O/D/N=(numEpochs * 3, 5, 2) dfr:$levels_x_name/WAVE=levels_x
levels_x = NaN

sprintf levels_y_name, "levels_y_%s", idPart
Make/O/N=(numEpochs * 3, 5, 2) dfr:$levels_y_name/WAVE=levels_y
Make/O/D/N=(numEpochs * 3, 5, 2) dfr:$levels_y_name/WAVE=levels_y
levels_y = NaN
SetStringInWaveNote(levels_y, "EpochInfo", GetWavesDataFolder(epochs, 2))

Expand Down
9 changes: 7 additions & 2 deletions Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Constant WAVEBUILDER_PANEL_VERSION = 14
Constant ANALYSISBROWSER_PANEL_VERSION = 3

/// Version of the stimset wave note
Constant STIMSET_NOTE_VERSION = 9
Constant STIMSET_NOTE_VERSION = 10

/// Version of the epoch information for DA+TTL data
Constant SWEEP_EPOCH_VERSION = 9
Expand Down Expand Up @@ -55,7 +55,7 @@ Constant PSQ_SEAL_EVALUATION_VERSION = 3
Constant PSQ_TRUE_REST_VM_VERSION = 2
Constant MSQ_FAST_RHEO_EST_VERSION = 1
Constant MSQ_DA_SCALE_VERSION = 1
Constant SC_SPIKE_CONTROL_VERSION = 1
Constant SC_SPIKE_CONTROL_VERSION = 2
/// @}

/// Especially interesting for PXP consumers like the analysis browser.
Expand Down Expand Up @@ -970,6 +970,11 @@ StrConstant EPOCHS_ENTRY_KEY = "Epochs"
StrConstant CLAMPMODE_ENTRY_KEY = "Clamp Mode"
StrConstant TP_AMPLITUDE_VC_ENTRY_KEY = "TP Amplitude VC"
StrConstant TP_AMPLITUDE_IC_ENTRY_KEY = "TP Amplitude IC"
StrConstant PULSE_START_INDICES_KEY = "Pulse Train Pulse Start Indices"
StrConstant PULSE_END_INDICES_KEY = "Pulse Train Pulse End Indices"
StrConstant INFLECTION_POINTS_INDEX_KEY = "Inflection Points Indices"
StrConstant EPOCH_LENGTH_INDEX_KEY = "Epoch Length Indices"
StrConstant STIMSET_SIZE_KEY = "Stimset Size"

/// DA_Ephys controls which should be disabled during DAQ
StrConstant CONTROLS_DISABLE_DURING_DAQ = "Check_DataAcqHS_All;Radio_ClampMode_AllIClamp;Radio_ClampMode_AllVClamp;Radio_ClampMode_AllIZero;SetVar_Sweep;Check_DataAcq_Indexing;check_DataAcq_IndexRandom;Check_DataAcq1_IndexingLocked;check_DataAcq_RepAcqRandom;Check_DataAcq1_RepeatAcq;Check_Settings_SkipAnalysFuncs;check_Settings_MD"
Expand Down
28 changes: 20 additions & 8 deletions Packages/MIES/MIES_DataConfigurator.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ End
/// @param stimSet stimset wave
/// @param device device
/// @param dataAcqOrTP one of #DATA_ACQUISITION_MODE or #TEST_PULSE_MODE
static Function DC_CalculateStimsetLength(stimSet, device, dataAcqOrTP)
Function DC_CalculateStimsetLength(stimSet, device, dataAcqOrTP)
WAVE stimSet
string device
variable dataAcqOrTP
Expand All @@ -891,14 +891,16 @@ static Function DC_CalculateGeneratedDataSize(device, dataAcqOrTP, genLength)
string device
variable dataAcqOrTP, genLength

variable decimationFactor = DC_GetDecimationFactor(device, dataAcqOrTP)

// note: the decimationFactor is the factor between the hardware sample rate and the sample rate of the generated waveform in singleStimSet
// The ratio of the source to target wave sizes is however limited by the integer size of both waves
// While ideally srcLength == tgtLength the floor(...) limits the real data wave length such that
// when decimationFactor * index of real data wave is applied as index of the generated data wave it never exceeds its size
// Also if decimationFactor >= 2 the last point of the generated data wave is never transferred
// e.g. generated data with 10 points and decimationFactor == 2 copies index 0, 2, 4, 6, 8 to the real data wave of size 5
if(dataAcqOrTP == DATA_ACQUISITION_MODE)
return floor(genLength / DC_GetDecimationFactor(device, dataAcqOrTP))
return floor(genLength / decimationFactor) + IndexAfterDecimation(0, decimationFactor)
elseif(dataAcqOrTP == TEST_PULSE_MODE)
return genLength
else
Expand All @@ -920,11 +922,14 @@ static Function DC_PlaceDataInDAQDataWave(device, numActiveChannels, dataAcqOrTP

variable ret, row, column

WAVE/T epochWave = GetEpochsWave(device)

STRUCT DataConfigurationResult s
[s] = DC_GetConfiguration(device, numActiveChannels, dataAcqOrTP, multiDevice)

NVAR stopCollectionPoint = $GetStopCollectionPoint(device)
stopCollectionPoint = DC_GetStopCollectionPoint(device, s)
s.stopCollectionPoint = stopCollectionPoint

AssertOnAndClearRTError()

Expand All @@ -934,7 +939,7 @@ static Function DC_PlaceDataInDAQDataWave(device, numActiveChannels, dataAcqOrTP
DC_FillDAQDataWaveForDAQ(device, s)
endif

EP_CollectEpochInfo(device, s)
EP_CollectEpochInfo(epochWave, s)
DC_PrepareLBNEntries(device, s)

if(dataAcqOrTP == DATA_ACQUISITION_MODE)
Expand Down Expand Up @@ -994,7 +999,7 @@ static Function DC_WriteTTLIntoDAQDataWave(string device, STRUCT DataConfigurati
singleSetLength = DC_CalculateStimsetLength(TTLWaveSingle, device, DATA_ACQUISITION_MODE)
WAVE NIChannel = NIDataWave[i + ttlOffset]
MultiThread NIChannel[startOffset, startOffset + singleSetLength - 1] = \
limit(TTLWaveSingle[trunc(s.decimationFactor * (p - startOffset))], 0, 1); AbortOnRTE
limit(TTLWaveSingle[round(s.decimationFactor * (p - startOffset))], 0, 1); AbortOnRTE
endfor
break
case HARDWARE_ITC_DAC:
Expand All @@ -1007,12 +1012,12 @@ static Function DC_WriteTTLIntoDAQDataWave(string device, STRUCT DataConfigurati
bitMask = 1 << NUM_ITC_TTL_BITS_PER_RACK - 1
if(ITCRackZeroChecked)
MultiThread ITCDataWave[startOffset, startOffset + singleSetLength - 1][ttlOffset] = \
limit(TTLWaveITC[trunc(s.decimationFactor * (p - startOffset))] & bitMask, SIGNED_INT_16BIT_MIN, SIGNED_INT_16BIT_MAX); AbortOnRTE
limit(TTLWaveITC[round(s.decimationFactor * (p - startOffset))] & bitMask, SIGNED_INT_16BIT_MIN, SIGNED_INT_16BIT_MAX); AbortOnRTE
endif

if(DC_AreTTLsInRackChecked(device, RACK_ONE))
MultiThread ITCDataWave[startOffset, startOffset + singleSetLength - 1][ttlOffset + ITCRackZeroChecked] = \
limit(TTLWaveITC[trunc(s.decimationFactor * (p - startOffset))] >> NUM_ITC_TTL_BITS_PER_RACK & bitMask, SIGNED_INT_16BIT_MIN, SIGNED_INT_16BIT_MAX); AbortOnRTE
limit(TTLWaveITC[round(s.decimationFactor * (p - startOffset))] >> NUM_ITC_TTL_BITS_PER_RACK & bitMask, SIGNED_INT_16BIT_MIN, SIGNED_INT_16BIT_MAX); AbortOnRTE
endif
break
endswitch
Expand Down Expand Up @@ -1430,6 +1435,7 @@ static Function [STRUCT DataConfigurationResult s] DC_GetConfiguration(string de
variable channel, headstage, channelMode
variable scalingZero, indexingLocked, indexing
variable i, j, ret, setCycleCountLocal
variable testPulseLength, tpPulseStartPoint, tpPulseLengthPoints
string ctrl

// pass parameters into returned struct
Expand Down Expand Up @@ -1484,8 +1490,11 @@ static Function [STRUCT DataConfigurationResult s] DC_GetConfiguration(string de

WAVE s.testPulse = GetTestPulse()

// test pulse length is calculated for dataAcqOrTP
s.testPulseLength = DimSize(s.testPulse, ROWS)
// test pulse length is calculated for dataAcqOrTP @ref TP_CreateTestPulseWave
[testPulseLength, tpPulseStartPoint, tpPulseLengthPoints] = TP_GetCreationPropertiesInPoints(device, dataAcqOrTP)
s.testPulseLength = testPulseLength
s.tpPulseStartPoint = tpPulseStartPoint
s.tpPulseLengthPoints = tpPulseLengthPoints

s.headstageDAC[] = channelClampMode[s.DACList[p]][%DAC][%Headstage]
s.headstageADC[] = channelClampMode[s.ADCList[p]][%ADC][%Headstage]
Expand Down Expand Up @@ -1671,6 +1680,7 @@ static Function DC_SetupConfigurationTTLstimSets(string device, STRUCT DataConfi

WAVE/T allSetNames = DAG_GetChannelTextual(device, CHANNEL_TYPE_TTL, CHANNEL_CONTROL_WAVE)
WAVE statusTTLFiltered = DC_GetFilteredChannelState(device, s.dataAcqOrTP, CHANNEL_TYPE_TTL)
WAVE s.statusTTLFiltered = statusTTLFiltered

for(i = 0; i < NUM_DA_TTL_CHANNELS; i += 1)
if(!statusTTLFiltered[i])
Expand Down Expand Up @@ -1997,6 +2007,7 @@ static Function DC_ITC_MakeTTLWave(string device, STRUCT DataConfigurationResult
endfor
endif
endfor
s.joinedTTLStimsetSize = DC_CalculateStimsetLength(TTLWave, device, DATA_ACQUISITION_MODE)
End

static Function DC_NI_MakeTTLWave(string device, STRUCT DataConfigurationResult &s)
Expand Down Expand Up @@ -2027,6 +2038,7 @@ static Function DC_NI_MakeTTLWave(string device, STRUCT DataConfigurationResult
MultiThread TTLWaveSingle[] = TTLStimSet[p][s.TTLsetColumn[i]]
TTLWave[i] = TTLWaveSingle
endfor
s.joinedTTLStimsetSize = NaN

DC_DocumentChannelProperty(device, "Stim set length", INDEP_HEADSTAGE, NaN, XOP_CHANNEL_TYPE_TTL, str=TextWaveToList(setLength, ";"))
DC_DocumentChannelProperty(device, "channels", INDEP_HEADSTAGE, NaN, XOP_CHANNEL_TYPE_TTL, str=TextWaveToList(channels, ";"))
Expand Down
Loading