Sharing custom process for Sleep Spindle Analysis for sleep researchers

Dear BST community,

Some time ago I posted the following discussion regarding the extraction of manually identified sleep spindles for further analysis. Down this discussion, @Raymundo.Cassani gave me a good idea to "would be read the data from each of the imported spindle instances (trials), and compute the features for each one of the instances."

So that is what I have done. Thank you for the idea @Raymundo.Cassani :slight_smile:

I made a custom process for sleep researchers out there interested in sleep spindles to calculate sleep duration, frequency, amplitude and symmetry. Hope it becomes useful.
@Raymundo.Cassani if you wish to add this process to GitHub my user name is mcp0228 .

process_sleepspindle_parameters.m (12.1 KB)


@mcp0228, Thanks for your contribution!

The process looks good. Few observations:

  • Sampling frequency is hardcoded, that would difficult the use for other users.
    It can be read from the data
  • Used channels, it seems the spindle identification run channels that are not EEG (e.g., EOG, EMG and the status). It is possible to add a channel selection parameter in the options so the user can select the set of channels to be used.

Thanks for your ideas, Raymundo!
Please find the updated process where I've made the following amendments:

  1. Sampling frequency is no longer hardcoded but calculated by the number of time samples-1 divided by the duration
  2. Counting the number of zeros and sign changes for calculation of frequency has been removed.
    This is now replaced by counting the number of spindle peaks.

I've decided not to add a channel selection parameter in the options because spindles are by definition an EEG phenomenon therefore it wouldn't make sense for a user to select EOG or EMG for this process.
process_sleepspindle_parameters.m (12.4 KB)

And I've created a pull request for this as well.

Hi mcp0228, is there any reason you are manually extracting sleep spindles, rather than to use an algorithm? question might be naive, so forgive me ahead of time.

We can continue the conversation on the PR, and just post here once it's available

Hello @chanakyareddy thank you for your question :slight_smile:
Firstly, the custom-process that I wrote is for analysing already identified and extracted individual/discrete spindles so the process of manually extracting sleep spindles is independent of the process.

Now, onto your question, it's not naive at all, no worries.
The reasons for manual extraction is as follows:

  1. It is well known from articles like Warby et al. (2014) and its related papers that automatic detection of spindles, while useful, is actually not as great as people assume. Therefore automatic detection algorithms are usually used in conjunction with visual re-checking of the spindles identified by the algorithms - i.e. a semi-automatic process. Therefore at this stage our group decided to just manually identify the discrete spindles if we eventually have to recheck the spindles identified by the algorithms.
  2. There is a plan in place to implement an automatic detection algorithm eventually but that is in due course. Due to where we are at in our data preprocessing and analysis we decided to manually identify the spindles first and compare its results to the (eventual) automatic detection algorithm - therefore think of the current methods as stage 1 in our spindle analysis pipeline.
  3. One of the main issues with visual identification of spindles is the large quantity of time spent in visual identification. Fortunately, our sleep research is a nap study meaning the quantity of data to visually identify the spindles is not much compared to overnight noctural studies.
  4. One of the other main issues with visual identification of spindles is the aspect of subjectivity, which is the case with sleep staging as well. Therefore we decided to cross-check the visually identified spindles in the time domain (which is the gold standard for identifying spindles) with spindles in the time-frequency domain. This allowed our team to check the spindles we've identified subjectively in the time domain from a different perspective. While the element of subjectivity would still be present, by implementing this method, we can reduce the degree of subjectivity. If you wish to know more about this check my other forum post down below.

Yes we can - the pull request is already there in GitHub so we can continue this chat over there :slight_smile: