Skip to content

Commit 52e53d9

Browse files
authored
Merge pull request #1032 from AllenInstitute/feature/1032-make-compatible-with-latest-IP9
Make dimension labels valid liberal object names
2 parents 50beb41 + 02773e2 commit 52e53d9

11 files changed

+286
-49
lines changed

Packages/MIES/MIES_Constants.ipf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Constant HARDWARE_DAC_EXTERNAL_TRIGGER = 0x1
623623
/// Used to upgrade the GuiStateWave as well as the DA Ephys panel
624624
Constant DA_EPHYS_PANEL_VERSION = 53
625625
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 30
626-
Constant WAVEBUILDER_PANEL_VERSION = 10
626+
Constant WAVEBUILDER_PANEL_VERSION = 11
627627
Constant ANALYSISBROWSER_PANEL_VERSION = 1
628628

629629
/// Version of the labnotebooks (numerical and textual)
@@ -633,7 +633,7 @@ Constant ANALYSISBROWSER_PANEL_VERSION = 1
633633
/// - Changed names of entries
634634
/// - Changed units or meaning of entries
635635
/// - New/Changed layers of entries
636-
Constant LABNOTEBOOK_VERSION = 48
636+
Constant LABNOTEBOOK_VERSION = 49
637637

638638
/// Version of the stimset wave note
639639
Constant STIMSET_NOTE_VERSION = 7

Packages/MIES/MIES_DataConfigurator.ipf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,9 +1014,9 @@ static Function DC_PrepareLBNEntries(string panelTitle, STRUCT DataConfiguration
10141014
DC_DocumentChannelProperty(panelTitle, "Igor Pro version", INDEP_HEADSTAGE, NaN, NaN, str=GetIgorProVersion())
10151015
DC_DocumentChannelProperty(panelTitle, "Igor Pro build", INDEP_HEADSTAGE, NaN, NaN, str=GetIgorProBuildVersion())
10161016
DC_DocumentChannelProperty(panelTitle, "Igor Pro bitness", INDEP_HEADSTAGE, NaN, NaN, var=GetArchitectureBits())
1017-
DC_DocumentChannelProperty(panelTitle, "JSON config file: path", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_SOURCEFILE_PATH))
1018-
DC_DocumentChannelProperty(panelTitle, "JSON config file: SHA-256 hash", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_SOURCEFILE_HASH))
1019-
DC_DocumentChannelProperty(panelTitle, "JSON config file: stimset nwb file path", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_STIMSET_NWB_PATH))
1017+
DC_DocumentChannelProperty(panelTitle, "JSON config file [path]", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_SOURCEFILE_PATH))
1018+
DC_DocumentChannelProperty(panelTitle, "JSON config file [SHA-256 hash]", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_SOURCEFILE_HASH))
1019+
DC_DocumentChannelProperty(panelTitle, "JSON config file [stimset nwb file path]", INDEP_HEADSTAGE, NaN, NaN, str=GetUserData(panelTitle, "", EXPCONFIG_UDATA_STIMSET_NWB_PATH))
10201020
DC_DocumentChannelProperty(panelTitle, "TP after DAQ", INDEP_HEADSTAGE, NaN, NaN, var=DAG_GetNumericalValue(panelTitle, "check_Settings_TPAfterDAQ"))
10211021

10221022
for(i = 0; i < NUM_HEADSTAGES; i += 1)

Packages/MIES/MIES_Debugging.ipf

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,96 @@ Function GetSizeOfAllWavesInExperiment()
551551
Edit/K=1 root:list
552552
End
553553

