Skip to content

Commit

Permalink
Merge pull request #2061 from AllenInstitute/feature/2061-sf-labnoteb…
Browse files Browse the repository at this point in the history
…ook-anafuncparam

Rework SF labnotebook and add anaFuncParam
  • Loading branch information
t-b authored Oct 19, 2024
2 parents 7d6c223 + 0f68cff commit f98d439
Show file tree
Hide file tree
Showing 18 changed files with 1,097 additions and 210 deletions.
25 changes: 1 addition & 24 deletions Packages/MIES/MIES_AnalysisBrowser_SweepBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Function/DF SB_GetSweepDataFolder(WAVE/T sweepMap, [variable sweepNo, variable i
return GetAnalysisSweepPath(dataFolder, device)
End

static Function/DF SB_GetSweepDataPathFromIndex(sweepBrowserDFR, mapIndex)
Function/DF SB_GetSweepDataPathFromIndex(sweepBrowserDFR, mapIndex)
DFREF sweepBrowserDFR
variable mapIndex

Expand Down Expand Up @@ -722,26 +722,3 @@ Function/WAVE SB_GetSweepMap(string win)

return sweepMap
End

Function [WAVE/Z numericalValues, WAVE/Z textualValues] SB_GetLabNotebooks(WAVE/T sweepMap, variable mapIndex)

string dataFolder, device

dataFolder = sweepMap[mapIndex][%DataFolder]
device = sweepMap[mapIndex][%Device]
WAVE/Z numericalValues = GetAnalysLBNumericalValues(dataFolder, device)
WAVE/Z textualValues = GetAnalysLBTextualValues(dataFolder, device)

return [numericalValues, textualValues]
End

Function/DF SB_GetSweepDF(string win, variable mapIndex)

ASSERT(BSP_IsSweepBrowser(win), "Requires window to be a SweepBrowser")

WAVE/T sweepMap = SB_GetSweepMap(win)
DFREF deviceDFR = SB_GetSweepDataFolder(sweepMap, index = mapIndex)
DFREF sweepDFR = GetSingleSweepFolder(deviceDFR, str2num(sweepMap[mapIndex][%Sweep]))

return sweepDFR
End
49 changes: 49 additions & 0 deletions Packages/MIES/MIES_AnalysisFunctionHelpers.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,55 @@ Function AFH_AddAnalysisParameter(string setName, string name, [variable var, st
endif
End

/// @brief Add an analysis parameter to the given `params` string
///
/// Exactly one of `var`/`str`/`wv` must be given.
///
/// @param[in, out] params stimset name
/// @param[in] name name of the parameter
/// @param[in] var [optional] numeric parameter
/// @param[in] str [optional] string parameter
/// @param[in] wv [optional] wave parameter can be numeric or text
Function AFH_AddAnalysisParameterToParams(string &params, string name, [variable var, string str, WAVE wv])

string type, value

ASSERT(ParamIsDefault(var) + ParamIsDefault(str) + ParamIsDefault(wv) == 2, "Expected one of var, str or wv")

if(!ParamIsDefault(var))
type = "variable"
// numbers never need URL encoding
value = num2str(var)
elseif(!ParamIsDefault(str))
type = "string"
value = URLEncode(str)
elseif(!ParamIsDefault(wv))
ASSERT(DimSize(wv, ROWS) > 0, "Expected non-empty wave")
if(IsTextWave(wv))
type = "textwave"
Duplicate/T/FREE wv, wvText
wvText = UrlEncode(wvText)
value = TextWaveToList(wvText, "|")
else
type = "wave"
// numbers never need URL encoding
value = NumericWaveToList(wv, "|", format = "%.15g")
endif
endif

ASSERT(AFH_IsValidAnalysisParameter(name), "Name is not a legal non-liberal igor object name")
ASSERT(!GrepString(value, "[=:,;]+"), "Broken URL encoding. Written entry contains invalid characters (one of `=:,;`)")
ASSERT(AFH_IsValidAnalysisParamType(type), "Invalid type")

#ifndef AUTOMATED_TESTING
if(WhichListItem(name, AFH_GetListOfAnalysisParamNames(params)) != -1)
printf "Parameter \"%s\" is already present and will be overwritten!\r", name
endif
#endif

params = ReplaceStringByKey(name, params, type + "=" + value, ":", ",", 0)
End

/// @brief Return a stringified version of the analysis parameter value
///
/// @param name name of the parameter
Expand Down
19 changes: 16 additions & 3 deletions Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2050,11 +2050,14 @@ StrConstant SF_META_AVERAGED_FIRST_SWEEP = "/AveragedFirstSweep" // number
StrConstant SF_META_XVALUES = "/XValues" // numeric wave
StrConstant SF_META_XTICKLABELS = "/XTickLabels" // text wave
StrConstant SF_META_XTICKPOSITIONS = "/XTickPositions" // numeric wave
StrConstant SF_META_YTICKLABELS = "/YTickLabels" // text wave
StrConstant SF_META_YTICKPOSITIONS = "/YTickPositions" // numeric wave
StrConstant SF_META_XAXISLABEL = "/XAxisLabel" // string
StrConstant SF_META_YAXISLABEL = "/YAxisLabel" // string
StrConstant SF_META_LEGEND_LINE_PREFIX = "/LegendLinePrefix" // string
StrConstant SF_META_TAG_TEXT = "/TagText" // string
StrConstant SF_META_OPSTACK = "/OperationStack" // string
StrConstant SF_META_MOD_MARKER = "/Marker" // numeric wave
StrConstant SF_META_MOD_MARKER = "/Marker" // numeric wave (per point) or number (all points)
StrConstant SF_META_SHOW_LEGEND = "/ShowLegend" // numeric, boolean, defaults to true (1)
StrConstant SF_META_CUSTOM_LEGEND = "/CustomLegend" // string with custom legend text, honours /ShowLegend
StrConstant SF_META_ARGSETUPSTACK = "/ArgSetupStack" // string
Expand All @@ -2063,9 +2066,18 @@ StrConstant SF_META_LINESTYLE = "/LineStyle" // number
StrConstant SF_META_TRACE_MODE = "/TraceMode" // number
StrConstant SF_META_TRACETOFRONT = "/TraceToFront" // number, boolean, defaults to false (0)
StrConstant SF_META_DONOTPLOT = "/DoNotPlot" // number, boolean, defaults to false (0)
StrConstant SF_META_WINDOW_HOOK = "/WindowHook" // string

/// A color group allows to have matching colors for sweep data with the same channel type/number and sweep.
/// It is applied before the matching headstage/average colors in #SF_GetTraceColor().
///
/// To use the feature set SF_META_COLOR_GROUP for traces to a unique integer,
/// see GetUniqueInteger(). All traces with the same integer are considered to
/// be in the same group. A list of supported operations is in #SF_GetTraceColor().
StrConstant SF_META_COLOR_GROUP = "/ColorGroup" // number

StrConstant SF_META_USER_GROUP = "/User/" // custom metadata for individual operations, top-level group with individual entries

StrConstant SF_META_USER_GROUP = "/User/" // custom metadata for individual operations,
// top-level group with individual entries
StrConstant SF_META_FIT_COEFF = "FitCoefficients"
StrConstant SF_META_FIT_SIGMA = "FitSigma"
StrConstant SF_META_FIT_PARAMETER = "FitParameter"
Expand Down Expand Up @@ -2111,6 +2123,7 @@ StrConstant SF_DATATYPE_SELECTSETCYCLECOUNT = "SelectSetCycleCount"
StrConstant SF_DATATYPE_SELECTSETSWEEPCOUNT = "SelectSetSweepCount"
StrConstant SF_DATATYPE_SELECTSCIINDEX = "SelectSCIIndex"
StrConstant SF_DATATYPE_SELECTRACINDEX = "SelectRACIndex"
StrConstant SF_DATATYPE_ANAFUNCPARAM = "AnaFunc"

StrConstant SF_WREF_MARKER = "\"WREF@\":"
StrConstant SF_VARIABLE_MARKER = "/SF_IsVariable" // numeric
Expand Down
20 changes: 20 additions & 0 deletions Packages/MIES/MIES_GuiUtilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,26 @@ Function RestoreAnnotationPositions(string graph, WAVE/T annoInfo)
endfor
End

/// @brief Remove the annotations given by the `regexp` from annoInfo and return the filtered wave
Function/WAVE FilterAnnotations(WAVE/T annoInfo, string regexp)

variable i, numEntries
string name

Duplicate/FREE/T annoInfo, annoInfoResult
WaveClear annoInfo

numEntries = DimSize(annoInfoResult, ROWS)
for(i = numEntries - 1; i >= 0; i -= 1)
name = GetDimLabel(annoInfoResult, ROWS, i)
if(GrepString(name, regexp))
DeletePoints/M=(ROWS) i, 1, annoInfoResult
endif
endfor

return annoInfoResult
End

/// @brief Autoscale all vertical axes in the visible x range
Function AutoscaleVertAxisVisXRange(graph)
string graph
Expand Down
16 changes: 16 additions & 0 deletions Packages/MIES/MIES_MiesUtilities_Logbook.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2017,3 +2017,19 @@ Function [variable type, variable waMode, variable headstage] GetAnalysisFunctio

return [type, waMode, headstage]
End

Function ParseLogbookMode(string modeText)

strswitch(modeText)
case "UNKNOWN_MODE":
return UNKNOWN_MODE
case "DATA_ACQUISITION_MODE":
return DATA_ACQUISITION_MODE
case "TEST_PULSE_MODE":
return TEST_PULSE_MODE
case "NUMBER_OF_LBN_DAQ_MODES":
return NUMBER_OF_LBN_DAQ_MODES
endswitch

ASSERT(0, "Unsupported labnotebook mode")
End
Loading

0 comments on commit f98d439

Please sign in to comment.