Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic EEG localization and labelling using Revopoint 3D (#716)
* initial commit: enable importing wavefront obj files into brainstorm * refactoring: add input checks, remove unwanted code * add 'Color' field to the surfacemat structure templates * add check for 'Color' field * Update menu: 'Digitizer' and 'Revopoint' under the bracket 'Digitize' * Refactor 'panel_digitize' to add conditions for 'Revopoint' * support visualizing per vertex color for imported OBJ mesh in BST * continued: enable importing wavefront obj files into brainstorm * External added: Piotr Image and Video Toolbox (https://github.com/pdollar/toolbox) required for warping and interpolating points on EEG cap * deface a 3D mesh * Tag imported mesh with color as 'textured' * Handle displaying a 'textured' mesh * Key 'c' as shortcut for collecting points from Revopoint mesh * Refactor importing wafefront obj - it is always going to be a meshed OBJ so 'FileType' parameter is unnecessary - renamed 'tri' as 'faces' - renamed 'pos' as 'vertices' * handle mesh without texture information * Update comment * intial commit: automatic detection and labelling of EEG cap electrodes * custom layout EEG caps - ANT 65 is a modeifed version of ANT Waveguard 64 - Acticap 66 is a modified version of Acticap 65 * configure 'Edit Settings' options for Revopoint * Option to generate 100 random headpoints to be used for registration to MRI * fix typo bugs introduced in 3066842 * 'AddMontage' function modified to handle adding Channel File as montage * WIP: Handle ANT Waveguard 65 and Acticap 66 EEG caps Needs work on a more generic approach to handle different EEG caps * updated comment (file description) * updated cap type * typo in file name * Update Color for 'textured' mesh when downsized/downsampled * Update comments on ways to add montage * Update panel_digitize.m - Limit display of 'Auto' and 'Random' buttons for Revopoint only - Correct display order of EEG labels based on the initialization labels required as per the EEG cap - Removed unwanted code for sketch points (was used for debugging) - Creating montages from EEG cap layout mat files (only for Revopoint) * load the latest (last updated) mesh to work on * add to 1b3e2c8 * adding montage from text files only available for Polhemus * better handling of saving ChannelFile info to DigitizeOptions * removing 'Color' fields from template To be added only when needed * 'Color' field added to surface when needed * remove commented code * Handle updating surface color for 'Views' menu option on 3D figure * making sure old naming in UI is intact for 'Digitize' * handle 'Edit Settings' for Revopoint * mask unwanted menu items for Revopoint * 'DelimitedTextImportOptions' support for R2016b to R2018a * code cleanup and reduce ambiguity * ignore 'rmoutliers' step for < R2018b * remove default menu size 12 for EEG cap montages * support new panel calls in the legacy panel; some code cleanup * adding revopoint changes to the new panel (1) and its dependencies * manual point collection in new panel for revopoint * new panel: collecting 100 random head points * legacy panel: reverting adding montage from text files * legacy panel: refactor montage selection in menu for Revopoint * new panel: montage menu refactoring for Revopoint * new panel: revopoint automation for detecting and labeling electrodes * new panel: refactor 'Edit_Settings' menu to handle Revopoint options * new panel: allow updating a specific EEG electrode from the coordinate list manually * new panel: remove unused variable * new panel: handle enable/disable of the 'Auto' and 'Random' buttons * new panel: User warning if 'Auto' button pressed without initialization points * new panel: use `Digitize.Type` to define the mode used * legacy panel: handle 'Auto' and 'Random' visibility; some code cleanup * new and legacy panel: rename `Revopoint` to `3DScanner` for better generalization * Bugfix: support old `Digitize.Options.Montages` struct * GUI menu name updated: '3DScaner' to '3D scanner' * Bugfix: Two entries in `GlobalData.Surface` were created instead of one * Implement `rmoutliers` without arguments for older Matlab versions * Ignore unused output arguments * Refactor to avoid unnecessary reads to db: `bst_get('Subject')` * Gentle exit if user cancels "Import surfaces..." * Clean code. Avoid copy-paste * Cleaner * Add `Color` field for all surface files and loaded surfaces - Avoid different versions of surfaces files and loaded surfaces - Avoid many checks for `Color` field * Treecallback for Display texture surface - Right-click > Display has same behaviour as double-click - Do not load surface on right-click, that slows the popup menu display * Bugfix typo * Avoid copy-paste same method call * Parse input in `panel_digitize_2024('Start')` * Not apparent reason to have a different panel name * Add progress bar to 'EEGAutoDetectElectrodes' * Parse input in `panel_digitize('Start')` See: 3d77e53 * Refactor to avoid unnecessary reads to db: `bst_get('Subject')` See 1c2c2b0 * Not apparent reason to have a different panel name See 8d6bc3b * Code easier to read * Bugfix * Remove unnecessary FOR loops * handle `Digitize` as input to `DigitizerType` parameter * Revert "handle `Digitize` as input to `DigitizerType` parameter" This reverts commit 53f43dd. * Better handling of calls to `Start` function recommended here: #716 (comment) * No scaling needed as OBJ vertices are unitless * new panel: avoid copy pasting; add comments * function to compartmentalize automatic detection and labelling * clean code; call compartmentalized function * legacy panel: avoid copy paste sync with changes as above for the new panel * bugfix: missed some call checks * code cleanup; comments added * avoid copy/paste for `Edit settings` * add comments; clean code and calls `auto_3dscanner` * changed surface description avoid using 'head' keyword because if renamed having `head` word in it, the `node_rename` function converts the type to `Scalp`. * remove comment; `in_tess` handles node naming * handle textured surface import and selection * do not delete `3D scanner` figure when resetting * textured surface handling: allow user to choose from options The options: 1. Subject has no textured mesh or subject does not exist at all: - Import surface GUI pops up, user chooses the surface and it gets loaded 2. Subject already has 1 or more than 1 textured mesh in it then user is given an option: - Use existing - if only one mesh present then it just loads that directly; if more than one present then user is given an option to choose which one he wants to use - Add New - Import surface GUI pops up, user chooses the surface and it gets loaded - Cancel / Press (X) at any instant - cancels the process and exits * `Digitize (3D scanner)` option on right click pop up for textured surface * Better way to get the open surface details * make textured surface comments unique; show comments as choice to users to choose from - Unique comments for same textured mesh makes it easy for the user to distinguish one from the other - When user clicks 'Use existing' the list of textured surface comments pop up for the users to choose from. This is more intuitive for the user than having to choose from the filename which sits in the database. * add comments * collect 100 points without `reducepatch` * bugfix: display correct label text on deleting-updating landmark coordinates * Avoid copy-paste same method call * Fixes 128c9b0 * Clean code * for `Start over`, close and reset figure for `3D Scanner` * bugfix: Right click on subject > `Import surfaces` * better way to access the current surface file * import head surface obj with units using fieldtrip's `ft_convert_units` * legacy: better way to access the current surface file * update the correct caps based on the protocol * update landmark initialization points * add all other surface property calculations required as the updated surface will be saved to database * save the surface and update the node * check spm12 installation for `ft_convert_units` `ft_convert_units` is part of spm12/external/fieldtrip * bugfix * replace `erase` with `strrep` for backward compatibility * improve obj parsing (see description) - updated the code reference from where this was inspired - for some obj, obtained from 3D software like Maya and Blender, when parsed using 'readtable', the vertex coordinates start from the 3rd column - `refine` is a FT function to improve resolution. Using this creates a processing and loading delay which can be avoided as the scans would already be in a good resolution. * similar to `ft_convert_units` inspired by `channel_fixunits.m` * remove `fieldtrip` dependency * typo fix * generalize checking for initialization points * adding `Wearable Sensing DS-24` EEG cap layout It follows the 10-20 system with 'Fpz' as GND and 'A1, A2' as REF. * Update `channel_fixunits` to accept vertices Remove unnecessary copies of code * Simpler creation of struct (`in_tess_wftobj`) * GUI: Add feedback that surface is loading... * Simplify using already defined function handle * Simpler and meaningful variable name * Use content rather than string in filename * Cleaner diff * Unify "EditSettings" options, default values and user inputs * Correct file tag * EEG caps with landmark labels must be usable, as they allow manual loc * Add info in auto button tooltip * Enable auto button for valid caps IFF all landmarks are acquired * Update function names in `auto_3dscanner` * Move "whiteCap" out of `FindElectrodesEegCap` * Bugfix: Consider that user acquires more points than landmarks * Bugfix: Setting proper tag for textured surface file * Improve warping by using all EEG points acquired by user * Remove unnecessary sorting Landmarks and extra points are identified by name. In output the locations for EEG electrodes is get also by name * Change dots in console with progress bar * Suppress expected warnings * Remove unnecessary output: `auto_3dscanner('GetEegCapLandmarkLabels')` * Reduce perceived lag in opening figures after fiducials are set * Unify sound of clicks across platforms for source and compiled BST * Avoid copy/pasting for default EEG caps menu * for <2016b: no importing WFTOBJ and `3D scanner` option * rename `auto_3dscanner` to `channel_detect_eegcap_auto` * update description; expected units `mm` * Correct case in comments * remove unnecessary indents for cleaner diff * bugfix: `iOptionsType` was not initialized; use `num2str` for `ComPort` * bugfix: set global point index with found index * Correct case in comments * changes in `panel_digitize_2024` made to `panel_digitize` * collect random head shape points based on Brainstorm recommended way https://neuroimage.usc.edu/brainstorm/Tutorials/TutDigitize3dScanner#Collect_the_desired_number_of_head_shape_points * explicitly mention `digitize` in condition * revert `ComPort` type conversion mistook it for a number * `menu_default_eegcaps`: separate function for generating BST available EEG caps menu * extend renaming of surfaces with same filename (comments) while importing to all surfaces * Add first draft of parsing of `.wobj` text file * proper columns assigned for `vertices`, `faces` and `textureIdx` * use `regexp` to spoort older versions; only check based on `Comment` for renaming * revert back importing obj support for < R2016b * Fix indentation * Use functions in Brainstorm to: - Retrieve sSubject from MRI filename - Generate unique comment * Bugfix: return same orientation as input * Cleaner indexing * Update regexp to handle scientific notation (using e notation) * Digitize panels, do not clear settings that are not asked to the user * Allow displaying texture surfaces with "Add surface" in surface panel * use `clock` instead of `datetime` (support older MATLAB versions) * better way to get the surface file structure in `hFig` tested in R2014a: `TessInfo.hPatch` does not have the structure definitions * supress more warnings tested in R2014a: Large Radius warnings were showing up * add disclaimer to users that 'Auto' feature is experimental * Bugfix: No check required while doing manual head shape points collection * Bugfix: Update tooltip for 'Auto' button * Allow to cancel start of autodetection * Bugfix: Disable Auto button, when EXTRA are being acquired. * Bugfix: Wrong logic: `~cellfun(@isempty, ...)` results in `1` or `0` --------- Co-authored-by: rcassani <[email protected]>
- Loading branch information