Ephys

v0.5.1
io.github.happyc0der/ephys-mcp Checked 12 hours ago Published 2 months ago

Read-only analysis of intracortical BCI recordings (NWB, DANDI, WAV): spikes, PSTHs, decoding, plots

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_sources

List the data source types this server can open, with their parameters and status.

open_session

Open a recording session and return its session_id and metadata. `params` overrides the source's default_params (see list_sources).

ParameterTypeDescription
params
sourcestring

close_session

Close a session and drop any decoder fitted on it.

ParameterTypeDescription
session_id *string

get_session_info

Metadata for a session: duration, channels, sampling rates, behaviour signals, licence, citation.

ParameterTypeDescription
session_id *string

get_signal_quality

Noise level, SNR and dead/noisy channels from a broadband snippet (max 10 s).

ParameterTypeDescription
session_id *string
duration_snumber
t0number

detect_spikes

Threshold-crossing spike detection on a broadband snippet (max 10 s). Where the session has ground-truth spikes, precision and recall are reported.

ParameterTypeDescription
session_id *string
duration_snumber
t0number
threshold_sigmanumber

set_probe_geometry

Tell the server where the recording's contacts are, for sessions whose file does not say. Named layouts: 'utah' (square grid, e.g. 96 contacts at 400 um), 'grid' with n_columns, 'linear' (one column at pitch_um, e.g. a laminar probe), 'tetrode_linear' (groups of four). 'explicit' takes positions_um as [[x, y], ...] in channel order. Geometry is used by sort_spikes and plot_probe. Contacts under 100 um apart are sorted jointly.

ParameterTypeDescription
session_id *string
layoutstring
n_columnsinteger
pitch_umnumber
positions_um

get_probe

Contact geometry and brain-area labels per channel, where known. Use the `channel` indices with the `units` argument of get_psth / fit_latent_factors to analyse one area.

ParameterTypeDescription
session_id *string
max_rowsinteger

plot_probe

Figure: the array map, each contact coloured by its firing rate over a window, with area labels and sorted units marked when a sort has been run. Needs geometry from the file or set_probe_geometry.

ParameterTypeDescription
session_id *string
duration_snumber
t0number

sort_spikes

Spike-sort a broadband window (needs the sort extra). Afterwards the session's spike times are the sorted units, restricted to that window, so rates, PSTHs, rasters and decoders use them. Uses the session's probe geometry (from the file or set_probe_geometry) so nearby contacts are sorted jointly; without geometry each channel is treated as an independent electrode. Sorting takes seconds to a few minutes depending on duration and channel count.

ParameterTypeDescription
session_id *string
channels
duration_snumber
sorterstring
t0number

get_firing_rates

Population firing-rate summary over a time range (defaults to the whole session).

ParameterTypeDescription
session_id *string
t0number
t1

fit_decoder

Fit a decoder from spike counts to a behaviour signal and score it on held-out data. The first `train_fraction` of the session trains; the remainder tests. With no `target`, the first velocity-like behaviour signal is used. Unrecorded gaps are skipped. `mask` names a boolean behaviour signal (such as FALCON's eval_mask); only bins where it is true are used for fitting and scoring.

ParameterTypeDescription
session_id *string
bin_snumber
kindstring
mask
target
train_fractionnumber

evaluate_cross_session

Fit a decoder on one session and score it, unchanged, on other sessions: the question benchmarks such as FALCON ask (does a decoder survive to a later day?). All sessions must be open and share the same units/channels. `mask` names a boolean behaviour signal restricting which bins are scored (FALCON files carry `eval_mask`; pass null when the sessions have none). Also reports same-session held-out R² for comparison.

ParameterTypeDescription
test_session_ids *array
train_session_id *string
bin_snumber
kindstring
mask
target

decode_window

Decode a window with the fitted decoder; returns a downsampled decoded-vs-true preview.

ParameterTypeDescription
session_id *string
t0 *number
duration_snumber
max_pointsinteger

get_psth

Peri-stimulus time histogram: firing aligned to a trial event and averaged over trials. `event` is one of the session's event_columns (default: movement onset if present). `group_by` splits trials by one of its group_columns, e.g. reach direction. `units` restricts the analysis to some units; tuning that cancels in the population average (such as direction preference) only shows up per unit. Unit numbers in the result index into `units` when it is given. Returns the population time course, its peak, and the units that change most.

ParameterTypeDescription
session_id *string
bin_snumber
event
group_by
t_afternumber
t_beforenumber
units

fit_latent_factors

Fit low-dimensional latent factors to trial-aligned population activity. GPFA (Yu et al. 2009) gives denoised single-trial trajectories and a timescale per factor; PCA is the fast, noisier baseline. Look for an elbow in variance_explained_per_factor to judge dimensionality. If the session has a velocity-like signal, reports how well the top factors explain it. Then plot_latent_factors draws the trajectories.

ParameterTypeDescription
session_id *string
bin_snumber
event
group_by
methodstring
n_factorsinteger
t_afternumber
t_beforenumber
units

plot_latent_factors

Figure: the top three latent factors over time (single trials thin, group means bold), the trajectory in the plane of the first two factors, and variance explained per factor. Requires fit_latent_factors first.

ParameterTypeDescription
session_id *string
max_trials_drawninteger

plot_psth

Figure: population PSTH per group (mean ± SEM over trials) above a unit-by-time heatmap of change from baseline. Same arguments as get_psth. Returns the PNG path and the image.

ParameterTypeDescription
session_id *string
bin_snumber
event
group_by
t_afternumber
t_beforenumber
units

plot_raster

Figure: spike raster for a time window (max 60 s), with unrecorded spans shaded.

ParameterTypeDescription
session_id *string
duration_snumber
max_unitsinteger
t0number

plot_decoding

Figure: decoded against actual behaviour for a window (max 60 s), one panel per dimension. Requires fit_decoder first. Pick a window in the test split for an honest picture.

ParameterTypeDescription
session_id *string
t0 *number
duration_snumber

list_lsl_streams

Lab Streaming Layer streams visible on the local network (needs the lsl extra).

ParameterTypeDescription
wait_snumber

get_stream_status

For a live session: how much signal is buffered, whether data is still arriving, and drops.

ParameterTypeDescription
session_id *string

search_datasets

Search the DANDI Archive for datasets. An empty query returns a short curated list of intracortical datasets that work well with this server.

ParameterTypeDescription
limitinteger
querystring

list_dataset_files

Licence, citation and NWB files of a DANDI dataset. Pass a file's path to open_session(source='dandi').

ParameterTypeDescription
dandiset_id *string
limitinteger
versionstring