Note
Go to the end to download the full example code. or to run this example in your browser via Binder
How to Edit the Sync Channel#
Note
This is a quick how-to on working with the sync channel. See here for a long-form tutorial.
Warning
Currently, the only supported sync channel is from Neuropixels Imec stream (in which it is the 385th channel). Please get in contact to see other cases supported.
import spikewrap as sw
session = sw.Session(
subject_path=sw.get_example_data_path("openephys") / "rawdata" / "sub-001",
session_name="ses-001",
file_format="openephys",
run_names="all"
)
session.load_raw_data()
session.get_raw_run_names()
# get the sync channel data as a numpy array
run_1_sync_channel = session.get_sync_channel(run_idx= 0)
# or plot the sync channel
session.plot_sync_channel(run_idx=0, show=True)
# edit the sync channel
session.silence_sync_channel(
run_idx=0,
periods_to_silence=[(0, 250), (500, 750)]
)
# refresh the sync channel
session.load_raw_data(overwrite=True)
session.save_sync_channel(overwrite=True, slurm=False)

/home/runner/work/spikewrap/spikewrap/spikewrap/process/_loading.py:146: UserWarning: The sessions or runs provided for are not in creation datetime order.
They will be concatenated in the order provided, as:
['recording2', 'recording1'].
warnings.warn(
Loading data from path: /home/runner/work/spikewrap/spikewrap/spikewrap/examples/example_tiny_data/openephys/rawdata/sub-001/ses-001/ephys/Record Node 104/experiment1/recording2
Loading data from path: /home/runner/work/spikewrap/spikewrap/spikewrap/examples/example_tiny_data/openephys/rawdata/sub-001/ses-001/ephys/Record Node 104/experiment1/recording1
Loading data from path: /home/runner/work/spikewrap/spikewrap/spikewrap/examples/example_tiny_data/openephys/rawdata/sub-001/ses-001/ephys/Record Node 104/experiment1/recording2
Loading data from path: /home/runner/work/spikewrap/spikewrap/spikewrap/examples/example_tiny_data/openephys/rawdata/sub-001/ses-001/ephys/Record Node 104/experiment1/recording1
Saving sync channel for: recording2...
Saving sync channel for: recording1...
Total running time of the script: (0 minutes 0.207 seconds)