I'm trying to use a chart to plot ECG (cardiac) signals.
The signals are recorded during 24 hours with a sampling frequency of 1 kHz.
I have 12 lineseries. each series has its own YAxis. but they share the same XAxis.
At first I tried loading all the data into the chart and using chart pages to display only a part of the signal but it was too slow.
Then I switched to putting a Tscrollbar (TchartScrollbar is not usefull in my case because it scrolls an already filled chart).
At change of the scrollbar.position I clear the old series and i create new 12 lineseries and I fill them with segment of 10 seconds data:
Here is my code :
Code: Select all
Screen->Cursor = crHourGlass;
int num_leads = ECG->getNumLeads() ;
int freq= ECG->getFreq();
long M= ECG->getNumSamp();
long K = M/num_leads;
ScrollBar2->Min = 0;
ScrollBar2->Max = floor(1.0*K/(UpDown1->Position*freq));
size_t num = freq * UpDown1->Position; // windows size
size_t start = ScrollBar2->Position*num; // Page number
double Dt = 1.0/freq;
double t =0.0;
char ld_name[64];
for (int j = 0; j < num_leads; j++) { // plot lead by lead
ECGPlot[j] = new TFastLineSeries(Chart1);
ECGPlot[j]->ParentChart = Chart1;
t=start*Dt;
double *data = new double[num];
int read =ECG->getData(j,start,num,data);
// data table for lead j
for (int i = 0; i < read ; i++)
{
t+=Dt;
ECGPlot[j]->AddXY(t,data[i]);
}
delete [] data;
sprintf(ld_name, "Lead-%s", ECG->LeadText(j));
ECGPlot[j]->Title=ld_name;
}
Chart1->BottomAxis->SetMinMax(start*Dt, start*Dt+num*Dt);
Chart1->BottomAxis->Increment=1.0;
Chart1->CustomAxes->Clear();
int n = Chart1->SeriesCount();
int D = 100/n;
for (int i = 0; i < n; i++) {
TChartAxis *Ax = new TChartAxis(Chart1->CustomAxes);
Ax->Axis->Color = Chart1->Series[i]->Color;
Ax->StartPosition = i*D;
Ax->EndPosition = Min(i*D +D-2,100);
Ax->PositionPercent = 0;
Ax->LabelStyle =talNone;
Chart1->Series[i]->CustomVertAxis = Ax;
Chart1->Series[i]->Color= clNavy;
}
1- Can I make the 12 lineseries sharing the same XAxis data with repeating filling and allocating the Xvalues to the 12 series ?
2- I want to control the XAxis scale on the screen and on the printer. Doctors are used to display ECG data with a 25 mm/s.
How can I control the Xasis length to make it equal to 25*10 = 250 mm =25 cm on the screen and on the printer?
Regards