-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDataProcess.cpp
More file actions
2071 lines (1868 loc) · 56.2 KB
/
Copy pathDataProcess.cpp
File metadata and controls
2071 lines (1868 loc) · 56.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "stdafx.h"
#include "BCGPChartExample.h"
#include "Includes_app.h"
DataProcess::DataProcess()
{
}
DataProcess::~DataProcess()
{
}
/*************************************************
Copyright (C), SINNOWA. Co., Ltd.
File name: DataProcess.c
Author: liguoqing Version: 1.0 Date: 2010-07-07
Description: 数据处理
Others: 待改进: ResultsAnalysis只分析了原始数据
考虑查询的时候没有散点图
画图函数为一期调用,可以和平,其静态全局变量用于其共享
2011.1.1数据库中存放的都是原始数据(影响效率,但方便日后改动)
Important:
必须将存储到数据库的0x00做特殊处理,否则一旦遇到0x00存到数据库
并认为是字符串截止符,处理方式,所有的数据存入的时候统一加1
从数据库取出记录来的时候,统一减去1
Function List:
History:
create wsm 2010.11.4
*************************************************/
//分析计算参数宏定义
#define VOLAMP_WBCBASO 0.0015 //WBCBASO体积和放大相关倍数
#define VOL_RBCPLT 0.00027 //采样体积相关系数
#define AMP_RBC 0.97 //RBC放大倍数相关
#define AMP_PLT 0.125 //PLT放大倍数相关
//画图相关宏定义
#define LMNE_LEFT 340
#define LMNE_BOTTOM 365
#define LMNE_WIDTH 200//540-340 [0,255]->[340,540]
#define LMNE_HEIGHT 200
#define BASO_LEFT 570
#define BASO_BOTTOM 305
#define BASO_WIDTH 204//774-570 [0,255]->[570,774]
#define BASO_HEIGHT 105
#define RBC_LEFT 340
#define RBC_BOTTOM 525
#define RBC_WIDTH 204//544-340
#define RBC_HEIGHT 105
#define PLT_LEFT 570
#define PLT_BOTTOM 525
#define PLT_WIDTH 204 //774-570
#define PLT_HEIGHT 105 //525-420
#define COECALNUM 10
//HWND MainTestDlg;
//int PLTGraphEnd = 133;
extern int PLTGraphEnd=133;
float wbc_lmne = 0.0;
//用于开机测试流程与 TestWin.c 进行变量交互
extern bool StartupBlankTestsflag;
extern float StartupBlankTestswbc;
extern float StartupBlankTestsrbc;
extern float StartupBlankTestsplt;
extern bool IsBlankTest;
extern char studyPara[8][6];
static char wbc_hided_1[6], wbc_hided_2[6]; //用于记录两次WBC的结果
static char rbc_hided_1[6], rbc_hided_2[6];
static char plt_hided_1[6], plt_hided_2[6];
//从接受的数据帧中解析的各种细胞的个数,可以直接用sample_info中的结构体代替
//画散点图用,此变量定义比较特殊,使用时要注意
//访问函数列表:
//从接受的数据帧中解析的散射的细胞数据
static const char *static_param[28] =
{
"WBC",
"LYM%",
"NEU%",
"MONO%",
"EOS%",
"BASO%",
"ALY%",
"LIC%",
"LYM#",
"NEU#",
"MONO#",
"EOS#",
"BASO#",
"ALY#",
"LIC#",
"RBC",
"HGB",
"HCT",
"MCV",
"MCH",
"MCHC",
"RDW-CV",
"RDW-SD",
"PLT",
"MPV",
"PDW",
"PCT",
"P-LCR"
};
//中文
static const char *static_sampinfo_cn[6] =
{
"编号:",
"姓名:",
"性别:",
"科室:",
"年龄:",
"条码:"
};
//英文
static const char *static_sampinfo_en[6] =
{
"No.:",
"Name:",
"Sex:",
"Dept.:",
"Age:",
"Code:"
};
static const char *static_unit_WBC[4] =
{
"10^9/L",
"10^3/uL",
"10^2/uL",
"/nL"
};
static const char *static_unit_RBC[4] =
{
"10^12/L",
"10^6/uL",
"10^4/uL",
"/pL"
};
static const char *static_unit_HGB[3] =
{
"g/L",
"g/dL",
"mmol/L"
};
static const char *static_unit_MCVRDWSD[2] =
{
"fL",
"um^3"
};
static const char *static_unit_MCH[2] =
{
"pg",
"fmol"
};
static const char *static_unit_MCHC[3] =
{
"g/L",
"g/dL",
"mmol/L"
};
static const char *static_unit_PLT[4] =
{
"10^9/L",
"10^3/uL",
"10^4/uL",
"/nL"
};
static const char *static_unit_MPV[2] =
{
"fL",
"um^3"
};
double DataProcess::WbcForCompare = 0.0;
/***********************************************************
*Function:
*Description:对WBC RBC PLT 俩组数据进行比较
*Called by:
*Params illustration:
*Data Access:
*History:
************************************************************/
void DataProcess::BasoLmneRbcPlt_2Analyse(sample_info *psampledata)
{
unsigned short int i = 0;
unsigned char start = 0, end = 0;
signed int count_1, count_2;
float countResult = 0.0;
//count_wbc_flag = 0;
//count_rbc_flag = 0;
//count_plt_flag = 0;
TRACE("\nTwoGroupResultsAnalysis()====================\n");
//BASO
count_1 = 0;
count_2 = 0;
start = systemcfg.range.thresholds[BA1];
end = systemcfg.range.thresholds[BA3];
for (i = start; i <= end; i++)
{
count_1 += (*psampledata).basograph[i];//白细胞直方图数据[256]
count_2 += basograph_2[i];//第二组数据
}
TRACE("WbcBaso->wbc_count_1=%d----------#\n", count_1);
TRACE("WbcBaso->wbc_count_2=%d----------#\n", count_2);
if (count_1 >= 200) //对应wbc >= 0.3,即不是空白测试
{
if (count_1 <= 2666) //对应wbc < 4.0
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00) //FDparam 0.50,0.20,0.15参数确定
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.50)
{
(*psampledata).flag_wrp[0] = 2;
//count_wbc_flag = 1;
}
}
else if (count_1 <= 6666) //对应wbc <= 10.0
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.20)
{
//count_wbc_flag = 1;
(*psampledata).flag_wrp[0] = 2;
}
}
else
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.15)
{
//count_wbc_flag = 1;
(*psampledata).flag_wrp[0] = 2;
}
}
}
if (count_1 <= 66666) //确保测试结果<100.00,然后使用sprintf转换格式存到数据库中没有问题
{
countResult = count_1*VOLAMP_WBCBASO;
sprintf(wbc_hided_1, "%.2f", countResult);
}
if (count_2 <= 66666) //确保测试结果<100.00,然后使用sprintf转换格式存到数据库中没有问题
{
countResult = count_2*VOLAMP_WBCBASO;
sprintf(wbc_hided_2, "%.2f", countResult);
}
//RBC
count_1 = 0;
count_2 = 0;
start = systemcfg.range.thresholds[RB1];
end = systemcfg.range.thresholds[RB2];
for (i = start; i <= end; i++)
{
count_1 += (((psampledata->rbcgraph[(i << 1) + 1]) << 8) + psampledata->rbcgraph[i << 1]);
count_2 += (((rbcgraph_2[(i << 1) + 1]) << 8) + rbcgraph_2[i << 1]);
}
TRACE("Rbc->rbc_count_1=%d\n", count_1);
TRACE("Rbc->rbc_count_2=%d\n", count_2);
if (count_1 >= 186) //对应rbc >= 0.05,即认为不是空白测试
{
if (count_1 <= 14814) //对应rbc < 4.0
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00) //FDparam 0.50,0.20,0.15参数确定
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.50)
//count_rbc_flag = 1;
(*psampledata).flag_wrp[1] = 2;
}
else if (count_1 <= 20370) //对应wbc <= 5.5
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.20)
//count_rbc_flag = 1;
(*psampledata).flag_wrp[1] = 2;
}
else
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.15)
//count_rbc_flag = 1;
(*psampledata).flag_wrp[1] = 2;
}
}
if (count_1 <= 370370)
{
countResult = count_1*VOL_RBCPLT;
sprintf(rbc_hided_1, "%.2f", countResult);
}
if (count_2 <= 370370)
{
countResult = count_2*VOL_RBCPLT;
sprintf(rbc_hided_2, "%.2f", countResult);
}
//PLT
count_1 = 0;
count_2 = 0;
start = systemcfg.range.thresholds[PLT1];
end = systemcfg.range.thresholds[PLT2];
for (i = start; i <= end; i++)
{
count_1 += (*psampledata).pltgraph[i];
count_2 += pltgraph_2[i];
}
TRACE("Plt->plt_count_1=%d\n", count_1);
TRACE("Plt->plt_count_2=%d\n", count_2);
if (count_1 >= 38) //对应PLT >= 10 即不是空白测试
{
if (count_1 <= 370) //对应PLT < 100
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00) //FDparam 0.50,0.20,0.15参数确定
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.50)
//count_plt_flag = 1;
(*psampledata).flag_wrp[2] = 2;
}
else if (count_1 <= 1111) //对应PLT <= 300
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2)) / count_1 >= 0.20)
//count_plt_flag = 1;
(*psampledata).flag_wrp[2] = 2;
}
else
{
//if(1.0*fabs(count_1 - count_2)/count_1 > 1.00)
if (1.0*fabs((double)(count_1 - count_2))/ count_1 >= 0.15)
//count_plt_flag = 1;
(*psampledata).flag_wrp[2] = 2;
}
}
if (count_1 <= 37037)
{
countResult = count_1*1000.0*VOL_RBCPLT;
sprintf(plt_hided_1, "%.0f", countResult);
}
if (count_2 <= 37037)
{
countResult = count_2*1000.0*VOL_RBCPLT;
sprintf(plt_hided_2, "%.0f", countResult);
}
}
/***********************************************************
*Function:
*Description: 对接收的数据帧的数据(rdata所指空间)进行
分析(解析判断,并存入sampledata.basograph所指向的空间)
*Called by:
*Params illustration:
*Data Access:
*Other:
*History: create wsm 2010.12.31
************************************************************/
void DataProcess::WbcBasoAnalysis(sample_info *psampledata, uchar * pIsSuper)
{
unsigned short int i, j;
unsigned short int pointnum = 0;
float dist_temp = 0.0;
unsigned char tempbuff[256] = { 0 };
unsigned char start = 0, mid = 0, end = 0;
unsigned char maxval = 0;
unsigned char threshold = 0;
unsigned short int count_baso = 0;
unsigned short int count_wbc = 0;
unsigned short int temp0_BA1 = 0; //[0,BA1)之间的计数
float a = 0, b = 1.0, c = 0;
float cal = 1.0;
float wbc = 0;
float baso = 0;
float basop = 0;
TRACE("\nBasoAnalysis()====================\n");
for (i = 0; i < 256; i++) //BASO数据,共256通道
tempbuff[i] = ((*psampledata).basograph[i] + basograph_2[i]) / 2; // hw:20140521
//取有效数据段(幅值滤波)
start = systemcfg.range.thresholds[BA1];
mid = systemcfg.range.thresholds[BA2];
end = systemcfg.range.thresholds[BA3];
//求BASO总数
count_baso = 0;
for (i = mid; i <= end; i++)
count_baso += tempbuff[i];
TRACE("count_baso=%d---------#\n", count_baso);
//求WBC总数
count_wbc = count_baso;
for (i = start; i < mid; i++)
count_wbc += tempbuff[i];
TRACE("count_wbc=%d---------#\n", count_wbc);
//求[0,BA1)之间的总数
temp0_BA1 = 0;
for (i = 0; i < start; i++)
temp0_BA1 += tempbuff[i];
TRACE("temp0_BA1=%d---------#\n", temp0_BA1);
if (count_wbc > 0)//保证不为0
{
//L1
if ((float)temp0_BA1 / (temp0_BA1 + count_wbc) > 0.03) //FDparam 参考ABX
(*psampledata).basoflg[0] = 2;
}
if (count_wbc <= 66666 && count_wbc > 0) //确保测试结果<100.00,然后使用sprintf转换格式存到数据库中没有问题
{
//baso
basop = (100.0*count_baso) / count_wbc;
//baso#
baso = count_baso*VOLAMP_WBCBASO;
//wbc
a = systemcfg.modify[systemcfg.mode].a[MOD_WBCF];
b = systemcfg.modify[systemcfg.mode].b[MOD_WBCF];
c = systemcfg.modify[systemcfg.mode].c[MOD_WBCF];
wbc = count_wbc*VOLAMP_WBCBASO;
WbcForCompare = wbc;
wbc = systemcfg.calibration[systemcfg.mode][CAL_WBCF] * fabs(a*wbc*a*wbc + b*wbc + c);
}
maxval = tempbuff[start];
for (i = start + 1; i <= end; i++)
if (tempbuff[i] > maxval)
maxval = tempbuff[i];
TRACE("BASO->maxval=%d---------#\n", maxval);
//threshold = (int)(maxval*(BASO_HEIGHT)/(BASO_HEIGHT+55.0));
threshold = (int)((float)maxval*(BASO_HEIGHT) / (BASO_HEIGHT + 58.33)); //58.33有什么依据没 xx22
if (threshold != 0)
cal = (float)BASO_HEIGHT / threshold;
else
cal = 1.0;
//图形调整
for (i = start; i <= end; i++)
{
if (tempbuff[i] > threshold)
tempbuff[i] = BASO_HEIGHT;
else
tempbuff[i] *= cal;
}
//WBC值小于0.3图形不显示
if (wbc < 0.3)
{
for (i = 0; i < 256; i++)
tempbuff[i] = 0;
}
else
{
//hw_temp:
// pointnum = 4;
// for(i = 0;i < 63;i++)
// {
// dist_temp = tempbuff[1 + pointnum*(i+1)] -tempbuff[1 + pointnum*i];
// for(j = 2; j <= pointnum; j++)
// tempbuff[j + pointnum*i] = dist_temp*(j-1)/pointnum + tempbuff[1 + pointnum*i] ;
// }
// tempbuff[254] = tempbuff[253]*2/3;
// tempbuff[255] = tempbuff[253]*1/3;
//------------------------------------
//加权滤波
for (i = start + 1; i <= end - 1; i++)
tempbuff[i] = 0.4*tempbuff[i - 1] + 0.4*tempbuff[i] + 0.2*tempbuff[i + 1];
for (i = start + 3; i <= end - 3; i++)
tempbuff[i] = 0.3*tempbuff[i - 2] + 0.3*tempbuff[i - 1] + 0.2*tempbuff[i] + 0.1*tempbuff[i + 1] + 0.1*tempbuff[i + 1];
}
//加1处理,消除0x00截止符,否则以TEXT格式存入数据库会有问题
for (i = 0; i < start; i++)
(*psampledata).basograph[i] = 1;
for (i = start; i <= end; i++)
(*psampledata).basograph[i] = tempbuff[i] + 1;
for (i = end + 1; i < 255; i++)
(*psampledata).basograph[i] = 1;
psampledata->basograph[255] = 0;
//------------------------------------------------
//如果进行开机测试则对原始数据进行保存
if (StartupBlankTestsflag)
{
StartupBlankTestswbc = wbc;
}
//----------------------------------------
//判断并格式转换
if (*pIsSuper == 0 && (!IsBlankTest)) //非密码进入非空白
{
if (wbc < 0.5)
{
if (wbc < 0.3)
wbc = 0;
sprintf((*psampledata).wbcdata.wbc, "%.2f", wbc);
//其它相关参数都是初始化的值即"*"号
(*psampledata).basoflg[0] = 1;
}
else if (basop < 8.0) //BASO不超过8% hw_temp:20141231
{
sprintf((*psampledata).wbcdata.wbc, "%.2f", wbc);
sprintf((*psampledata).wbcdata.basp, "%.1f", basop);
sprintf((*psampledata).wbcdata.bas, "%.2f", baso);
}
else
{
printf("basop:%.2f\n", basop);
}
}
else
{
if (wbc < 0.5)
{
if (wbc < 0.3)
wbc = 0;
sprintf((*psampledata).wbcdata.wbc, "%.2f", wbc);
//其它相关参数都是初始化的值即"*"号
(*psampledata).basoflg[0] = 1;
}
else
{
sprintf((*psampledata).wbcdata.wbc, "%.2f", wbc);
sprintf((*psampledata).wbcdata.basp, "%.1f", basop);
sprintf((*psampledata).wbcdata.bas, "%.2f", baso);
}
}
}
/***********************************************************
*Function:
*Description: 对接受到散点图的电阻抗放大
*Called by:
*Params illustration:
*Data Access:
*Other:
*History:
1.信号放大部分
2.若不是工程师进入 ,则电阻抗值进行自动调整或者工程师可以设置要不要自动调整
************************************************************/
void DataProcess::LmneAmpRes(sample_info *psampledata) //xx22 暂时没用到
{
unsigned int i;
unsigned char res = 0; //电阻抗信号
unsigned char mark1 = 0;
unsigned char mark2 = 0;
unsigned short int resb[256] = { 0 };
unsigned short int numtemp = 0;
unsigned short int max1num = 0;
unsigned short int max2num = 0;
unsigned char max1res = 0;
unsigned char max2res = 0;
float amp1 = 0.0, amp3 = 0.0;
unsigned char max1res_amped = 0; //放大后的峰值电阻抗
unsigned char max2res_amped = 0;
mark1 = systemcfg.lmnepeak1;
mark2 = systemcfg.lmnepeak2;
for (i = 0; i < 256; i++)
resb[i] = 0;
for (i = 0; i < MATRIX_POINT_MAX; i++)
{
res = (*psampledata).lmnegraph[(i << 1)];
resb[res]++;
}
//[mark1-10,mark1+10] //10 xx22
max1num = resb[mark1 - 10 - 2] + resb[mark1 - 10 - 1] + resb[mark1 - 10] + resb[mark1 - 10 + 1] + resb[mark1 - 10 + 2]; //先不除5,避免精度损失
max1res = mark1 - 10;
for (i = mark1 - 9; i <= mark1 + 10; i++)
{
numtemp = resb[i - 2] + resb[i - 1] + resb[i] + resb[i + 1] + resb[i + 2];
if (numtemp > max1num)
{
max1num = numtemp;
max1res = i;
}
}
//[mark2-10,mark2+10] //10 xx22
max2num = resb[mark2 - 10 - 2] + resb[mark2 - 10 - 1] + resb[mark2 - 10] + resb[mark2 - 10 + 1] + resb[mark2 - 10 + 2];//先不除5,避免精度损失
max2res = mark2 - 10;
for (i = mark2 - 9; i <= mark2 + 10; i++)
{
numtemp = resb[i - 2] + resb[i - 1] + resb[i] + resb[i + 1] + resb[i + 2];
if (numtemp > max2num)
{
max2num = numtemp;
max2res = i;
}
}
if (mark1 / max1res < 0.7)
amp1 = 0.7;
else if (mark1 / max1res > 1.3)
amp1 = 1.3;
else
amp1 = mark1 / max1res;
max1res_amped = amp1*max1res;
if (mark2 / max2res < 0.7)
amp3 = 0.7;
else if (mark1 / max1res > 1.3)
amp3 = 1.3;
else
amp3 = mark2 / max1res;
max2res_amped = amp3*max2res;
//保证max1res < max2res
for (i = 0; i < MATRIX_POINT_MAX; i++)
{
res = (*psampledata).lmnegraph[(i << 1)];
if (res <= max1res)
(*psampledata).lmnegraph[(i << 1)] = res*amp1;
else if (res >= max2res)
(*psampledata).lmnegraph[(i << 1)] = max2res_amped + (res - max2res)*(255 - max2res_amped) / (255 - max2res);
else
(*psampledata).lmnegraph[(i << 1)] = max1res_amped + (res - max1res)*(max2res_amped - max1res_amped) / (max2res - max1res);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//Description: 计算散点图界标移动系数 //
//Called by: LmneAnalysis //
//Params illustration: //
//Data Access: //
//Other: //
//*History: //
// (1)Created:20150127 //
//////////////////////////////////////////////////////////////////////////////////////////
void DataProcess::LmneCoeCalculate(sample_info *psampledata) //xx22 暂时没用到
{
unsigned int i;
unsigned char res = 0; //电阻抗信号
unsigned char mark1 = 0;
unsigned short int resb[256] = { 0 };
unsigned short int numtemp = 0;
unsigned short int max1num = 0;
unsigned char max1res = 0;
float coe = 1.0;
int board = 3 * systemcfg.lmnepeak1 / 10;
int calboard = 2 * systemcfg.lmnepeak1 / 10;
printf("board:%d calboard:%d\n", board, calboard);
mark1 = systemcfg.lmnepeak1;
for (i = 0; i < 256; i++)
resb[i] = 0;
for (i = 0; i < MATRIX_POINT_MAX; i++)
{
res = (*psampledata).lmnegraph[(i << 1)];
resb[res]++;
}
//[mark1-10,mark1+10] //10 xx22
max1num = resb[mark1 - board - 2] + resb[mark1 - board - 1] + resb[mark1 - board] + resb[mark1 - board + 1] + resb[mark1 - board + 2]; //先不除5,避免精度损失
max1res = mark1 - board;
for (i = mark1 - board + 1; i <= mark1 + board; i++)
{
numtemp = resb[i - 2] + resb[i - 1] + resb[i] + resb[i + 1] + resb[i + 2];
if (numtemp > max1num)
{
max1num = numtemp;
max1res = i;
}
}
printf("mark1:%d res:%d\n", mark1, max1res);
if ((max1res < (mark1 - calboard)) || (max1res >(mark1 + calboard)))
coe = (float)max1res / mark1; //返回系数
printf("coe:%.2f\n", coe);
if (coe < (1.0 - 0.3))
coe = 1.0 - 0.3;
else if (coe > 1.0 + 0.3)
coe = 1.0 + 0.3;
psampledata->coeoflmne = coe;
}
//////////////////////////////////////////////////////////////////////////////////////////
//Description: 动态初始化LMNE散点图各区域界标值 //
//Called by: LmneAnalysis //
//Params illustration: //
//Data Access: //
//Other: //
//*History: //
// (1)Created:20150121 //
//////////////////////////////////////////////////////////////////////////////////////////
void DataProcess::Init_B_LMNE(float coefficient, B_LMNE* p_blmne)
{
float coe_rtoabs;
//Resistance
p_blmne->X_NOL = (uchar)systemcfg.range.thresholds[NoL] * coefficient;
p_blmne->X_NON = (uchar)systemcfg.range.thresholds[NoN] * coefficient;
p_blmne->X_LL = (uchar)systemcfg.range.thresholds[LL] * coefficient;
p_blmne->X_LN = (uchar)systemcfg.range.thresholds[LN] * coefficient;
p_blmne->X_AL = (uchar)systemcfg.range.thresholds[AL] * coefficient;
p_blmne->X_LMN = (uchar)systemcfg.range.thresholds[LMN] * coefficient;
p_blmne->X_LMU = (uchar)systemcfg.range.thresholds[LMU] * coefficient;
p_blmne->X_MN = (uchar)systemcfg.range.thresholds[MN] * coefficient;
p_blmne->X_LMD = (uchar)systemcfg.range.thresholds[LMD] * coefficient;
p_blmne->X_NOE = (uchar)systemcfg.range.thresholds[NoE] * 1.0;
p_blmne->X_RM = (uchar)systemcfg.range.thresholds[RM] * 1.0;
p_blmne->X_RN = (uchar)systemcfg.range.thresholds[RN] * 1.0;
coe_rtoabs = coefficient * 1.0;
//Absorbance
p_blmne->Y_NL = (uchar)systemcfg.range.thresholds[NL] * coe_rtoabs;
p_blmne->Y_RMN = (uchar)systemcfg.range.thresholds[RMN] * coe_rtoabs;
p_blmne->Y_NE = (uchar)systemcfg.range.thresholds[NE] * coe_rtoabs;
}
/***********************************************************
*Function:
*Description: 对接受数据的matrix_lmen[MATRIX_POINT_MAX]处理
*Called by:
*Params illustration:
*Data Access:
*Other:
1、测试时,将接受的LMNE数据 解析,获得所需参数并画出散点图
2、查询数据库时,将数据库中的LMNE数据解析,画出散点图
*History: create lgq 2010.7.20
mod wsm 2010.11.5
************************************************************/
int DataProcess::LmneAnalysis(sample_info *psampledata, uchar* pIsSuper)
{
unsigned int i;
unsigned char res = 0, scatter = 0; //电阻抗信号、光散射信号
unsigned short int count_eos = 0;
unsigned short int count_neu = 0;
unsigned short int count_lneu = 0;
unsigned short int count_rneu = 0;
unsigned short int count_lym = 0;
unsigned short int count_llym = 0;
unsigned short int count_rlym = 0;
unsigned short int count_mono = 0;
unsigned short int count_rmono = 0;
unsigned short int count_fln = 0; //报警区的计数
unsigned short int count_fne = 0; //报警区的计数
unsigned short int count_fmn = 0; //报警区的计数
unsigned short int count_aly = 0;
unsigned short int count_lic = 0;
unsigned short int count_noise = 0;
unsigned short int count_blood = 0;
float coefficient = 0.0;
float wbc = 0.0;
float lymp = 0.0;
float neup = 0.0;
float monop = 0.0;
float eosp = 0.0;
float alyp = 0.0;
float licp = 0.0;
float lym = 0.0;
float neu = 0.0;
float mono = 0.0;
float eos = 0.0;
float aly = 0.0;
float lic = 0.0;
//研究参数
unsigned short int count_blasts = 0;
float blastsp = 0.0;
float leftp = 0.0;
float nrbcp = 0.0;
float blasts = 0.0;
float left = 0.0;
float nrbc = 0.0;
int retn = 0;
B_LMNE m_blmne;
TRACE("\nLmneAnalysis()====================\n");
for (i = 0; i < MATRIX_DATA_MAX; i++)
{
if ((*psampledata).lmnegraph[i] != 0)
{
retn++;
if (255 == (*psampledata).lmnegraph[i])
(*psampledata).lmnegraph[i] = 254;
}
}
if (retn == 0)
return -1;
//判断,计算psampledata->coeoflmne值(普通用户模式非空白测试)
if (*pIsSuper == 0 && (!IsBlankTest) && systemcfg.LMNEMarkMode == 1)
{
LmneCoeCalculate(psampledata);
}
//printf("coeoflmne:%.1f\n",psampledata->coeoflmne);
Init_B_LMNE(psampledata->coeoflmne, &m_blmne);
for (i = 0; i < MATRIX_POINT_MAX; i++)
{
res = (*psampledata).lmnegraph[(i << 1)];
scatter = (*psampledata).lmnegraph[(i << 1) + 1];
if (scatter >= m_blmne.Y_NE)
{
if (res < m_blmne.X_NOE)
count_noise++;
else
{
count_eos++;
if (scatter < m_blmne.Y_NE + systemcfg.range.thresholds[FNE])
count_fne++;
}
if (res >= 250)//研究参数 //xx21 250只是一个暂时的变量,其它也是
{
count_blasts++;
}
}
else if (scatter >= m_blmne.Y_RMN)
{
if (res < m_blmne.X_NON)
count_noise++;
else if (res < m_blmne.X_LN)
count_lneu++;
else if (res < m_blmne.X_RN)
count_neu++;
else
count_rneu++;
if (res >= 250)//研究参数
{
count_blasts++;
}
}
else if (scatter >= m_blmne.Y_NL)
{
if (res < m_blmne.X_NON)
count_noise++;
else if (res < m_blmne.X_LN)
{
count_lneu++;
if (scatter < m_blmne.Y_NL + systemcfg.range.thresholds[FLN])
count_fln++;
}
else if (res < m_blmne.X_LMN)
{
count_neu++;
if (scatter < m_blmne.Y_NL + systemcfg.range.thresholds[FLN])
count_fln++;
}
else if (res < m_blmne.X_MN)
{
if ((res - m_blmne.X_LMN)*(m_blmne.Y_RMN - m_blmne.Y_NL) <
(m_blmne.X_MN - m_blmne.X_LMN)*(scatter - m_blmne.Y_NL))
{
count_neu++;
if (scatter <= m_blmne.Y_NL + systemcfg.range.thresholds[FMN] || res >= m_blmne.X_MN - systemcfg.range.thresholds[FMN] ||
((res - m_blmne.X_LMN)*(m_blmne.Y_RMN - m_blmne.Y_NL - systemcfg.range.thresholds[FMN]) >
(m_blmne.X_MN - m_blmne.X_LMN - systemcfg.range.thresholds[FMN])*(scatter - m_blmne.Y_NL - systemcfg.range.thresholds[FMN])))
count_fmn++;
}
else
count_mono++;
}
else if (res < m_blmne.X_RM)
count_mono++;
else
count_rmono++;
if (res >= 250)//研究参数
{
count_blasts++;
}
}
else
{
if (res < m_blmne.X_NOL)
count_noise++;
else if (res < m_blmne.X_LL)
count_llym++;
else if (res < m_blmne.X_AL)
count_lym++;
else if (res < m_blmne.X_LMU)
count_rlym++;
else if (res < m_blmne.X_LMD)
{
if ((m_blmne.X_LMD - res)*m_blmne.Y_NL >
(m_blmne.X_LMD - m_blmne.X_LMU)*scatter)
count_rlym++;
else
count_mono++;
}
else if (res < m_blmne.X_RM)
count_mono++;
else
count_rmono++;
if (res >= 250)//研究参数
{
count_blasts++;
}
}
}
count_blood = count_llym + count_rlym + count_lym + count_lneu + count_rneu + count_neu + count_rmono + count_mono + count_eos;
count_lic = count_rneu + count_rmono;
count_aly = count_rlym;
//blood
TRACE("count_blood=%d---------#\n", count_blood);
//lym
TRACE("count_llym=%d---------#\n", count_llym);
TRACE("count_rlym=%d---------#\n", count_rlym);
TRACE("count_lym=%d---------#\n", count_lym);
//neu
TRACE("count_lneu=%d---------#\n", count_lneu);
TRACE("count_rneu=%d---------#\n", count_rneu);
TRACE("count_neu=%d---------#\n", count_neu);
//mono
TRACE("count_rmono=%d---------#\n", count_rmono);
TRACE("count_mono=%d---------#\n", count_mono);
//eos
TRACE("count_eos=%d---------#\n", count_eos);
//aly
TRACE("count_aly=%d---------#\n", count_aly);
//lic
TRACE("count_lic=%d---------#\n", count_lic);
//nosie
TRACE("count_noise=%d---------#\n", count_noise);
//研究参数
//blasts
TRACE("count_blasts=%d---------#\n", count_blasts);
//left
TRACE("count_left=%d---------#\n", count_lneu);
//nrbc
TRACE("count_nrbc=%d---------#\n", count_llym);
if (count_blood > 0)//除数不为0
{
//NO
if (count_noise > 120) //FDparam 及下面几个,参考ABX
(*psampledata).lmneflg[0] = 2;
//LL
if (count_llym > 50)
(*psampledata).lmneflg[1] = 2;
//LL1
if (count_llym > 45 && (float)count_llym / count_blood > 0.05)
(*psampledata).lmneflg[2] = 2;
//NL
if (count_fln > 120 || (float)count_fln / count_blood > 0.03)
(*psampledata).lmneflg[3] = 2;
//MN
if (count_fmn > 120)
(*psampledata).lmneflg[4] = 2;
//RM
if (count_rmono > 999 || (float)count_rmono / count_blood > 0.011)
(*psampledata).lmneflg[5] = 2;
//LN
if (count_lneu > 999 || (float)count_lneu / count_blood > 0.025)
(*psampledata).lmneflg[6] = 2;
//RN
if (count_rneu > 999 || (float)count_rneu / count_blood > 0.011)
(*psampledata).lmneflg[7] = 2;
//NE
if (count_fne > 60 || (float)count_fne / count_blood > 0.011)
(*psampledata).lmneflg[8] = 2;
}