typedef __nogc struct HDRBLKtag{ long Var_length_block_size; long Sample_Size_ECG; long Offset_var_lenght_block; long Offset_ECG_block; short int File_Version; unsigned char First_Name[40]; unsigned char Last_Name[40]; unsigned char ID[20]; short int Sex; short int Race; short int Birth_Date[3]; short int Record_Date[3]; short int File_Date[3]; short int Start_Time[3]; short int nLeads; short int Lead_Spec[12]; short int Lead_Qual[12]; short int Resolution[12]; short int Pacemaker; unsigned char Recorder[40]; short int Sampling_Rate; unsigned char Proprietary[80]; unsigned char Copyright[80]; unsigned char Reserved[88]; } ISNEHeader; // This function read the Ishne ECG files void readIshneECG(String * strFileName) { int i, j; FileStream *fsIn; BinaryReader *br; System::Windows::Forms::DialogResult result; unsigned char magicnumber __gc[]; unsigned short checksum; try { fsIn = File::OpenRead(strFileName); br = new BinaryReader(fsIn); // get magic number magicnumber = br->ReadBytes(8); // get checksum checksum = br->ReadInt16(); ///////////// read header ///////////////////// // get Var_length_block_size m_ISHNEHeader.Var_length_block_size = br->ReadInt32(); // get Sample_Size_ECG m_ISHNEHeader.Sample_Size_ECG = br->ReadInt32(); // get Offset_var_length_block m_ISHNEHeader.Offset_var_lenght_block = br->ReadInt32(); // get Offset_ECG_block m_ISHNEHeader.Offset_ECG_block = br->ReadInt32(); // get File_Version m_ISHNEHeader.File_Version = br->ReadInt16(); // get First_Name for (i = 0; i < 40; i++) m_ISHNEHeader.First_Name[i] = (char)br->ReadByte(); // get Last_Name for (i = 0; i < 40; i++) m_ISHNEHeader.Last_Name[i] = (char)br->ReadByte(); // get ID for (i = 0; i < 20; i++) m_ISHNEHeader.ID[i] = (char)br->ReadByte(); // get Sex m_ISHNEHeader.Sex = br->ReadInt16(); // get Race m_ISHNEHeader.Race = br->ReadInt16(); // get Birth_Date for (i = 0; i < 3; i++) m_ISHNEHeader.Birth_Date[i] = br->ReadInt16(); // get Record_Date for (i = 0; i < 3; i++) m_ISHNEHeader.Record_Date[i] = br->ReadInt16(); // get File_Date for (i = 0; i < 3; i++) m_ISHNEHeader.File_Date[i] = br->ReadInt16(); // get Start_Time for (i = 0; i < 3; i++) m_ISHNEHeader.Start_Time[i] = br->ReadInt16(); // get nLeads; m_ISHNEHeader.nLeads = br->ReadInt16(); // get Lead_Spec for (i = 0; i < 12; i++) m_ISHNEHeader.Lead_Spec[i] = br->ReadInt16(); // get Lead_Qual for (i = 0; i < 12; i++) m_ISHNEHeader.Lead_Qual[i] = br->ReadInt16(); // get Resolution for (i = 0; i < 12; i++) m_ISHNEHeader.Resolution[i] = br->ReadInt16(); // get Pacemaker m_ISHNEHeader.Pacemaker = br->ReadInt16(); // get Recorder for (i = 0; i < 40; i++) m_ISHNEHeader.Recorder[i] = (char)br->ReadByte(); // get Sampling_Rate m_ISHNEHeader.Sampling_Rate = br->ReadInt16(); // get Propriety for (i = 0; i < 80; i++) m_ISHNEHeader.Proprietary[i] = (char)br->ReadByte(); // get Copyright for (i = 0; i < 80; i++) m_ISHNEHeader.Copyright[i] = (char)br->ReadByte(); // get Reserved for (i = 0; i < 88; i++) m_ISHNEHeader.Reserved[i] = (char)br->ReadByte(); if (m_ISHNEHeader.Var_length_block_size > 0) { varblock = new char __gc[m_ISHNEHeader.Var_length_block_size]; varblock = br->ReadBytes(m_ISHNEHeader.Var_length_block_size); } // read ECG data short data; for (i = 0; i < m_ISHNEHeader.Sample_Size_ECG; i++) { for (j = 0; j < m_ISHNEHeader.nLeads; j++) { data = br->ReadInt16(); } } br->Close(); fsIn->Close(); } catch (Exception *ex) { result = MessageBox::Show (String::Concat("Exception in reading Ishne ECG file: ", ex->Message), "Read ECG", MessageBoxButtons::OK, MessageBoxIcon::Asterisk); } } // The function reads the binary formatted Ishen annotation file void readIshneAnnotation(String * strFileName) { int i, j, loc; unsigned char ann, internalUse; unsigned short RR; FileStream *fsIn; BinaryReader *br; System::Windows::Forms::DialogResult result; unsigned char magicnumber __gc[]; unsigned short checksum; try { fsIn = File::OpenRead(strFileName); br = new BinaryReader(fsIn); // get magic number magicnumber = br->ReadBytes(8); // get checksum checksum = br->ReadInt16(); ///////////// read header ///////////////////// // get Var_length_block_size m_ISHNEHeader.Var_length_block_size = br->ReadInt32(); // get Sample_Size_ECG m_ISHNEHeader.Sample_Size_ECG = br->ReadInt32(); // get Offset_var_length_block m_ISHNEHeader.Offset_var_lenght_block = br->ReadInt32(); // get Offset_ECG_block m_ISHNEHeader.Offset_ECG_block = br->ReadInt32(); // get File_Version m_ISHNEHeader.File_Version = br->ReadInt16(); // get First_Name for (i = 0; i < 40; i++) m_ISHNEHeader.First_Name[i] = (char)br->ReadByte(); // get Last_Name for (i = 0; i < 40; i++) m_ISHNEHeader.Last_Name[i] = (char)br->ReadByte(); // get ID for (i = 0; i < 20; i++) m_ISHNEHeader.ID[i] = (char)br->ReadByte(); // get Sex m_ISHNEHeader.Sex = br->ReadInt16(); // get Race m_ISHNEHeader.Race = br->ReadInt16(); // get Birth_Date for (i = 0; i < 3; i++) m_ISHNEHeader.Birth_Date[i] = br->ReadInt16(); // get Record_Date for (i = 0; i < 3; i++) m_ISHNEHeader.Record_Date[i] = br->ReadInt16(); // get File_Date for (i = 0; i < 3; i++) m_ISHNEHeader.File_Date[i] = br->ReadInt16(); // get Start_Time for (i = 0; i < 3; i++) m_ISHNEHeader.Start_Time[i] = br->ReadInt16(); // get nLeads; m_ISHNEHeader.nLeads = br->ReadInt16(); // get Lead_Spec for (i = 0; i < 12; i++) m_ISHNEHeader.Lead_Spec[i] = br->ReadInt16(); // get Lead_Qual for (i = 0; i < 12; i++) m_ISHNEHeader.Lead_Qual[i] = br->ReadInt16(); // get Resolution for (i = 0; i < 12; i++) m_ISHNEHeader.Resolution[i] = br->ReadInt16(); // get Pacemaker m_ISHNEHeader.Pacemaker = br->ReadInt16(); // get Recorder for (i = 0; i < 40; i++) m_ISHNEHeader.Recorder[i] = (char)br->ReadByte(); // get Sampling_Rate m_ISHNEHeader.Sampling_Rate = br->ReadInt16(); // get Propriety for (i = 0; i < 80; i++) m_ISHNEHeader.Proprietary[i] = (char)br->ReadByte(); // get Copyright for (i = 0; i < 80; i++) m_ISHNEHeader.Copyright[i] = (char)br->ReadByte(); // get Reserved for (i = 0; i < 88; i++) m_ISHNEHeader.Reserved[i] = (char)br->ReadByte(); if (m_ISHNEHeader.Var_length_block_size > 0) { varblock = new char __gc[m_ISHNEHeader.Var_length_block_size]; varblock = br->ReadBytes(m_ISHNEHeader.Var_length_block_size); } // read annotation // read first location loc = br->ReadInt32(); while (br->PeekChar() != -1) { // read ann and internalUse ann = br->ReadByte(); internalUse = br->ReadByte(); // read RR RR = br->ReadUInt16(); loc += RR; } br->Close(); fsIn->Close(); } catch (Exception *ex) { result = MessageBox::Show (String::Concat("Exception in reading Ishne annotation file: ", ex->Message), "Read Annotation", MessageBoxButtons::OK, MessageBoxIcon::Asterisk); } }