Introduction

Finally I found some free time to make ECG_1 more useful. So now, ECG_1 application is running on Windows NT, XP, and 2000 operating systems, and can collect data in real time. To accomplish this, you must download and install free driver for low level in/out ports access. But functions are predefined. Because this is not the end version, I made it for friends who have to convert data from medical records in to TXT format.

The new things are: drvECG_1.dll and ECG_1.exe with capabilities to store data in a TXT file. First download and compile source files, or just download a demo project. To run NT Windows support you will need first to download a “DriverLINX Port I/O Driver for Win95 and WinNT” – it is free, and can be done after a registration here.

After this, you may need to install the driver, simply click on just downloaded file. In future I’m planning to build my own driver, but for this moment this one works well. Follow the instructions and confirm installation by clicking on Next button.

Do not change anything, just click Next.

After installing the port access driver, you need to restart the PC, this will be done automatically. After restarting the PC, you can start ECG_1 application by clicking on its icon - ECG_1.exe.

To use the program, you may need to open files with data. So use the download link to get an data.ecg file. After this, use the menu File->Open to open the open file name dialog.

Select a file data.ecg and click OK or Open. After this, you will be asked to confirm the record, so do this.

After this operation, the data.ecg file will be opened and you can move inside the records:

To save all records in to TXT format you need to use: File->ExportData->Export All Records to TXT, or if you want to export only the selected record to TXT file, use: File->ExportData->Export Current Record to TXT.

If you use Export Current Record, the program will show you the exact number of the selected records, so click OK.

After this, Save File dialog will be opened to ask you to specify the file name and location on the HDD.

So write a test file name and click OK to save the current record, or all the records to a TXT file. The separator between each point in the record is “ ; ”. Note this when opening TXT file. Now you can open the just saved TXT file to view it in notepad.

You can see the separators – “ ; “.

Now to use your data in Microsoft Excel program to perform some extra calculations on it, open MS Excel program and click on File->Open and select your just saved test.txt data file from ECG_1 program and follow the pictures. Because this TXT is a text file, and MS Excel does not support such files directly. You may need to specify in the Open File dialog that you need to see all files, so do it. After this, find on your HDD just saved data.txt file and click Open.

You need to go on a little procedure to accommodate TXT file in to Excel file. So click OK on the upper screen.

Check the Delimiter properties and click Next button.

Select the check box Other and in the input field write a “ ; “. Click Finish to accomplish the procedure.

Now your Excel will contain a single row of values. To make a graph from them go in the Insert Menu and select Chart.

Select chart type as it is shown on the upper picture, then you will need to click next and specify the data to draw.

To do this, click one tile in the data range field, and after this, click before row 1 to select all records in the first row. Click Finish.

Now you can make additional calculations on your file. Because Excel do not support larger data fields, you may need to use Math Cad to use TXT data for additional calculations. I’m not going to discuss this now. But try it. Now is time for some code. To see the full explanations, on ECG_1 code search for my first article in CodeProject. In ECG_1, I added some new functions to support data.TXT file saving.

This function uses the next one function which is created to make the conversion to CString from CWordArray DATA array that is used in ECG.exe to store the medical records data.

void CECG_Data::Serialize_DATA_TXT(CArchive *ar)
{
int i=0;
CString str;
CString stmp;
DATA_TXT.RemoveAll();
//This string is addet to te begining of the
//TXT file so to know what is the exact data in
//this file if someone else open the txt file.
str = "Start from ECG_1 data file;";
//Now we go through the loop to convert
//each one CWordArray DATA value
//in int variable.
for(int j=0;j<DATA.GetSize();j++)
{
stmp.Empty();
char ch[5];
i = int(short(DATA.GetAt(j)));
//This function converts an integer to a char array
_itoa(i, ch, 10 );
for(int k=0;k<4;k++)
{
//To fit each one char value in a
//CString variable we make a
//short loop across char array
stmp = stmp + ch[k];
}
//Current value is set in to a char array and
//now we can add a separator - " ; "
stmp = stmp + ";";
//befor the end we add the stmp CString value
//in the end aff str array
str = str + stmp;
}
//because DATA_TXT is a CStringArray, I use this to make
//easy serializing the txt data
DATA_TXT.Add(str);
//DATA_TXT is Serialized and saved in to a TXT file
DATA_TXT.Serialize(*ar);
}

Important: This loop can take a lot of time!

This one converts CWordArray DATA array into one CStringArray DATA_TXT array. I’m using CStringArray instead of a single CString variable, because it doesn’t support Serialize function directly but CStringArray support it. One additional function is:

Calculations on TXT files take a lot of time, so I made this feature in ECG.exe to support some of you with the ability to use my data files in Mat Lab, Mat Cad, Excel and other programs that you may use every day. But my opinion is that txt files are not a good choice for storing data. Many programs offer this capabilities and I found it useful to make this feature in ECG.exe.

History

01.09.2004

I added some useful features in ECG.exe, so now you can see signal spectrum. To do this, use check box (FFT) see the picture below.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

Comments and Discussions

hi! first of all, thanks for your article here... i download the driver (from another page) and get from the internet all the missings dll's mannually. The thing is this; when i run the .exe once that i have all the dll's, it launchs a debug error (that ugly error window with the unconfortable noise tell me this, it has: Microsoft Visual C++ Library in the title), and it says that i need to debug again the program :S... i really sorry to disturb you, but do you know how can i solve this? or in any case, how can i convert from an .ECG file to a .txt one? any tip is going to be preciated... thanks in advance.

I’m working on one project where I need to develop a simple simulation program (non-commercial and not for profit!) for representation of normal and abnormal ECG patters depends of different physiological and pathophysiological conditions that could impact cardiac and pulmonary physiology.

I was wondering if you know math formula(s) for emulation of ECG patters. If you do know, I would deeply appreciate if you could share your knowledge.

I am trying to use your ECG_1.exe but when I execute your soft, an error message appears and says : "this application has failed to start because MFC42D.DLL was not found re-installing the application may fix this problem".

When i try to open a .ECG file in the software, it gives an error message saying "An attempt was made to access an unnamed file past its end." The .ECG file is a 12-channel ECG data recorded by a machine.

First, thank you for your nice and useful article.
As you said I tried to download the "DriverLINX Port I/O Driver for Win95 and WinNT” but I couldn't. Ive
registered the request form, but the download was impossible.
Can you send me the driver ?