Coding An Electronic EEG Logbook [Part 1]

Around the beginning of 2018 after I took my new position at our practice as Clinical Technology Manager, I took it upon myself to come up with a solution to an enormous problem in our company. Data management, billing and overall tracking of our LTM and clinical EEG studies was a complete mess. We were living in the dark ages, log books just like everyone else. But on top of that, another logbook with patient demographics, the reading doctor, number of hours recorded, pruned/cropped and archived and so on and so forth. All of this had historically been a full-time job for somebody, but as time went on and the practice grew, things needed to change to improve efficiency.

Back in 2008 we had acquired new business performing PICU and NICU EEG telemetry at another hospital and needed a way to track what we were doing there not just for the EEG department but also for billing. My boss then had come up with a very basic Excel spreadsheet. When I saw it I cringed. It was so basic I knew it wouldn’t work. If I took his spreadsheet and made it better I would just hate myself because let me tell you something, I hate Excel spreadsheets with a passion.

I’m not an expert coder by any means but I’m resourceful. I had coded websites before, HTML, javascript, PHP and MySql.

I turned to Google to find some code. Let’s face it if you think of it, someone has probably already done it. And if they publish it or sell it, take/buy that code and modify it to do what you want rather than start from scratch. So that’s what I did.

I found some code online called MySqlTableAjaxEditor. These days code like this is referred to as a CRUD (Create, read, update and delete). Basically it’s code for a webpage that allows you an easy way to manipulate a database.

With this code, I was able to create a simple web-based database on our local intranet to track all of our Outreach EEG studies being performed at this remote hospital. It worked great and our billing department had a way to see what had been done and check off when they had the report for the study and they had billed for it.

Back to 2018. I needed to take this code and expand it big time for our core business. Let me just point out that the code I was using still had not been further developed for many years but the website was still up. I searched and tried out many other CRUDs and similar scripts and none of them had all of the functionality I was looking for. Also, I was already familiar with it and time was of the essence, plus I’m just one guy, so I went with what I knew.

What I needed to do in a nutshell:

  1. Build an electronic version of our EEG logbook including patient demographics, EEG numbers, total hours recorded and more.
  2. Have a way for Doctors to check they have completed a report and have the ability to attach that report
  3. Give our medical records department a way to attach reports and/or take attached reports and upload them into the EMR system
  4. Have a way for our billing department to see when the EEG reports had been completed, prompting them to start the billing process
  5. Have a way for the accounting department to track what’s been billed, which reports are outstanding and overdue etc
  6. Give our administration/accounting a dashboard to give them a daily glance at the status of all EEG numbers/reporting and billing

The main page:

The front page displays many icons, but I wanted to make it as simple for the end users as possible so I thought about how IOS is laid out on an iPhone, something everyone is familiar with. For now, this is what I went with.

The top icons are the logbooks for each of our units/clinics. There are corresponding real-life logbooks for each of these, and they are red which is why I chose these icons. These digital logbooks contain all patient demographics, EEG numbers, total hours recorded, room number, unit, type of equipment etc.

After the EEG study is entered, it shows up in the doctor’s list as an unread study. They click on their respective pages and see the studies that show up. If a study is unread for greater than 21 days, for instance, the code will see that and highlight the study in yellow and shift it to the top, alerting the doctor to hurry up and read it.

The second row of icons displays the second tier in the process, medical records. After the EEG logbook data is entered, the medical records staff looks to see when the doctors have checked a box that the study has been read. When in a read status it shows up on their respective pages as read. They will then go into the EMR and retrieve the report and attach it to the database and mark the study as being entered into EMR.

After medical records has done their part and check off the box that the study is read and in the EMR, it’s ready to be billed. These two tables equaling Yes means they will show up in the respective billing pages. Certain billers are tasked with billing different clinics and EMUs.

Once the billing department has submitted billing with the proper CPT code based on the total hours recorded and type of study it’s now marked as completed. This data is viewable in the dashboard for the administrative and accounting departments.

Here’s a quick look at part of the dashboard:

