{"id":16273241,"url":"https://github.com/mattansb/tbt","last_synced_at":"2025-03-19T23:31:28.214Z","repository":{"id":109915078,"uuid":"117079093","full_name":"mattansb/TBT","owner":"mattansb","description":"Reject and interpolate channels on a epoch by epoch basis (EEGLAB plugin)","archived":false,"fork":false,"pushed_at":"2022-02-02T12:44:01.000Z","size":557,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T21:55:39.030Z","etag":null,"topics":["eeg","eeglab","eeglab-plugin","tbt"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattansb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-01-11T09:31:53.000Z","updated_at":"2023-01-19T11:04:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dd68997-4bd6-4079-820d-a3206f896cce","html_url":"https://github.com/mattansb/TBT","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FTBT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FTBT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FTBT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FTBT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattansb","download_url":"https://codeload.github.com/mattansb/TBT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031029,"owners_count":20386534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eeg","eeglab","eeglab-plugin","tbt"],"created_at":"2024-10-10T18:23:23.177Z","updated_at":"2025-03-19T23:31:27.791Z","avatar_url":"https://github.com/mattansb.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# TBT\n\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1241518.svg)](https://doi.org/10.5281/zenodo.1241518)\n[![EEGLABplugin](https://img.shields.io/badge/eeglab-TBT-9cf)](https://sccn.ucsd.edu/eeglab/plugin_uploader/plugin_list_all.php)\n\n\nThis EEGLAB plugin allows for the automatic rejection and interpolation of channels on an epoch-by-epoch basis.\n\nIt also comes with an additional method for rejecting epochs - [max-minus-min threshold](./eegmaxmin/README.md).\n\nYou can reference the plugin and its documentation as follows:\n\n- Ben-Shachar, M. S. (2018). TBT: Reject and Interpolate channels on a trial-by-trial basis. Zenodo. [https://doi.org/10.5281/zenodo.1241518](https://doi.org/10.5281/zenodo.1241518)\n\nSee ***Scripting*** below for a citation example.\n\n## Downloading\n\n-   You can download TBT through EEGLAB's data-processing extension GUI (*File \u0026gt; Manage EEGLAB Extensions \u0026gt; Filter by artifact*).\n-   Or as a `.zip` file from the GitHub page [(TBT)](https://github.com/mattansb/TBT/releases).\n\n## List of included functions\n\n-   `eegplugin_TBT` - EEGLAB plugin function.\n-   `tbt_bcr2` - epoch-by-epoch channel interpolation, based on any rejection method used by EEGLAB, or a manual cell-array listing which channels to interpolate in which epochs.\n-   `tbt_bool2cell` - converts a boolean channel-by-trial matrix to a tbt ready cell-list (see bellow).\n-   `tbt_cell2bool` - converts a tbt ready cell-list a boolean channel-by-trial matrix (see bellow).\n-   `pop_TBT` - call from EEGLAB menu of `tbt_bcr`. If no parameters are specified, pops a GUI window.\n\n## TBT GUI\n\nUse the menu *Tools \u0026gt; Epoch by Epoch Rejection/Interpolation*, or type into the command line:\n\n```Matlab\n[EEG, com, badlist] = pop_TBT(EEG); % pop-up interactive window mode\n```\n\n![](img/TBT_eg.png)\n\nYou will be asked to select a rejection method, and set its parameters, and also to set the following:\n1. **The maximum percent of bad trials per channel.** If a channel is bad on more then this percent of the trials, the channel will be removed across the whole data-set.\n2. **The maximum number of bad channels per trial.** If a trial has more than this number of bad channels, the trial will be removed.\n3. Whether to plot the marked channels and trials before rejecting and interpolating the marked channels.\n\nIf you select `Plot before executing`, a pop-up window will appear, allowing for two kinds of plots:\n\n- ***A scrolling EEG plot***, with bad channels marked in red, and bad trials marked in yellow:  \n\n![](img/tbt_plot_eeg.png)\n\n- ***A matrix plot***:\n  - Red horizontal bars mark channels that will be completely removed,  \n  - Red vertical bars mark trials that will be completely removed,  \n  - Colored dots mark which channels that will be removed and interpolated on a trial-by-trial basis.  \n\n![](img/tbt_plot_matrix.png)\n\n\n## Scripting\n\nScripting takes to general following form:\n\n```Matlab\n% Use some rejection method:\nEEG = pop_eegmaxmin(EEG);\n\n% Send the 'rejE' matrix to pop_TBT:\nmy_bads = EEG.reject.rejmaxminE;\nEEG = pop_TBT(EEG,my_bads,10,0.3);\n\n% to get more info, type 'help pop_TBT' in the command line.\n```\n\nScripting gives two major additional not available in the gui:\n\n1.  Supplying a cell-list for rejection\n2.  interpolating additional missing channels (thus making TBT an optional last step in pre-processing)\n\n### Supplying a cell-list\n\nA cell list can be manually created to mark bad channels in specific trials. For example, if we wish to remove E12 and E45 from the 1st epoch, and E22 from epochs 13 and 28, we would create a cell list to be used this list as input for `pop_TBT`:\n\n```Matlab\nmy_bads = {...\n  1,{'E12','E45'};...\n  [13 28],{'E22'};...\n  }\n  \nEEG = pop_TBT(EEG,my_bads,10,0.3);\n                  \n```\n\nThis method can also be combined with other `rejE` methods using the `tbt_cell2bool` function:\n\n```Matlab\n% Specify cell-list\nmy_bads = {...\n  1,{'E12','E45'};...\n  [13 28],{'E22'};...\n  }\n\n% transforms the cell-list into a 'rejE'-like matrix.\nmy_bads = tbt_cell2bool(my_bads,EEG);\n\n% combine with automatic method:\nEEG = pop_eegmaxmin(EEG);\n\n\nmy_bads = my_bads | EEG.reject.rejmaxminE;\nEEG = pop_TBT(EEG,my_bads,10,0.3);\n                  \n```\nThe `tbt_bool2cell` function is the reverse of `tbt_cell2bool`, converting a boolean `rejE` matrix to a tbt-ready cell-list. For example:\n\n```Matlab\n\nEEG = pop_eegmaxmin(EEG);\n\ntbt_bool2cell(EEG.reject.rejmaxminE, EEG)\n\n\u003e\u003e ans =\n\u003e\u003e \n\u003e\u003e   70ª2 cell array\n\u003e\u003e \n\u003e\u003e     [ 2]    {'E64'\t'E90'}\n\u003e\u003e     [ 3]    {'E63'\t'E64'\t'E68'\t'E90'\t'E99'}\n\u003e\u003e     [ 5]    {'E68'\t'E73'}\n\u003e\u003e      ...\n\n```\n\n### Interpolating all missing channels\n\nBy default, trial-by-trial interpolation interpolates *only* the channels that are marked on a single-trial basis. i.e., channels marked as bad across the whole data-set will not be re-added by interpolation. If you wish to add them back (or any other channel that may have been removed in any previous processing step), channel locations can be added to `pop_TBT`:\n\n```Matlab\n% To add back all channels from the input EEG data-set:\nEEG = pop_eegmaxmin(EEG);\n\nmy_bads = EEG.reject.rejmaxminE;\n\nEEG = pop_TBT(EEG,my_bads,10,0.3,[],EEG.chanlocs); % or any other chanloc struct\n                  \n```\n\nThis makes TBT an ideal 'last step' in preprocessing - providing a clean data-set with all missing channels interpolated.\n\n### Citation Example\n\nThis is a citation example for the following code:\n\n```Matlab\nEEG = pop_eegmaxmin(EEG, [],[], 75, [], 1, 0);\n\nEEG = pop_TBT(EEG, EEG.reject.rejmaxminE , 10, 0.15, 1);\n```\n\nof the max-min method + TBT:\n\n\u003e Epoched data were subjected to an automated bad-channel and artifact detection using EEGPLAB's *TBT* plugin (Ben-Shachar, 2018): within each epoch, channels that exceeded a differential average amplitude of 75μV were marked for rejection. Channels that were marked as bad on more then 15/% of all epochs were excluded. Epochs having more than 10 bad channels were excluded. Epochs with less than 10 bad channels were included, while replacing the bad-channel data with spherical interpolation of the neighboring channel values.\n\nAuthor\n------\n\n-   **Mattan S. Ben-Shachar** \\[aut, cre\\] \\\u003cmattanshm at post.bgu.ac.il\\\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2Ftbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattansb%2Ftbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2Ftbt/lists"}