554+
/// @brief Check that all stored waves (permanent and free) adhere to the liberal naming rules.
555+
///
556+
/// These are only enforced since IP9 beta9 or later.
557+
///
558+
/// @return Number of waves not matching
559+
Function CheckAllDimensionLabels()
560+
string msg, path
561+
variable i, numWaves, failures
562+
563+
WAVE/T allWaves = ListToTextWave(GetListOfObjects($"root:", ".*", fullPath=1, recursive=1), ";")
564+
WAVE/T allWavesUnique = GetUniqueEntries(allWaves)
565+
WaveClear allWaves
566+
567+
numWaves = DimSize(allWavesUnique, ROWS)
568+
for(i = 0; i < numWaves; i += 1)
569+
path = allWavesUnique[i]
570+
WAVE wv = $path
571+
msg = CheckDimensionLabels(wv)
572+
573+
if(!IsEmpty(msg))
574+
printf "Wave %s:\r", path
575+
print msg
576+
failures += 1
577+
endif
578+
endfor
579+
580+
return failures
581+
End
582+
583+
threadsafe static Function/S CheckDimensionLabels(WAVE/Z wv)
584+
variable i, numDims, j, size, numMatches, numEntries, idx
585+
string entry
586+
string msg = ""
587+
string text = ""
588+
589+
if(!WaveExists(wv))
590+
return msg
591+
endif
592+
593+
numDims = WaveDims(wv)
594+
595+
for(i = 0; i < numDims; i += 1)
596+
size = DimSize(wv, i)
597+
598+
Make/FREE/T/N=(size + 1) lbls
599+
Multithread lbls[] = GetDimLabel(wv, i, p - 1)
600+
Make/FREE/N=(size + 1) valid
601+
Multithread valid[] = IsValidLiberalObjectName(lbls[p])
602+
603+
FindValue/UOFV/V=0 valid
604+
605+
if(V_Value >= 0)
606+
WAVE/Z indizes = FindIndizes(valid, col = 0, var = 0)
607+
numMatches = WaveExists(indizes) ? DimSize(indizes, ROWS) : 0
608+
609+
for(j = 0; j < numMatches; j += 1)
610+
sprintf text, "dimension %d, element %d, label %s\r", i, indizes[j], lbls[indizes[j]]
611+
msg += text
612+
endfor
613+
endif
614+
endfor
615+
616+
// call recursively if it is a wave reference wave
617+
if(IsWaveRefWave(wv))
618+
WAVE/WAVE waveRef = wv
619+
// use a linearized index to check all holded waves
620+
numEntries = numpnts(waveRef)
621+
Make/FREE/T/N=(numEntries) results
622+
Multithread results[] = CheckDimensionLabels(waveRef[p])
623+
624+
if(HasOneValidEntry(results))
625+
WAVE/Z indizes = FindIndizes(results, col = 0, prop = PROP_NON_EMPTY)
626+
numMatches = WaveExists(indizes) ? DimSize(indizes, ROWS) : 0
627+
628+
for(i = 0; i < numMatches; i += 1)
629+
idx = indizes[i]
630+
entry = results[idx]
631+
632+
if(IsEmpty(entry))
633+
continue
634+
endif
635+
636+
sprintf text, "Wave ref wave has wave with the following invalid dimension label (invalid linear index %d): %s", idx, entry
637+
endfor
638+
endif
639+
endif
640+
641+
return msg
642+
End
643+
554644
// see tools/functionprofiling.sh
555645
Function DEBUG_STOREFUNCTION()
556646
string funcName = GetRTStackInfo(2)

Packages/MIES/MIES_ExperimentDocumentation.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ static Function/Wave ED_FindIndizesAndRedimension(incomingKey, key, values, rowI
437437
numCols = DimSize(incomingKey, COLS)
438438
for(i = 0; i < numCols; i += 1)
439439
searchStr = incomingKey[0][i]
440-
ASSERT(!isEmpty(searchStr), "Incoming key can not be empty")
441440

442441
FindValue/TXOP=4/TEXT=(searchStr) key
443442
col = floor(V_value / numKeyRows)
@@ -449,6 +448,7 @@ static Function/Wave ED_FindIndizesAndRedimension(incomingKey, key, values, rowI
449448
sprintf msg, "Found key \"%s\" from incoming column %d in key column %d", incomingKey[0][i], i, idx
450449
DEBUGPRINT(msg)
451450
else
451+
ASSERT(IsValidLiberalObjectName(searchStr), "Incoming key is not a valid liberal object name: " + searchStr)
452452
idx = numKeyCols + numAdditions
453453
EnsureLargeEnoughWave(key, minimumSize=idx, dimension=COLS)
454454
key[0, lastValidIncomingKeyRow][idx] = incomingKey[p][i]

Packages/MIES/MIES_StimsetAPI.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ End
165165
static Function/S ST_ParameterStringValues(string entry)
166166
// translate passed string values which are numeric internally
167167
// WBP_GetDeltaModes() WBP_GetNoiseTypes() WBP_GetNoiseBuildResolution() WBP_GetTriggerTypes() WBP_GetPulseTypes()
168-
Make/FREE/T translateableEntries = {"^.* op$", "Noise Type: White, Pink, Brown", "Build resolution (index)", "Trigonometric function Sin/Cos", "Pulse train type (index)"}
168+
Make/FREE/T translateableEntries = {"^.* op$", "Noise Type [White, Pink, Brown]", "Build resolution (index)", "Trigonometric function Sin/Cos", "Pulse train type (index)"}
169169

170170
if(GrepString(entry, translateableEntries[0]))
171171
return WBP_GetDeltaModes()

Packages/MIES/MIES_Utilities.ipf

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,11 +3422,21 @@ End
34223422

34233423
/// @brief Check if a name for an object adheres to the strict naming rules
34243424
///
3425-
/// @see `DisplayHelpTopic "ObjectName"`
3426-
threadsafe Function IsValidObjectName(name)
3427-
string name
3425+
/// @see `DisplayHelpTopic "Standard Object Names"`
3426+
threadsafe Function IsValidObjectName(string name)
3427+
return NameChecker(name, 0)
3428+
End
3429+
3430+
/// @brief Check if a name for an object adheres to the liberal naming rules
3431+
///
3432+
/// @see `DisplayHelpTopic "Liberal Object Names"`
3433+
threadsafe Function IsValidLiberalObjectName(string name)
3434+
return NameChecker(name, 1)
3435+
End
34283436

3429-
return !cmpstr(name, CleanupName(name, 0, MAX_OBJECT_NAME_LENGTH_IN_BYTES))
3437+
threadsafe static Function NameChecker(string name, variable liberal)
3438+
// @todo remove the IsEmpty check once this is resolved upstream.
3439+
return !IsEmpty(name) && !cmpstr(name, CleanupName(name, !!liberal, MAX_OBJECT_NAME_LENGTH_IN_BYTES))
34303440
End
34313441

34323442
/// @brief Find an integer `x` which is larger than `a` but the

0 commit comments

Comments
 (0)