Skip to content

Commit

Permalink
Merge pull request #2091 from AllenInstitute/feature/2091-various
Browse files Browse the repository at this point in the history
Various minor changes from other PRs
  • Loading branch information
t-b authored Apr 21, 2024
2 parents a8ca5fe + 1a2d6b0 commit 1747f22
Show file tree
Hide file tree
Showing 22 changed files with 254 additions and 107 deletions.
29 changes: 15 additions & 14 deletions Packages/MIES/MIES_AnalysisBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ static Function AB_GUIRowIsStimsetsOnly(variable row)
End

/// @returns 0 if at least one sweep or stimset could be loaded, 1 otherwise
static Function AB_LoadFromExpandedRange(variable row, variable subSectionColumn, variable AB_LoadType, [variable overwrite, DFREF sweepBrowserDFR, WAVE/T dfCollect])
static Function AB_LoadFromExpandedRange(variable row, variable subSectionColumn, variable loadType, [variable overwrite, DFREF sweepBrowserDFR, WAVE/T dfCollect])

variable j, endRow, mapIndex, sweep, oneValidLoad, index
string device, discLocation, dataFolder, fileName, fileType
Expand All @@ -1563,7 +1563,7 @@ static Function AB_LoadFromExpandedRange(variable row, variable subSectionColumn
for(j = row; j < endRow; j += 1)

if(AB_GUIRowIsStimsetsOnly(row))
if(AB_LoadType != AB_LOAD_STIMSET)
if(loadType != AB_LOAD_STIMSET)
return 1
endif
device = ""
Expand All @@ -1589,7 +1589,7 @@ static Function AB_LoadFromExpandedRange(variable row, variable subSectionColumn
fileType = map[mapIndex][%FileType]
fileName = map[mapIndex][%FileName]

switch(AB_LoadType)
switch(loadType)
case AB_LOAD_STIMSET:
if(AB_LoadStimsetFromFile(discLocation, dataFolder, fileType, device, sweep, overwrite = overwrite) == 1)
continue
Expand Down Expand Up @@ -1641,14 +1641,14 @@ static Function AB_GetRowWithNextTreeView(selWave, startRow, col)
return numRows
End

static Function AB_LoadFromFile(AB_LoadType, [sweepBrowserDFR])
variable AB_LoadType
static Function AB_LoadFromFile(loadType, [sweepBrowserDFR])
variable loadType
DFREF sweepBrowserDFR

variable mapIndex, sweep, numRows, i, row, overwrite, oneValidLoad, index
string dataFolder, fileName, discLocation, fileType, device

if(AB_LoadType == AB_LOAD_SWEEP)
if(loadType == AB_LOAD_SWEEP)
ASSERT(!ParamIsDefault(sweepBrowserDFR), "create sweepBrowser DataFolder with SB_OpenSweepBrowser() prior")
ASSERT(IsGlobalDataFolder(sweepBrowserDFR), "sweepBrowser DataFolder does not exist")
endif
Expand All @@ -1669,23 +1669,23 @@ static Function AB_LoadFromFile(AB_LoadType, [sweepBrowserDFR])
row = indizes[i]

// handle not expanded EXPERIMENT and DEVICE COLUMNS
switch(AB_LoadType)
switch(loadType)
case AB_LOAD_STIMSET:
if(!AB_LoadFromExpandedRange(row, EXPERIMENT_TREEVIEW_COLUMN, AB_LoadType, overwrite = overwrite))
if(!AB_LoadFromExpandedRange(row, EXPERIMENT_TREEVIEW_COLUMN, loadType, overwrite = overwrite))
oneValidLoad = 1
continue
endif
if(!AB_LoadFromExpandedRange(row, DEVICE_TREEVIEW_COLUMN, AB_LoadType, overwrite = overwrite))
if(!AB_LoadFromExpandedRange(row, DEVICE_TREEVIEW_COLUMN, loadType, overwrite = overwrite))
oneValidLoad = 1
continue
endif
break
case AB_LOAD_SWEEP:
if(!AB_LoadFromExpandedRange(row, EXPERIMENT_TREEVIEW_COLUMN, AB_LoadType, sweepBrowserDFR = sweepBrowserDFR, overwrite = overwrite, dfCollect = dfCollect))
if(!AB_LoadFromExpandedRange(row, EXPERIMENT_TREEVIEW_COLUMN, loadType, sweepBrowserDFR = sweepBrowserDFR, overwrite = overwrite, dfCollect = dfCollect))
oneValidLoad = 1
continue
endif
if(!AB_LoadFromExpandedRange(row, DEVICE_TREEVIEW_COLUMN, AB_LoadType, sweepBrowserDFR = sweepBrowserDFR, overwrite = overwrite, dfCollect = dfCollect))
if(!AB_LoadFromExpandedRange(row, DEVICE_TREEVIEW_COLUMN, loadType, sweepBrowserDFR = sweepBrowserDFR, overwrite = overwrite, dfCollect = dfCollect))
oneValidLoad = 1
continue
endif
Expand All @@ -1706,7 +1706,7 @@ static Function AB_LoadFromFile(AB_LoadType, [sweepBrowserDFR])
discLocation = map[mapIndex][%DiscLocation]
fileType = map[mapIndex][%FileType]

switch(AB_LoadType)
switch(loadType)
case AB_LOAD_STIMSET:
if(AB_LoadStimsetFromFile(discLocation, dataFolder, fileType, device, sweep, overwrite = overwrite))
continue
Expand Down Expand Up @@ -2684,6 +2684,7 @@ Function AB_BrowserStartupSettings()

HideTools/W=$panel/A
SetWindow $panel, userData(panelVersion)=""
SetWindow $panel, userData(datafolder)=""

SetCheckBoxState(panel, "checkbox_load_overwrite", CHECKBOX_UNSELECTED)

Expand All @@ -2692,8 +2693,8 @@ Function AB_BrowserStartupSettings()
SearchForInvalidControlProcs(panel)
print "Do not forget to increase ANALYSISBROWSER_PANEL_VERSION."

ListBox list_experiment_contents, win=$panel, listWave=$"", selWave=$""
ListBox listbox_AB_Folders, win=$panel, listWave=$"", selWave=$""
ListBox list_experiment_contents, win=$panel, listWave=$"", selWave=$"", colorWave=$""
ListBox listbox_AB_Folders, win=$panel, listWave=$"", selWave=$"", colorWave=$""

Execute/P/Z "DoWindow/R " + panel
Execute/P/Q/Z "COMPILEPROCEDURES "
Expand Down
5 changes: 1 addition & 4 deletions Packages/MIES/MIES_AnalysisBrowser_Macro.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ Window AnalysisBrowser() : Panel
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)=A"!!,FS!!#97!!#E85QF.Xz!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
ListBox listbox_AB_Folders, userdata(ResizeControlsInfo)+=A"zzz!!#u:Du]k<zzzzzzzzzzzzzz!!!"
ListBox listbox_AB_Folders, labelBack=(65535, 65535, 65535)
ListBox listbox_AB_Folders, colorWave=root:MIES:Analysis:AnaBrowserFolderColors
ListBox listbox_AB_Folders, mode=4
ListBox listbox_AB_Folders, labelBack=(65535, 65535, 65535), mode=4
Button button_AB_AddFolder, pos={7.00, 5.00}, size={100.00, 25.00}, proc=AB_ButtonProc_AddFolder
Button button_AB_AddFolder, title="Add folder"
Button button_AB_AddFolder, help={"Add a new folder to the list"}
Expand Down Expand Up @@ -128,6 +126,5 @@ Window AnalysisBrowser() : Panel
SetWindow kwTopWin, userdata(ResizeControlsGuides)="splitGuide;UGVL;"
SetWindow kwTopWin, userdata(ResizeControlsInfosplitGuide)="NAME:splitGuide;WIN:AnalysisBrowser;TYPE:User;HORIZONTAL:1;POSITION:10.00;GUIDE1:FT;GUIDE2:;RELPOSITION:10;"
SetWindow kwTopWin, userdata(ResizeControlsInfoUGVL)="NAME:UGVL;WIN:AnalysisBrowser;TYPE:User;HORIZONTAL:0;POSITION:15.00;GUIDE1:FL;GUIDE2:;RELPOSITION:15;"
SetWindow kwTopWin, userdata(datafolder)="workFolder"
Execute/Q/Z "SetWindow kwTopWin sizeLimit={855,573,inf,inf}" // sizeLimit requires Igor 7 or later
EndMacro
18 changes: 9 additions & 9 deletions Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ End
///
/// And as usual we want the *last* matching sweep.
///
/// @return existing sweep number or -1 in case no such sweep could be found
/// @return existing sweep number or INVALID_SWEEP_NUMBER in case no such sweep could be found
static Function PSQ_GetLastPassingLongRHSweep(string device, variable headstage, variable duration)
string key
variable i, j, setSweep, numSetSweeps, numEntries, sweepNo, setQC, numPassingSweeps
Expand All @@ -1461,7 +1461,7 @@ static Function PSQ_GetLastPassingLongRHSweep(string device, variable headstage,
WAVE/Z sweeps = GetSweepsWithSetting(numericalValues, key)

if(!WaveExists(sweeps))
return -1
return INVALID_SWEEP_NUMBER
endif

// sweeps hold all which have a Set QC entry
Expand Down Expand Up @@ -1501,7 +1501,7 @@ static Function PSQ_GetLastPassingLongRHSweep(string device, variable headstage,
endfor
endfor

return -1
return INVALID_SWEEP_NUMBER
End

static Function PSQ_DS_IsValidMode(string str)
Expand All @@ -1524,7 +1524,7 @@ static Function PSQ_GetLastPassingDAScale(string device, variable headstage, str
WAVE/Z sweeps = GetSweepsWithSetting(numericalValues, key)

if(!WaveExists(sweeps))
return -1
return INVALID_SWEEP_NUMBER
endif

numEntries = DimSize(sweeps, ROWS)
Expand All @@ -1548,7 +1548,7 @@ static Function PSQ_GetLastPassingDAScale(string device, variable headstage, str
endif
endfor

return -1
return INVALID_SWEEP_NUMBER
End

/// @brief Return the sweep number of the last sweep using the PSQ_TrueRestingMembranePotential()
Expand All @@ -1564,7 +1564,7 @@ static Function PSQ_GetLastPassingTrueRMP(string device, variable headstage)
WAVE/Z sweeps = GetSweepsWithSetting(numericalValues, key)

if(!WaveExists(sweeps))
return -1
return INVALID_SWEEP_NUMBER
endif

numEntries = DimSize(sweeps, ROWS)
Expand All @@ -1581,13 +1581,13 @@ static Function PSQ_GetLastPassingTrueRMP(string device, variable headstage)
return sweepNo
endfor

return -1
return INVALID_SWEEP_NUMBER
End

/// @brief Return the DAScale offset for PSQ_DaScale()
///
/// @return DAScale value in pA or NaN on error
Function PSQ_DS_GetDAScaleOffset(device, headstage, opMode)
static Function PSQ_DS_GetDAScaleOffset(device, headstage, opMode)
string device, opMode
variable headstage

Expand Down Expand Up @@ -1620,7 +1620,7 @@ End
///
/// @return 1 if found at least one, zero if none and `NaN` if no such entry
/// could be found
Function PSQ_FoundAtLeastOneSpike(device, sweepNo)
static Function PSQ_FoundAtLeastOneSpike(device, sweepNo)
string device
variable sweepNo

Expand Down
17 changes: 9 additions & 8 deletions Packages/MIES/MIES_BrowserSettingsPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ End
Function/S BSP_GetSFHELP(mainPanel)
string mainPanel

return BSP_GetPanel(mainPanel) + "#" + EXT_PANEL_SF_HELP
string helpNotebook

helpNotebook = BSP_GetPanel(mainPanel) + "#" + EXT_PANEL_SF_HELP
BSP_UpdateHelpNotebook(helpNotebook)

return helpNotebook
End

/// @brief Inits controls of BrowserSettings side Panel
Expand Down Expand Up @@ -238,8 +243,6 @@ Function BSP_DynamicStartupSettings(mainPanel)

BSP_InitMainCheckboxes(bsPanel)

BSP_UpdateHelpNotebook(mainPanel)

shPanel = LBV_GetSettingsHistoryPanel(mainPanel)

if(BSP_IsDataBrowser(mainPanel))
Expand Down Expand Up @@ -1038,14 +1041,12 @@ End

/// @brief Fill the SweepFormula help notebook
/// with the contents of the stored file
Function BSP_UpdateHelpNotebook(win)
string win
Function BSP_UpdateHelpNotebook(string helpNotebook)

variable helpVersion
string name, text, helpNotebook, path
string name, text, path

helpNotebook = BSP_GetSFHELP(win)
text = GetNotebookText(helpNotebook, mode = 2)
text = GetNotebookText(helpNotebook, mode = 2)

if(!IsEmpty(text))
return NaN
Expand Down
21 changes: 21 additions & 0 deletions Packages/MIES/MIES_Cache.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,27 @@ threadsafe Function/S CA_IgorInfoKey(variable selector)
endswitch
End

/// @brief Return the key for the filled labnotebook parameter names
Function/S CA_GetLabnotebookNamesKey(WAVE/T/Z textualValues, WAVE/T/Z numericalValues)

string key = ""
variable crc

if(WaveExists(textualValues))
key += GetWavesDataFolder(textualValues, 2)
key += num2istr(WaveModCountWrapper(textualValues))
endif

if(WaveExists(numericalValues))
key += GetWavesDataFolder(numericalValues, 2)
key += num2istr(WaveModCountWrapper(numericalValues))
endif

ASSERT(!IsEmpty(key), "key can't be empty")

return "Version 1:" + Hash(key, HASH_SHA2_256)
End

/// @}

/// @brief Make space for one new entry in the cache waves
Expand Down
4 changes: 3 additions & 1 deletion Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Constant DAQ_CONFIG_WAVE_VERSION = 3
Constant DA_EPHYS_PANEL_VERSION = 64
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 50
Constant WAVEBUILDER_PANEL_VERSION = 14
Constant ANALYSISBROWSER_PANEL_VERSION = 4
Constant ANALYSISBROWSER_PANEL_VERSION = 5

/// Version of the stimset wave note
Constant STIMSET_NOTE_VERSION = 11
Expand Down Expand Up @@ -2244,3 +2244,5 @@ StrConstant DF_NAME_FREE = "freeroot"
StrConstant DF_NAME_MIES = "MIES"

Constant SUTTER_MAX_MAX_TP_PULSES = 10000

Constant INVALID_SWEEP_NUMBER = -1
4 changes: 4 additions & 0 deletions Packages/MIES/MIES_ExperimentDocumentation.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,14 @@ static Function ED_createAsyncWaveNoteTags(device, sweepCount)
asyncSettingsWave[0][%AlarmState][INDEP_HEADSTAGE] = alarmState

if(alarmEnabled && alarmState)

#ifndef AUTOMATED_TESTING
beep
print time() + " !!!!!!!!!!!!! " + title + " has exceeded max/min settings" + " !!!!!!!!!!!!!"
ControlWindowToFront()
beep
#endif // AUTOMATED_TESTING

redoLastSweep = 1
endif

Expand Down
46 changes: 45 additions & 1 deletion Packages/MIES/MIES_GuiUtilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,50 @@ End
Function [STRUCT RGBColor s] GetTraceColorForAverage()

[s] = GetTraceColor(NUM_HEADSTAGES + 1)

End

/// @brief Get colors from alternative color scheme
///
/// Uses 8 colors with maximum contrast for colorblind people, see
/// https://www.wavemetrics.com/code-snippet/distinguishable-color-index and
/// https:// jfly.iam.u-tokyo.ac.jp/color/
///
/// @sa GetTraceColor
Function [STRUCT RGBColor s] GetTraceColorAlternative(variable index)

index = mod(index, 8)

switch(index)
case 0:
s.red = 0; s.green = 0; s.blue = 0
break
case 1:
s.red = 59110; s.green = 40863; s.blue = 0
break
case 2:
s.red = 22102; s.green = 46260; s.blue = 59881
break
case 3:
s.red = 0; s.green = 40606; s.blue = 29555
break
case 4:
s.red = 61680; s.green = 58596; s.blue = 16962
break
case 5:
s.red = 0; s.green = 29298; s.blue = 45746
break
case 6:
s.red = 54741; s.green = 24158; s.blue = 0
break
case 7:
s.red = 52428; s.green = 31097; s.blue = 42919
break
default:
ASSERT(0, "Invalid index")
endswitch

return [s]
End

/// @brief Query the axis minimum and maximum values
Expand Down Expand Up @@ -2352,7 +2396,7 @@ Function ColorNotebookKeywords(string win, string keyWord, variable r, variable
Notebook $win, findText={"", 0}

do
Notebook $win, findText={keyWord, 6}
Notebook $win, findText={keyWord, 2^0 + 2^2}
if(V_flag == 1)
Notebook $win, textRGB=(r, g, b)
endif
Expand Down
Loading

0 comments on commit 1747f22

Please sign in to comment.