Skip to content

Commit

Permalink
Merge pull request #2136 from AllenInstitute/bugfix/2136-use-more-ip9…
Browse files Browse the repository at this point in the history
…-features

Use more IP9 features
  • Loading branch information
t-b authored Jun 10, 2024
2 parents ab54d19 + 174f36d commit 5c9352e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ static Function SC_ProcessPulses(string device, variable sweepNo, variable minim

WAVE statusHS = DAG_GetActiveHeadstages(device, I_CLAMP_MODE)

WAVE/T/Z spikeNumbersLBN, spikePositionsLBN
[spikeNumbersLBN, spikePositionsLBN] = SC_GetSpikeNumbersAndPositions(device, sweepNo)
[WAVE/T spikeNumbersLBN, WAVE/T spikePositionsLBN] = SC_GetSpikeNumbersAndPositions(device, sweepNo)

key = CreateAnaFuncLBNKey(SC_SPIKE_CONTROL, MSQ_FMT_LBN_SPIKE_COUNTS)
ED_AddEntryToLabnotebook(device, key, spikeNumbersLBN)
Expand Down
1 change: 0 additions & 1 deletion Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -6073,7 +6073,6 @@ static Function [variable epBegin, variable epEnd] PSQ_CR_GetSpikeEvaluationRang

WAVE durations = PSQ_GetPulseDurations(device, PSQ_CHIRP, sweepNo, totalOnsetDelay)

WAVE/T epochWave = GetEpochsWave(device)
[epBegin, epEnd] = PSQ_CR_AddSpikeEvaluationEpoch(epochsWave, DAC, headstage, durations, totalOnsetDelay)

return [epBegin * ONE_TO_MILLI, epEnd * ONE_TO_MILLI]
Expand Down
4 changes: 1 addition & 3 deletions Packages/MIES/MIES_Configuration.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ Function CONF_AutoLoader([string customIPath])
Abort
endif

WAVE/T/Z mainFileList
WAVE/T/Z rigFileList
[rigFileList, mainFileList] = SplitTextWaveBySuffix(rawFileList, EXPCONFIG_RIGFILESUFFIX)
[WAVE/T rigFileList, WAVE/T mainFileList] = SplitTextWaveBySuffix(rawFileList, EXPCONFIG_RIGFILESUFFIX)

Sort mainFileList, mainFileList
numFiles = DimSize(mainFileList, ROWS)
Expand Down
9 changes: 3 additions & 6 deletions Packages/MIES/MIES_LogbookViewer.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ static Function LBV_AddTraceToLBGraph(string graph, WAVE keys, WAVE values, stri
variable isTimeAxis, isTextData, xPos, logbookType
STRUCT RGBColor s

WAVE/T/Z traces
[traces, lbl, unit, col] = LBV_GetPropertiesForLabnotebookEntry(keys, key)
[WAVE/T traces, lbl, unit, col] = LBV_GetPropertiesForLabnotebookEntry(keys, key)

if(!WaveExists(traces))
return NaN
Expand Down Expand Up @@ -609,8 +608,7 @@ static Function LBV_AddTraceToLBGraphTPStorage(string graph, DFREF dfr, string k
variable xPos, layer, legacyActiveADColumns, searchLayer
STRUCT RGBColor s

WAVE/T/Z traces
[traces, lblTemplate] = LBV_GenerateTraceNames(key, NUM_HEADSTAGES)
[WAVE/T traces, lblTemplate] = LBV_GenerateTraceNames(key, NUM_HEADSTAGES)

list = GetListOfObjects(dfr, TP_STORAGE_REGEXP, fullPath = 1)

Expand Down Expand Up @@ -763,8 +761,7 @@ static Function LBV_AddTagsForTextualLBNEntries(string graph, WAVE/T keys, WAVE/
string tagString, tmp, text, unit, lbl, name, lastTag
STRUCT RGBColor s

WAVE/T/Z traces
[traces, lbl, unit, col] = LBV_GetPropertiesForLabnotebookEntry(keys, key)
[WAVE/T traces, lbl, unit, col] = LBV_GetPropertiesForLabnotebookEntry(keys, key)

if(!WaveExists(traces))
return NaN
Expand Down
3 changes: 1 addition & 2 deletions Packages/MIES/MIES_MiesUtilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -8159,8 +8159,7 @@ Function UploadLogFiles([variable verbose, variable firstDate, variable lastDate

if(doFilter)
UploadLogFilesPrint(" -> Filtering", verbose)
WAVE/Z/T uploadData = $""
[uploadData, lastIndex] = FilterByDate(logData, firstDate, lastDate)
[WAVE/T uploadData, lastIndex] = FilterByDate(logData, firstDate, lastDate)
if(!WaveExists(uploadData))
UploadLogFilesPrint(" -> No new entries to upload here.\r", verbose)
continue
Expand Down
3 changes: 1 addition & 2 deletions Packages/MIES/MIES_NeuroDataWithoutBorders.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,7 @@ static Function NWB_AppendLogFileToString(string path, string &str)
now = GetISO8601TimeStamp()
firstDate = ParseISO8601TimeStamp(now[0, 9] + "T00:00:00Z")
lastDate = Inf
WAVE/Z/T partData = $""
[partData, lastIndex] = FilterByDate(logData, firstDate, lastDate)
[WAVE/T partData, lastIndex] = FilterByDate(logData, firstDate, lastDate)
if(WaveExists(partData))
WAVE/WAVE splitContents = SplitLogDataBySize(partData, LOG_FILE_LINE_END, STRING_MAX_SIZE - MEGABYTE)
if(DimSize(splitContents, ROWS) > 1)
Expand Down
22 changes: 7 additions & 15 deletions Packages/MIES/MIES_PulseAveraging.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,7 @@ static Function [STRUCT PulseAverageSetIndices pasi] PA_GenerateAllPulseWaves(st
j = 0
numNewSweeps = DimSize(additionalData, ROWS)
ASSERT(numNewSweeps > 0, "Set POST_PLOT_ADDED_SWEEPS, but found no new sweep(s) in additionlData")
WAVE/D/Z newSweeps
WAVE/T/Z newExperiments
[newSweeps, newExperiments] = PA_GetSweepsAndExperimentsFromIndices(win, additionalData)
[WAVE/D newSweeps, WAVE/T newExperiments] = PA_GetSweepsAndExperimentsFromIndices(win, additionalData)

for(i = 0; i < numNewSweeps; i += 1)
WAVE/Z indizesNewSweep = FindIndizes(traceData, colLabel = "SweepNumber", str = num2str(newSweeps[i]))
Expand Down Expand Up @@ -883,9 +881,8 @@ static Function [STRUCT PulseAverageSetIndices pasi] PA_GenerateAllPulseWaves(st
first = round(pulseInfos[k][%PulseStart] / DimDelta(wv, ROWS))
length = round(pulseToPulseLength / DimDelta(wv, ROWS))

WAVE/Z pulseWave, pulseWaveNote
[pulseWave, pulseWaveNote] = PA_CreateAndFillPulseWaveIfReq(wv, singlePulseFolder, channelType, channelNumber, \
clampMode, region, k, first, length, pulseInfos)
[WAVE pulseWave, WAVE pulseWaveNote] = PA_CreateAndFillPulseWaveIfReq(wv, singlePulseFolder, channelType, channelNumber, \
clampMode, region, k, first, length, pulseInfos)

if(!WaveExists(pulseWave))
continue
Expand Down Expand Up @@ -1752,8 +1749,7 @@ static Function/S PA_ShowPulses(string win, STRUCT PulseAverageSettings &pa, STR
graphWasReset = WhichListItem(graph, resetGraphs, ";") != -1
endif

WAVE/Z averageWave
[averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)
[WAVE averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)

sprintf traceName, "Ovl_%s%s", PA_AVERAGE_WAVE_PREFIX, baseName

Expand Down Expand Up @@ -2294,8 +2290,7 @@ static Function PA_DrawScaleBars(string win, STRUCT PulseAverageSettings &pa, ST
SetDrawLayer/K/W=$graph $PA_DRAWLAYER_SCALEBAR
endif

WAVE/Z averageWave
[averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)
[WAVE averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)
if(WaveExists(averageWave))
maximum = GetNumberFromWaveNote(averageWave, NOTE_KEY_WAVE_MAXIMUM)
length = pa.yScaleBarLength * (IsFinite(maximum) ? sign(maximum) : +1)
Expand Down Expand Up @@ -3410,8 +3405,7 @@ static Function/S PA_ShowImage(string win, STRUCT PulseAverageSettings &pa, STRU

resetImage = 0

WAVE/Z averageWave
[averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)
[WAVE averageWave, baseName] = GetPAPermanentAverageWave(pasi.pulseAverageDFR, channelNumber, region)

if(!pa.multipleGraphs && i == 0 && j == 0 || pa.multipleGraphs)
graph = PA_GetGraph(win, pa, PA_DISPLAYMODE_IMAGES, channelNumber, region, j + 1, i + 1, numActive)
Expand Down Expand Up @@ -3467,9 +3461,7 @@ static Function/S PA_ShowImage(string win, STRUCT PulseAverageSettings &pa, STRU
|| scaleChanged \
|| layoutChanged))

WAVE/D/Z newSweeps
WAVE/T/Z newExperiments
[newSweeps, newExperiments] = PA_GetSweepsAndExperimentsFromIndices(win, additionalData)
[WAVE/D newSweeps, WAVE/T newExperiments] = PA_GetSweepsAndExperimentsFromIndices(win, additionalData)

newSweep = WaveMin(newSweeps)
WAVE setIndizes = pasi.setIndices[i][j]
Expand Down
9 changes: 3 additions & 6 deletions Packages/MIES/MIES_StimsetAPI.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ Function ST_GetStimsetParameterAsVariable(string setName, string entry, [variabl
return NaN
endif

WAVE/Z wv
[wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)
[WAVE wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)

if(WaveExists(wv) && IsNumericWave(wv))
return wv[row][col][layer]
Expand Down Expand Up @@ -380,8 +379,7 @@ Function/S ST_GetStimsetParameterAsString(string setName, string entry, [variabl
return ""
endif

WAVE/Z wv
[wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)
[WAVE wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)

WAVE/T/Z wvText = wv

Expand Down Expand Up @@ -439,8 +437,7 @@ Function ST_SetStimsetParameter(string setName, string entry, [variable epochInd
return 1
endif

WAVE/Z wv
[wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)
[WAVE wv, row, col, layer] = ST_GetStimsetParameterWaveIndexTuple(setName, entry, epochIndex)

if(!WaveExists(wv))
return 1
Expand Down
9 changes: 3 additions & 6 deletions Packages/MIES/MIES_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ static Function [WAVE sweepDataFiltOff, WAVE sweepDataFiltOffDeconv] PSX_Analysi

WAVE sweepDataFilt = PSX_FilterSweepData(sweepData, sweepFilterLow, sweepFilterHigh)

WAVE/ZZ sweepDataFiltOff
[sweepDataFiltOff, offset] = PSX_OffsetSweepData(sweepDataFilt)
[WAVE sweepDataFiltOff, offset] = PSX_OffsetSweepData(sweepDataFilt)

if(!WaveExists(sweepDataFiltOff))
return [$"", $""]
Expand Down Expand Up @@ -4452,8 +4451,7 @@ Function/WAVE PSX_OperationPrep(variable jsonId, string jsonPath, string graph)
WAVE/WAVE output = SFH_CreateSFRefWave(graph, SF_OP_PSX_PREP, 3)
SetDimensionLabels(output, "Histogram;Fit;Thresholds;", ROWS)
WAVE/Z hist, fit
[hist, fit, threshold, dataUnit] = PSX_CalculatePeakThreshold(results, numCombos, numSDs)
[WAVE hist, WAVE fit, threshold, dataUnit] = PSX_CalculatePeakThreshold(results, numCombos, numSDs)
Make/FREE=1/N=1 sdThresholdX, sdThresholdY
Expand Down Expand Up @@ -4495,8 +4493,7 @@ static Function [WAVE hist, WAVE fit, variable peakThresh, string dataUnit] PSX_
WAVE hist = PSX_CreateHistogramOfDeconvSweepData(sweepDataFiltOffDeconv)
WAVE/Z coef, fit
[coef, fit] = PSX_FitHistogram(hist)
[WAVE coef, WAVE fit] = PSX_FitHistogram(hist)
if(WaveExists(coef) && WaveExists(fit))
peakThresh = RoundNumber(coef[3] * numSDs, 3)
Expand Down
65 changes: 6 additions & 59 deletions Packages/MIES/MIES_Utilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1500,90 +1500,37 @@ threadsafe Function/DF UniqueDataFolder(dfr, baseName)

string path

ASSERT_TS(!isEmpty(baseName), "baseName must not be empty")

path = UniqueDataFolderName(dfr, basename)

if(isEmpty(path))
return $""
endif

NewDataFolder $path
return $path
End

/// @brief Return an absolute unique data folder name which does not exist in dfr
///
/// @param dfr datafolder to search
/// @param baseName first part of the datafolder, must be a *valid* Igor Pro object name
threadsafe Function/S UniqueDataFolderName(dfr, baseName)
DFREF dfr
string baseName

variable index, numRuns
string basePath, path
/// @param baseName first part of the datafolder
threadsafe Function/S UniqueDataFolderName(DFREF dfr, string baseName)

ASSERT_TS(!isEmpty(baseName), "baseName must not be empty")
ASSERT_TS(DataFolderExistsDFR(dfr), "dfr does not exist")
ASSERT_TS(!IsFreeDatafolder(dfr), "dfr can not be a free DF")

numRuns = 10000
// shorten basename so that we can attach some numbers
baseName = baseName[0, MAX_OBJECT_NAME_LENGTH_IN_BYTES - (ceil(log(numRuns)) + 1)]
baseName = CleanupName(baseName, 0)
basePath = GetDataFolder(1, dfr)
path = basePath + baseName

do
if(!DataFolderExists(path))
return path
endif

path = basePath + baseName + "_" + num2istr(index)

index += 1
while(index < numRuns)

DEBUGPRINT_TS("Could not find a unique folder with trials:", var = numRuns)

return ""
return GetDataFolder(1, dfr) + CreateDataObjectName(dfr, basename, 11, 0, 0)
End

/// @brief Returns a wave name not used in the given datafolder
///
/// Basically a datafolder aware version of UniqueName for datafolders
///
/// @param dfr datafolder reference where the new datafolder should be created
/// @param baseName first part of the wave name, might be shorted due to Igor Pro limitations
threadsafe Function/S UniqueWaveName(dfr, baseName)
DFREF dfr
string baseName

variable index
string name
string path
/// @param baseName first part of the wave name
threadsafe Function/S UniqueWaveName(DFREF dfr, string baseName)

ASSERT_TS(!isEmpty(baseName), "baseName must not be empty")
ASSERT_TS(DataFolderExistsDFR(dfr), "dfr does not exist")

// shorten basename so that we can attach some numbers
baseName = CleanupName(baseName[0, MAX_OBJECT_NAME_LENGTH_IN_BYTES - 5], 0)
path = GetDataFolder(1, dfr)
name = baseName

do
if(!WaveExists($(path + name)))
return name
endif

name = baseName + "_" + num2istr(index)

index += 1
while(index < 10000)

DEBUGPRINT_TS("Could not find a unique folder with 10000 trials")

return ""
return CreateDataObjectName(dfr, basename, 1, 0, 0)
End

/// @brief Remove a prefix from a string
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_WaveDataFolderGetters.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,7 @@ Function/DF GetTempPath()
return createDFWithAllParents(GetMiesPathAsString() + ":" + TRASH_FOLDER_PREFIX)
End

/// @brief Return a unique temporary folder below the MIES hierarchy, e.g. root:mies:trash_$digit.
/// @brief Return a unique temporary folder below the MIES hierarchy, e.g. root:mies:trash$digit.
///
/// As soon as you discard the latest reference to the folder it will
/// be slated for removal at some point in the future.
Expand Down
5 changes: 3 additions & 2 deletions Packages/tests/Basic/UTF_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ End

static Function MouseSelectionPSX()

string browser, device, code, psxPlot
string browser, device, code, psxPlot, win

Make/FREE/T combos = {"Range[50, 150], Sweep [0], Channel [AD6], Device [ITC16_Dev_0]", \
"Range[50, 150], Sweep [2], Channel [AD6], Device [ITC16_Dev_0]"}
Expand All @@ -1315,7 +1315,8 @@ static Function MouseSelectionPSX()

ExecuteSweepFormulaCode(browser, code)

psxPlot = "SweepFormula_plotDatabrowser_1_#Graph0"
win = SFH_GetFormulaGraphForBrowser(browser)
psxPlot = MIES_PSX#PSX_GetPSXGraph(win)
REQUIRE(WindowExists(psxPlot))

[WAVE psxEvent_0, WAVE psxEvent_1] = GetPSXEventWavesHelper(psxPlot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static Function RTV_Works_REENTRY([str])
sweepNo = AFH_GetLastSweepAcquired(str)
CHECK_EQUAL_VAR(sweepNo, 2)

WAVE/Z deltaI, deltaV, resistance, resistanceErr, autobiasFromDialog
[deltaI, deltaV, resistance, resistanceErr, autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo)
[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, sweepNo)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
Expand Down Expand Up @@ -92,8 +91,7 @@ static Function RTV_WorksWithIndexing_REENTRY([str])
sweepNo = AFH_GetLastSweepAcquired(str)
CHECK_EQUAL_VAR(sweepNo, 3)

WAVE/Z deltaI, deltaV, resistance, resistanceErr, autobiasFromDialog
[deltaI, deltaV, resistance, resistanceErr, autobiasFromDialog] = GetLBNEntries_IGNORE(str, 0)
[WAVE deltaI, WAVE deltaV, WAVE resistance, WAVE resistanceErr, WAVE autobiasFromDialog] = GetLBNEntries_IGNORE(str, 0)

CHECK_WAVE(deltaI, NUMERIC_WAVE)
CHECK_WAVE(deltaV, NUMERIC_WAVE)
Expand Down
3 changes: 1 addition & 2 deletions Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ static Function UnassociatedChannelsAndTTLs_REENTRY([str])
WAVE/T/Z stimWaveChecksums = GetLastSetting(textualValues, j, "TTL Stim Wave Checksum", DATA_ACQUISITION_MODE)

WAVE/Z stimSetLengths = GetLastSetting(textualValues, j, "TTL Stim set length", DATA_ACQUISITION_MODE)
WAVE/Z settings = $""
[settings, index] = GetLastSettingChannel(numericalValues, textualValues, j, "TTL Stim set length", 1, XOP_CHANNEL_TYPE_TTL, DATA_ACQUISITION_MODE)
[WAVE settings, index] = GetLastSettingChannel(numericalValues, textualValues, j, "TTL Stim set length", 1, XOP_CHANNEL_TYPE_TTL, DATA_ACQUISITION_MODE)
CHECK_WAVE(settings, TEXT_WAVE)
CHECK_EQUAL_VAR(index, INDEP_HEADSTAGE)
WAVE/T settingsT = settings
Expand Down

0 comments on commit 5c9352e

Please sign in to comment.