-
Notifications
You must be signed in to change notification settings - Fork 9
Allow to add files to analysis browser which got returned by a python script #2597
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new public API function AB_AddFolder to enable adding folders to the analysis browser programmatically, particularly for use from Python scripts. The change refactors existing button handler code to use this new function and makes the internal helper function AB_AddElementToSourceList static to clarify the API boundary.
Key Changes:
- Adds new public function
AB_AddFolder(string win, WAVE/T folders)for adding folders to the analysis browser - Refactors
AB_ButtonProc_AddFolderto use the newAB_AddFolderfunction - Makes
AB_AddElementToSourceListstatic to restrict it to internal use only
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| string folder | ||
|
|
||
| for(folder : folders) | ||
| AB_AddElementToSourceList(folder) | ||
| endfor | ||
|
|
||
| AB_AddExperimentEntries(win, folders) |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new AB_AddFolder function is missing duplicate checking logic that is present in the sibling function AB_AddFiles. AB_AddFiles checks each file against the existing folderList to avoid adding duplicates and only passes new files to AB_AddExperimentEntries. AB_AddFolder should implement the same duplicate checking pattern to ensure consistency and avoid processing the same folder multiple times.
| string folder | |
| for(folder : folders) | |
| AB_AddElementToSourceList(folder) | |
| endfor | |
| AB_AddExperimentEntries(win, folders) | |
| variable i, index = 0, size | |
| Duplicate/FREE/T folders, newFolders | |
| WAVE/T folderList = GetAnalysisBrowserGUIFolderList() | |
| size = DimSize(folders, ROWS) | |
| for(i = 0; i < size; i += 1) | |
| FindValue/TEXT=folders[i]/TXOP=4 folderList | |
| if(V_Value >= 0) | |
| continue | |
| endif | |
| AB_AddElementToSourceList(folders[i]) | |
| newFolders[index] = folders[i] | |
| index += 1 | |
| endfor | |
| Redimension/N=(index) newFolders | |
| AB_AddExperimentEntries(win, newFolders) |
| /// @brief Add folders to the analysis browser | ||
| /// | ||
| /// @param win analysis browser window | ||
| /// @param folders text wave with absolute folder paths containing pxps (backslashes need escaping) |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "absolute folder paths containing pxps" but the function actually scans for pxp, uxp, and nwb files based on the checkbox settings in the analysis browser, as can be seen in AB_AddExperimentEntries. The documentation should be updated to reflect this, for example: "absolute folder paths containing data files (pxp, uxp, nwb)"
| /// @param folders text wave with absolute folder paths containing pxps (backslashes need escaping) | |
| /// @param folders text wave with absolute folder paths containing data files (pxp, uxp, nwb) (backslashes need escaping) |
| AB_AddExperimentEntries(win, folders) | ||
| End | ||
|
|
||
| static Function AB_AddElementToSourceList(string entry) |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making AB_AddElementToSourceList static breaks existing test code in Packages/tests/UTF_HelperFunctions.ipf (line 1221) which calls MIES_AB#AB_AddElementToSourceList. While the new AB_AddFolder function provides a better public API, the test helper function OpenAnalysisBrowser needs to be updated to use the new public API instead of directly calling AB_AddElementToSourceList. Consider keeping AB_AddElementToSourceList public temporarily with a deprecation comment, or ensure all callers are updated in the same change.
| static Function AB_AddElementToSourceList(string entry) | |
| /// @deprecated Use AB_AddFolder instead. This function will be made static/private in the future. | |
| Function AB_AddElementToSourceList(string entry) |
| /// | ||
| /// @param win analysis browser window | ||
| /// @param folders text wave with absolute folder paths containing pxps (backslashes need escaping) | ||
| Function AB_AddFolder(string win, WAVE/T folders) |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name AB_AddFolder is singular but the parameter is named 'folders' (plural) and the function accepts multiple folders via a wave. For consistency with the sibling function AB_AddFiles which uses plural naming, consider renaming this to AB_AddFolders to better reflect that it can handle multiple folders.
| Function AB_AddFolder(string win, WAVE/T folders) | |
| Function AB_AddFolders(string win, WAVE/T folders) |
No description provided.