At any given moment you can pop in and see how many reports are pending and by which physician or location. I used Highcharts to create the dashboard.

Here’s a look at the doctor’s reading page:

If the ‘Days Pending’ column is ≥ 21 days the study is highlighted in yellow and shifted to the top of the list to attract the attention of the reader. Notice the ‘Report Done’ column all show ‘No.’ Start time and stop time are entered and the Study duration column is then calculated.

In my next post [Part 2] I’ll delve deep into the code and include any add ons I did including the Highcharts dashboard. I’ll also outline my roadmap for future improvements to the code including user tracking and automatic email notifications plus moving the code to the cloud.

Proposed CMS Changes for LTM EEG 2020

Timeline for implementation:
• July 2019 – Proposed values for codes published in Medicare Physician Fee Schedule Proposed
• August 2019 – AMA CPT Manual for 2020 becomes available with the full description of the
codes and CPT introductory language.
• November 2019 – Medicare Physician Fee Schedule Final Rule published with final values
• January 1, 2020 – New codes take effect

NAEC Coding Changes Handout

Proposed 2020 Medicare Physician Fee Schedule

Pages 400-410 LTM EEG Proposed Changes

Vulnerabilities Discovered in Natus Xltek NeuroWorks Software

ICS-CERT issued an advisory following the discovery of 8 vulnerabilities in Natus NeuroWorks v8.

If the vulnerabilities are exploited they can allow a malicious hacker to crash the vulnerable device or trigger a buffer overflow condition that would allow remote code execution.

You should update your version of Neuroworks to 8.5 GMA 3 or later. It is available free of charge for users of NeuroWorks/SleepWorks Version 8.0, 8.1, 8.4, or 8.5. The Natus Neuro technical support department should be contacted for further information or download here.

SEEG/ECOG electrode locations in Brainstorm

Localization of intracranial electrodes is critical for invasive epilepsy evaluations and to confirm or not confirm the epileptic zone hypothesis. Various methods exist using various open-source and commercial software. Here is one method using some latest updates to the Brainstorm software.

Required imaging:

  • Pre-implantation T1 without contrast 1mm 3D volume scan
  • Post-implantation CT scan without contrast 1mm 3D volume scan

Assuming you are already familiar with Brainstorm and have already created anatomy files using Freesurfer:

Import Freesurfer anatomy

Choose Freesurfer folder

Change file type to Freesurfer

Set fiducial points & compute MNI coordinates

Convert CT to .nii.gz first with MRIcroGL (drag and drop)

Import CT by selecting ‘Import MRI’

Select the CT .nii file

Apply transformation


Register on default MRI

CT overlay in MRI Viewer

Import ECOG data

Edit channel file

Change channel type to ECOG

Go to CT, Display, Overlay on default MRI (MRI Viewer)

Right click, Electrodes, Set electrode position

View in 3D


Freesurfer Guide (Mac)

FreeSurfer is an open source software suite for extracting the cortex from an MRI, and more.

I’m using Brainstorm, but Brainstorm cannot extract the cortex from the MRI so I need to do this with FreeSurfer. There are also other utilities like BrainSuite that can do this as well.

Step 1

Download Freesurfer here.

Step 2

Register for a license key here.

Step 3

Follow the installation instructions. Create a license.txt file, copy the key into it and save in the freesurfer folder.

Sourcing FreeSurfer Mac from terminal:

$> export FREESURFER_HOME=/Applications/freesurfer

Step 4

Navigate to your DICOM folder in terminal.

Run the recon-all command

recon-all -i file.dcm -subject NAME -all

Where file.dcm should be one of the DICOM files in your folder (e.g. 00000001.dcm or just 00000001). Freesurfer will automatically get the rest of the images in the series.

After the -subject argument NAME should be the name you want to call the study/subject. There will be a folder created with this name in the Applications/FreeSurfer/Subjects folder.

The process can take 10-20 hours, for me, it took ~10hrs on my 2011 core i5 Macbook Pro.


Once it is done you can proceed to import your Freesurfer anatomy into Brainstorm. See the tutorial here.