intan.applications package

GUI applications and launchers for EMG analysis and trial labeling.

Lightweight package exports for intan.applications.

Make imports lazy/guarded so importing the package doesn’t pull optional GUI, SciPy, or pandas dependencies during CLI or test runs.

Submodules

intan.processing._emg_viewer_gui

Graphical User Interface (GUI) for loading and visualizing EMG data.

The EMGViewer provides an interactive interface for exploring high-density EMG signals from Intan .rhd recordings. It supports: - Channel selection - Segment visualization - Preprocessing - Trigger-based analysis (if available)

Typically launched via _emg_launcher.py.

save_model_obj(obj, path)[source]

Save a model object with joblib or pickle.

load_model_obj(path)[source]

Load a model object with joblib or pickle.

save_trials_csv(trials, path)[source]
load_trials_csv(path)[source]
save_features_npz(features, path)[source]
load_features_npz(path)[source]
class EMGViewerTk(root)[source]

Bases: object

build_layout()[source]
build_acquisition_tab()[source]
build_trials_tab()[source]
build_filtering_tab()[source]
build_training_tab()[source]
add_feature_directory()[source]
add_training_directory()[source]
apply_visualization_filters(signal)[source]

Filtering for visualization using Filtering Tab controls.

copy_display_to_training_filters()[source]
load_feature_segments()[source]
load_segment_and_visualize()[source]
load_file()[source]

Load an RHD, NPZ, or CSV file and plot the first channel.

update_training_labels_from_directory()[source]

Helper function to refresh the training labels listbox with all the labels detected from the current directories

remove_training_directory()[source]
remove_selected_label()[source]
visualize_selected_segment()[source]
run_pca_visualization()[source]
refresh_labels_list()[source]

Clear and rebuild the labels list from all currently listed directories.

update_training_labels_from_filename(fname)[source]

Extract label from filename and add to label list if not already present. Assumes filenames like: participant_label_0.npz

run_trial_segmentation()[source]

Segment the EMG data into trials based on manual indices or notes files. Saves each segment as a compressed .npz file (with ‘emg’ data and ‘label’) in an ‘emg’ subfolder.

enable_indexing()[source]
scroll_plot(*args)[source]
on_click(event)[source]
save_table()[source]
parse_channel_range(text)[source]
load_table()[source]
delete_selected()[source]
update_channel(event=None)[source]
plot_channel(event=None)[source]
extract_features_from_directories()[source]

Iterate over each selected directory of segmented trials, apply filters, extract features, and aggregate the results. Saves individual feature files and builds a dataset.

extract_td_features(segment)[source]

Computes a variety of unique features from segmented EMG data. Input shape expects (channels x samples).

apply_training_filters(emg)[source]

Applies selected filters to the EMG data. Handles both 1D (single channel) and 2D arrays.

add_scalebars(ax, scale_time=5, scale_voltage=10)[source]
insert_channel_labels(ax, time_vector, num_channels, num_labels=2, font_size=8)[source]
insert_vertical_labels(ax)[source]
build_training_dataset()[source]
waterfall_gui_plot(channel_indices)[source]
on_closing()[source]
EMGViewer

alias of EMGViewerTk

intan.processing._emg_trial_selector

Graphical tool for interactively labeling trial events on EMG recordings.

This GUI allows researchers to: - Load and visualize EMG signals from .rhd files - Select individual channels - Click to mark trial onset points - Assign labels to each indexed event - Append new recordings for multi-session review - Export trial events to a timestamped CSV or TXT file

Clicking the signal while “Set Trial Index” is enabled will add a labeled marker. This tool is useful for supervised training of gesture classifiers, post-hoc annotation, or protocol validation in EMG experiments.

class EMGTrialSelector(root)[source]

Bases: object

Tkinter-based application for manual EMG trial indexing.

emg_data

EMG signal matrix (channels × samples)

Type:

np.ndarray

time_vector

Time vector aligned with EMG samples

Type:

np.ndarray

sampling_rate

Sampling rate of amplifier

Type:

float

current_channel

Channel index currently displayed

Type:

int

indexing_enabled

If True, allows user to click to insert marker

Type:

bool

load_file()[source]

Load EMG data from a .rhd file and initialize the GUI with the first channel.

append_file()[source]

Append EMG data from another .rhd file to the current data.

sample_index_to_timestamp(index)[source]

Convert a sample index to a timestamp string.

Parameters:

index (int) – Sample index to convert.

Returns:

Formatted timestamp string (HH:MM:SS).

Return type:

str

save_table()[source]

Save the trial markers to a text file with sample index and timestamp.

delete_selected()[source]

Delete selected rows from the table.

extract_edges()[source]
clear_indices()[source]

Clear all rows in the table and remove drawn marker lines.

update_channel(event=None)[source]

Update the current channel based on the selection from the dropdown.

enable_indexing()[source]

Enable the indexing mode to allow trial marking on the plot.

on_click(event)[source]

Handle mouse click events on the plot to mark trial onset points.

Parameters:

event (matplotlib.backend_bases.Event) – The mouse event.

plot_channel()[source]

Plot the currently selected EMG channel.

on_closing()[source]

Launch the packaged desktop applications.

launch_emg_viewer()[source]

Launch the PyQt viewer when available, otherwise use the Tk fallback.

launch_emg_trial_selector()[source]

Launch the EMG trial selector GUI.