Spike Sorting Around Events

Hello,

I am working with mouse recordings from the Intan RHS system in Brainstorm. I have successfully imported events, and wish to perform spike sorting in the time windows around the events. The only way I have found to do this so far is to import the files based on events, then select "Review as Raw" on each individual event epoch prior to sorting.

Is there any way to, within the pipeline format, selectively spike sort in a windowed fashion around marked events, with only the event-marked Raw file as input? This would save me large amounts of time, as I want to spike sort chronic recordings, and only need to sort around 5 minutes of total time out of every hour of recording.

Thanks!

Hi @bharve4, we are talking of unsupervised spike sorting, right?

Currently there is not an option to do so. Unfortunately, the implementation of spike sorting by time intervals or event-related intervals is not on our near future developments.

However, the approach that you describe:

can be automated by creating a script using Brainstorm functions, check the pseudocode below, and this link: https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

Do not hesitate in writing us if you encounter any block in writing your script

CREATE Subject
# Function: [sSubject, iSubject] = db_add_subject('SubjectName')

REVIEW OriginalRaw file 
# Process: Import > Import recordings > Create link to raw file

IMPORT epochs by event
# Process: Import > Import recordings > Import MEG/EEG: Events

FOR iEpoch
    REVIEW iEpoch AS RAW iEpochRaw
    # Function: epochRawFile = import_raw(file_fullpath(epochFile), 'BST-DATA', iSubject)
    
    SPIKE SORT iEpochRaw
    # Process: Electrophysiology > Unsupervised Spike Sorting > Method
    
    EXPORT Spike events from iEpochRaw to file
    # sFile = in_bst_data(epochRawFile)
    # export_events(sFile.F, [], 'OutputFile.mat')
    # '.mat' indicates it is events in the Brainstorm format
ENDFOR

FOR iEpoch
    IMPORT Spike events from iEpochRaw file on OriginalRaw
    # Process: Events > Import from file
ENDFOR