main.cpp

来自「脑电信号分析软件」· C++ 代码 · 共 967 行 · 第 1/3 页

CPP
967
字号
      End_x=X+m*Page;
      for (n=0;n<16;n=n+1)         // file[i+m*Page].Lead[0]*0.05*amp + (PaintBox1->Height-30)/Amplify)
       {  aa=(2*n+1)*(PaintBox1->Height-30)/Amplify;
          bb=(2*(n+1)+1)*(PaintBox1->Height-30)/Amplify;
          if ((Y>=aa)&&(Y<=bb))
          {
             Lead_Num=n;
             Write_line(PaintBox1->Canvas,X,aa+2,X,bb-1,clBlue);    // End_x     End_x
        // Write_line(PaintBox1->Canvas,Start_x,aa+10,End_x,aa+10,clBlue);
          }
        }
     }
     if((Button==mbLeft)&&(Shift.Contains(ssCtrl))&&(Analisys%2==0))
     {
      Topo_End_x=X+m*Page;
       Write_line(PaintBox1->Canvas,X,0,X,PaintBox1->Height-20,clBlue);   // Topo_End_x   Topo_End_x
     }
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::PowerForm1Click(TObject *Sender)
{
  if(Start_x==End_x)
     {
      ShowMessage(AnsiString("请重新选择要分析的图像段") );
      goto theEnd;
     }

 PPpower->Show();
 theEnd:
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMainForm::topographic1Click(TObject *Sender)
{
     int p,q,j,i;
     int Num1,Num2;
     double FFTMag[FFTPOINT+5];
     double max,min,swing,t;
     double temp_dpower[5][16];
     double wx[FFTPOINT+5],wy[FFTPOINT+5];   //计算FFT用
     double datax[FFTPOINT+5],datay[FFTPOINT+5];  // 计算FFT用
  //-------------------------------------------------------//

  if (Topo_End_x==Topo_Start_x)
   {
    ShowMessage(AnsiString("请重新选择要分析的图像段") );
    goto theEnd;
   }
  if (Topo_End_x-Topo_Start_x+1>512)   ///取数据的长度大于512时
          Topo_End_x=512+Topo_Start_x;
    for(p=Topo_Start_x;p<Topo_End_x;p++)
    {
      for(q=0;q<16;q++)
        {
        TopoFile[p-Topo_Start_x].Lead[q]=file[p].Lead[q];
        }
     }
   //-------------------------------------------------------//
    if (Topo_End_x-Topo_Start_x+1<512) ////取数据小于512时,将后面补零
    {
       for (p=Topo_End_x-Topo_Start_x+1;p<512;p++)
         {
         for(q=0;q<16;q++)
            {
             TopoFile[p-Topo_Start_x].Lead[q]=0;
            }
         }
    }

   //-------------FFT 获得平均功率值-------------------------//

    for (q=0;q<16;q++)
    {
      //-----进行FFT变换-------------------------------------//
        FFTInit(wx,wy);
             for(p=0;p<FFTPOINT;p++)
               {
                   datax[p]=TopoFile[p].Lead[q];      //ctg[p].td[8];
                   datay[p] = 0;
                }

        fft(datax,datay,wx,wy,512);
    //-----------------------------------------------------------
        for(int i=0;i<5;i++)    //i分别表示0~3.9;4~7.9;8~13.9;14~30
        {
          if (i==0)
          {
          Num1=0;Num2=39;
          Topograp->d2_power[i][q]=MagFFT(datax,datay,Num1,Num2);
          temp_dpower[i][q]=MagFFT(datax,datay,Num1,Num2);
          }
          if (i==1)
          {
          Num1=40;Num2=79;
          Topograp->d2_power[i][q]=MagFFT(datax,datay,Num1,Num2);
          temp_dpower[i][q]=MagFFT(datax,datay,Num1,Num2);
          }
          if (i==2)
          {
          Num1=80;Num2=139;
          Topograp->d2_power[i][q]=MagFFT(datax,datay,Num1,Num2);
          temp_dpower[i][q]=MagFFT(datax,datay,Num1,Num2);
          }
          if (i==3)
          {
          Num1=140;Num2=300;
          Topograp->d2_power[i][q]=MagFFT(datax,datay,Num1,Num2);    //将512个点的FFT做和取平均,得功率值
          temp_dpower[i][q]=MagFFT(datax,datay,Num1,Num2);//Topograp->d2_power[i][q];
          }
          if (i==4)
          {
          Num1=0;Num2=512;
          Topograp->d2_power[i][q]=MagFFT(datax,datay,Num1,Num2);    //将512个点的FFT做和取平均,得功率值
          temp_dpower[i][q]=MagFFT(datax,datay,Num1,Num2);//Topograp->d2_power[i][q];
          }
        }
     }
    ///-------------FFT 获得平均功率值--(上)-----------------------///


    ///------------------由小到大排序-----------------------------///
        for (int mm=0;mm<5;mm++)
        {
         for (j=1;j<15;j++)
          {
           for (i=j;i<16;i++)
            {
            if(temp_dpower[mm][j]>temp_dpower[mm][i])
               {
               t=temp_dpower[mm][i];
               temp_dpower[mm][i]=temp_dpower[mm][j];
               temp_dpower[mm][j]=t;
               }
            }
          }
       }
    ///-------------------------------------------------------///
    ///------------------排序后,将标准系重新划定范围---------///
         for (i=0;i<5;i++)
         {
           for (j=0;j<14;j++)    //   (float)
           {
           Topograp->scale_2d[i][j]=(temp_dpower[i][0]+j*(temp_dpower[i][14]-temp_dpower[i][0])/14);
           }

         }
     ///--------------------------------------------------------///
      //----------------------------------------------------//

 Topograp->Show();
 theEnd:
}
//---------------------------------------------------------------------------
 

void __fastcall TMainForm::ModelOne1Click(TObject *Sender)
{  //QRListForm->Show();
  //int  step=10;
  //float  V_zoom=0.025;
  String  databasepath;
    databasepath= ExtractFilePath(Application->ExeName)+"dangan.mdb";
    if (QRListForm->ADOConnection1->Connected==false)
      {QRListForm->ADOConnection1->ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" + databasepath + ";Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
       }
   QRListForm->ADOQuery1->Close();
   QRListForm->ADOQuery1->SQL->Clear();
   QRListForm->ADOQuery1->SQL->Add("SELECT * FROM Pinfo WHERE  编号='" + QRListForm->ID + "'" );
   QRListForm->ADOQuery1->Open();
   if(QRListForm->ADOQuery1->Eof==false)
    { QRListForm->QRLabel_bh->Caption=QRListForm->ADOQuery1->FieldByName("编号")->AsString;
      QRListForm->QRLabel_rq->Caption=QRListForm->ADOQuery1->FieldByName("日期")->AsDateTime;
      QRListForm->QRLabel_qssj->Caption=QRListForm->ADOQuery1->FieldByName("时间")->AsDateTime;
      QRListForm->QRLabel_xm->Caption=QRListForm->ADOQuery1->FieldByName("姓名")->AsString;
      QRListForm->QRLabel_xb->Caption=QRListForm->ADOQuery1->FieldByName("性别")->AsString;
      QRListForm->QRLabel_nl->Caption=QRListForm->ADOQuery1->FieldByName("年龄")->AsString;
      QRListForm->QRLabel_zy->Caption=QRListForm->ADOQuery1->FieldByName("左/右利")->AsString;
      QRListForm->QRLabel_ks->Caption=QRListForm->ADOQuery1->FieldByName("科室")->AsString;
      QRListForm->QRLabel_mzh->Caption=QRListForm->ADOQuery1->FieldByName("门诊号")->AsString;
      QRListForm->QRLabel_zyh->Caption=QRListForm->ADOQuery1->FieldByName("住院号")->AsString;
      QRListForm->QRLabel_bfh->Caption=QRListForm->ADOQuery1->FieldByName("病房号")->AsString;
      QRListForm->QRLabel_dls->Caption=QRListForm->ADOQuery1->FieldByName("导联数")->AsString;
      QRListForm->QRLabel_fy->Caption=QRListForm->ADOQuery1->FieldByName("检查前服药")->AsString;
      QRListForm->QRLabel_sz->Caption=QRListForm->ADOQuery1->FieldByName("检查时神志")->AsString;
      QRListForm->QRLabel_ys->Caption=QRListForm->ADOQuery1->FieldByName("医师")->AsString;
    }
  QRListForm->QRImage2->Canvas->FillRect( QRListForm->QRImage2->ClientRect);
  QRListForm->QRLabel17->Caption="检查结果报告:";
  QRListForm->QRLabel18->Caption="医师:";
  QRListForm->QRLabel19->Caption ="";
  QRListForm->QRLabel20->Caption ="";
  QRListForm->QRLabel_ys2->Caption ="";
  QRListForm->QRImage2->Visible=false;
  QRListForm->QuickRep1->Preview();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ModelTwo1Click(TObject *Sender)
{
  int  step=10;
  float  V_zoom=0.025;
  String  databasepath;
    databasepath= ExtractFilePath(Application->ExeName)+"dangan.mdb";
    if (QRListForm->ADOConnection1->Connected==false)
      {QRListForm->ADOConnection1->ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" + databasepath + ";Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
       }
   QRListForm->ADOQuery1->Close();
   QRListForm->ADOQuery1->SQL->Clear();
   QRListForm->ADOQuery1->SQL->Add("SELECT * FROM Pinfo WHERE  编号='" + QRListForm->ID + "'" );
   QRListForm->ADOQuery1->Open();
   if(QRListForm->ADOQuery1->Eof==false)
    { QRListForm->QRLabel_bh->Caption=QRListForm->ADOQuery1->FieldByName("编号")->AsString;
      QRListForm->QRLabel_rq->Caption=QRListForm->ADOQuery1->FieldByName("日期")->AsDateTime;
      QRListForm->QRLabel_qssj->Caption=QRListForm->ADOQuery1->FieldByName("时间")->AsDateTime;
      QRListForm->QRLabel_xm->Caption=QRListForm->ADOQuery1->FieldByName("姓名")->AsString;
      QRListForm->QRLabel_xb->Caption=QRListForm->ADOQuery1->FieldByName("性别")->AsString;
      QRListForm->QRLabel_nl->Caption=QRListForm->ADOQuery1->FieldByName("年龄")->AsString;
      QRListForm->QRLabel_zy->Caption=QRListForm->ADOQuery1->FieldByName("左/右利")->AsString;
      QRListForm->QRLabel_ks->Caption=QRListForm->ADOQuery1->FieldByName("科室")->AsString;
      QRListForm->QRLabel_mzh->Caption=QRListForm->ADOQuery1->FieldByName("门诊号")->AsString;
      QRListForm->QRLabel_zyh->Caption=QRListForm->ADOQuery1->FieldByName("住院号")->AsString;
      QRListForm->QRLabel_bfh->Caption=QRListForm->ADOQuery1->FieldByName("病房号")->AsString;
      QRListForm->QRLabel_dls->Caption=QRListForm->ADOQuery1->FieldByName("导联数")->AsString;
      QRListForm->QRLabel_fy->Caption=QRListForm->ADOQuery1->FieldByName("检查前服药")->AsString;
      QRListForm->QRLabel_sz->Caption=QRListForm->ADOQuery1->FieldByName("检查时神志")->AsString;
      QRListForm->QRLabel_ys2->Caption=QRListForm->ADOQuery1->FieldByName("医师")->AsString;
    }
  QRListForm->QRLabel17->Caption="脑电图:";
 // QRListForm->QRLabel18->Visible=false;
  QRListForm->QRLabel19->Caption="检查结果报告:";
  QRListForm->QRLabel20->Caption="医师:";
  QRListForm->QRLabel_ys2->Visible =true;
  QRListForm->QRImage2->Visible=true;
  QRListForm->QRImage2->Canvas->FillRect( QRListForm->QRImage2->ClientRect);

   int n;
   Graphics::TBitmap   *MemBitmap   =   new   Graphics::TBitmap;    // 创建一个TBitmap对象,用作缓冲
          try
           {
            MemBitmap->Width    =   QRListForm->QRImage2->Width;      //  设置缓冲图像的宽度、高度
            MemBitmap->Height   =   QRListForm->QRImage2->Height;     //  和目标控件的宽度、高度相等

        //----------------------------------------------------------------
        // 这里面就直接在缓冲对象中,画波形

            //...
            //MemBitmap->Canvas->MoveTo(x,y);
            //MemBitmap->Canvas->LineTo(x+1,y+1);
           // ...
            for(i=0;i<700;i++)
             {for(n=0;n<16;n++)
               {if(n==0||n==8)
                 {MemBitmap->Canvas->Pen->Color=clBlue;}
                if(n==4||n==12)
                 {MemBitmap->Canvas->Pen->Color=clBlack;}
                      //MemBitmap->Canvas->MoveTo(i,buf[i*16+m*step+n]*V_zoom + (2*n+1)*PaintBox1->Height/32);
                      //MemBitmap->Canvas->LineTo(i+1,buf[(i+1)*16+m*step+n]*V_zoom + (2*n+1)*PaintBox1->Height/32 );
                   MemBitmap->Canvas->MoveTo(i,file[i+m*step].Lead[n]*V_zoom + (2*n+1)*QRListForm->QRImage2->Height/32);
                   MemBitmap->Canvas->LineTo(i+1,file[i+1+m*step].Lead[n]*V_zoom + (2*n+1)*QRListForm->QRImage2->Height/32 );
                       //MemBitmap->Canvas->MoveTo(k,file[i].Lead[n]*0.05*amp + (2*n+1)*(PaintBox1->Height-20)/Amplify);
                       //MemBitmap->Canvas->LineTo(k+1,file[i+1].Lead[n]*0.05*amp + (2*n+1)*(PaintBox1->Height-20)/Amplify );

                }
              }
        //----------------------------------------------------------------
           //PaintBox1->Canvas->Draw(0,0,MemBitmap);  //画完以后,PaintBox 直接将整个缓冲对象画出来
           BitBlt(QRListForm->QRImage2->Canvas->Handle,0,0,QRListForm->QRImage2->Width,QRListForm->QRImage2->Height,MemBitmap->Canvas->Handle,0,0,SRCCOPY);
        }
       catch(...)
      {
      Application->MessageBox("显示时发生错误!", "错误", IDOK);
      }
   /// __finally
    //{
        delete   MemBitmap;       // 释放缓冲

  QRListForm->QuickRep1->Preview();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditPatient1Click(TObject *Sender)
{
Form_dangan->Show();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::PatientFile1Click(TObject *Sender)
{
    Form_Retrieve->Show();
}
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------

void __fastcall TMainForm::About1Click(TObject *Sender)
{
AboutBox->Show();
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Timer3Timer(TObject *Sender)
{
  int i,n;
  // int  Amplify=32;
  //int Page=960;
  int kk;
  kk=MainForm->m;
  int uu,ll,ff,gg;
  for(uu=0;uu<10;uu++)
  {
   781/45*912/48*1258/145+145/86*145*237/4-154/89*1458*14/523/145682/14*478/56+1487*9513;
   for(ll=0;ll<100;ll++)
   {
     781/45*912/48*1258/145+145/86*14*5237/4-154/89*1458*14/523/145682/14*478/56+14879*513;;
     for(ff=0;ff<100;ff++)
     {
       781/45*912/48*1258/145+145/86*14*5237/4-154/89*1458*14/523/145682/14*478/56+1487*9513;;
       for(gg=0;gg<90;gg++)
       {
        781/45*912/48*1258/145+145/86*14*5237/4-154/89*1458*14/523/145682/14*478/56+1487*9513;;
       }
        781/45*912/48*1258/145+145/86*145*237/4-154/89*1458*14/523/145682/14*478/56+14879*513;;
      }
      781/45*912/48*1258/145+14/586*14*5237/4-154/89*1458*14/523/145682/14*478/56+1487*9513;;
    }
    781/45*912/48*1258/145+145/86*145*237/4-154/89*1458*145/23/145682/14*478/56+1487*9513;;
  }
        MainForm->PaintBox1->Refresh();
         for(i=0;i<=MainForm->GlobalRecordPic;i++)   //length
             {
                for(n=0;n<16;n++)
                   {
                       if(n==0||n==8)
                          {
                             MainForm->PaintBox1->Canvas->Pen->Color=clBlack;
                          }
                       if(n==4||n==12)
                          {
                              MainForm->PaintBox1->Canvas->Pen->Color=clBlue;
                          }

                       MainForm->PaintBox1->Canvas->MoveTo(i,MainForm->file[i+kk*Page].Lead[n]*0.05*(MainForm->amp) + (2*n+1)*(MainForm->PaintBox1->Height-20)/Amplify+5);
                       MainForm->PaintBox1->Canvas->LineTo(i+1,MainForm->file[i+1+kk*Page].Lead[n]*0.05*(MainForm->amp) + (2*n+1)*(MainForm->PaintBox1->Height-20)/Amplify+5);
                    }

               }

    Timer3->Enabled =false;
}
//---------------------------------------------------------------------------
/*void __fastcall TMainForm::PaintBox1MouseMove(TObject *Sender,TShiftState Shift, int X, int Y)
{
 int n;
   int aa,bb;
   if (Button==mbLeft)
    {
      End_x=X;
      for (n=0;n<16;n=n+1)         // file[i+m*Page].Lead[0]*0.05*amp + (PaintBox1->Height-30)/Amplify)
       {  aa=(2*n+1)*(PaintBox1->Height-30)/Amplify;
          bb=(2*(n+1)+1)*(PaintBox1->Height-30)/Amplify;
          if ((Y>=aa)&&(Y<=bb))
           {
              Write_line(PaintBox1->Canvas,Start_x,aa,End_x,aa,clBlue);
              Write_line(PaintBox1->Canvas,Start_x,bb,End_x,bb,clBlue);
           }
       }
    }
}
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?