[1/3] Fastgraph: Customize SPES (Nihon Kohden)#911
[1/3] Fastgraph: Customize SPES (Nihon Kohden)#911chinmaychinara91 wants to merge 5 commits intobrainstorm-tools:masterfrom
Conversation
Import Single-Pulse Electrical Stimulation (SPES) blocks from raw data recorded using Nihon Kohden system and detect stimulation triggers on the selected stimulation channel.
Observed during the step of Load SPES where we get analog triggers and it gives the warning: "Warning: Integer operands are required for colon operator when used as index"
@rcassani , We need to import the stim blocks first, in order to determine which stim rates we have and stim lines. After the blocks are loaded, then we can detect the events. If we detect events first in the raw file, we get way too many extraneous events throughout the raw file. So restricting the event detection AFTER the stim block loading is strongly preferred. |
|
Hi @Nastaranlotfi, I do not really understand what is shown the shared screenshot. Can you provide more context on what is exactly what cannot be done in the raw data, but that is possible to be done with in the imported data? |
|
@chinmaychinara91, from yesterday's discussion doing the event labelling on the raw file is straight forward, right? |
@rcassani It is straight forward, but I observed something, let me explain in detail to make it clearer.
The screenshot shared by @Nastaranlotfi is for another proprietary data that UTH has, but I feel with the 2nd approach (i.e. creating ODD EVEN after importing the data) it should resolve all the issues. Also, since we are creating this DC10 event in the raw itself, so we can remove the data import process We can now call this routine something like Hope it makes things clearer. Once we all come to a common understanding, I will then proceed with making the changes. |
@chinmaychinara91 on processing the raw file, you have complete control on how create the ODD and EVEN events. If it is needed to restart the ODD-EVEN sequence for each stimulation block:
@chinmaychinara91, This was my suggestion as I did not know the ODD-EVEN was per stimulation block. You had all the information and skills to do it properly. |
|
@rcassani thank you for the clarification. I will go ahead and make the changes accordingly. |
|
Closing this PR and moving things to #913 for a clean history. |
|
Ok, we continue on #913 Just a small note, this PR would have merged with squash, thus the commit history gets collapsed anyway, so to have a "clean history" isn't really a concern. Keeping the same feature in one PR is valuable as it keeps the full conversation, decisions, and code evolution in one place. Moving to new PRs makes that harder to trace later. |
|
@rcassani Thank you for the clarification. That makes sense. I was thinking of keeping the final changes easier to review, but I understand your point, and that keeping the discussion/code evolution in one PR is better for traceability. I’ll keep this in mind for future PRs. |
|
This PR is reopened, following the in-person discussion |
|
@rcassani, I have updated the description with details. |




This PR is the first part required for Fastgraph. It involves customizing the raw data.
Customize SPES (Nihon Kohden)
Linked to
process_customize_spes_nkand it does the following:The GUI
Inputs
Stim StartandStim Stoplabels in the imported NK events if they want to. In this case, we are shortening the labels toSBandSErespectively. Came as a requirement from UTH as the channel names can get very long, thereby making the overall stimulation event label very long.DC10)DC10) in the raw NK events if they want to (here, change toSTIM). Came from UTH, but maybe some other centers might have their own way of naming, so good to have this option.5s). Used as a buffer for the time window for detecting the stimulation trigger.Add ''ODD'' and ''EVEN'' events (alternating monophasic stimulation): If we check this, then it creates alternating monophasic stimulations from the original stimulation event. This is useful in downstream analysis as the odd and even pulses may produce different responses. We will be using this for Fastgraph plots (3rd PR).Steps to use
Load in the updated example test protocol [ NOTE: This preprocessed protocol involves running CAT12 segmentation to get all the anatomical information, the implantation done using Brainstorm, and then loading in the raw data and adding the locations from the implantation to it. These steps will be part of the tutorial].
Drag the
Baseline > Link to raw fileto theProcess1tab and click onRun > Stimulation > Customize SPES (Nihon Kohden).Fill in the values as seen in the GUI figure above. Click

Run. The raw data gets updated as under:Stim Startevent label gets replaced bySB(short for stim begin - UTH follows this)Stim Stopevent label gets replaced bySE(short for stim end - UTH follows this)DC10triggers were detected, and the event was renamed asSTIMODDandEVENevents was created from theSTIMevents aboveSTIM,ODDandEVENevent labels are appended with the stim site information (e.g.T'3-T'4 4 #1in the figure above whereT'3-T'4 4means stimulation was delivered between contactsT'3andT'4at 4 milliamps and the#1means the first session. You can see in the image there is also a 2nd session which isT'3-T'4 4 #2. Analyzing each of these sessions separately is required during the downstream analysis, which will be clearer in the 3rd PR.Baseline > Link to raw fileto theProcess1tab and click onRun > Import > Import recordings > Import MEG/EEG: Events. Set event name asSBand epoch time-5000to35000. For this sample data, we will be importing allSBevents with an epoch of 40s (30s stimulation block with a buffer of 5s around it so that it contains the full stimulation segment plus some context before and after it).Associated PRs
@jcmosher @Nastaranlotfi @yashvakilna