#include "ROI.h" #include "ProcessAlgorithmGlobalVar.h" #include bool CROI::CalcNetCounts(NetCountsI& _net_counts,QVector& _output) { //计算同位素系数 bool bRet=false; double F135; double F133; double F131m; double F133m; bRet = CalcF(_net_counts.time,global::cst_d_decay_135xeg_lam,F135); if(!bRet) { return false; } bRet = CalcF(_net_counts.time,global::cst_d_decay_133xeg_lam,F133); if(!bRet) { return false; } bRet = CalcF(_net_counts.time,global::cst_d_decay_131xem_lam,F131m); if(!bRet) { return false; } bRet = CalcF(_net_counts.time,global::cst_d_decay_133xem_lam,F133m); if(!bRet) { return false; } QVector factor; factor.append(F135); factor.append(F133); factor.append(F133); factor.append(F131m); factor.append(F133m); factor.append(F133); //通过系数计算净计数总数 bRet = CalcNetCountsByFactor(_net_counts,factor,_output); if(!bRet) { return false; } return true; } bool CROI::CalcF(SGTime& _time,double _Xe,double& _output) { double drData = 1-qExp(-_Xe*_time.g_acquisition_real_time); if(!_time.g_acquisition_live_time || !_time.s_acquisition_real_time || !drData) { return false; } else { drData = (_time.g_acquisition_real_time/_time.g_acquisition_live_time)*(_time.s_acquisition_live_time/_time.s_acquisition_real_time)*qExp(-_Xe*_time.gtos_acqStartDiff)* \ (1-qExp(-_Xe*_time.s_acquisition_real_time))/drData; } _output = drData; return true; } bool CROI::CalcNetCountsByFactor(NetCountsI& _net_counts,QVector& _factor,QVector& _output) { QVector::size_type size = _net_counts.g_netXe.size(); //参数传入判断 if(size!=_net_counts.s_netXe.size()) { return false; } QVector rData(size,0); bool bPara1 = true;//默认为一行一个参数 QVector::size_type bParaPos = 6; //系数起始位 此处理函数没有用到前六个系数 if(size>_factor.size()) //系数个数判断 { bPara1 = false; bParaPos = 0; } //提取数据 double factor = 1.0; const int detuct_grpnm = 3; const int pos_cts = 0; //扣除 计数偏移 const int pos_vari = 1; //偏差偏移 const int pos_level = 2; //关键水平偏移 const int pos_net_counts=0;//输出净计数 偏移值 const int pos_net_counts_vari=1; //净计数偏差 偏移值 const int pos_net_counts_0_vari=2; //净计数 0 信号偏移值 for(QVector::size_type pos=2*detuct_grpnm;pos+pos_level& _output) { const int group_num = 3; //每组个数为3 const int pos_cts = 0; //净计数位置 const int pos_variance = 1; //误差位置 const int pos_level =2; //关键水平位置 const int pos_one_ratios =-1; //比率第一组相对下标值 const int pos_two_ratios =6; //比率第二组相对下标值 QVector rData(group_num,0); QVector::size_type size = _input.roi_cts.size(); //大小判断 if(size-1+pos_two_ratios>=_input.roi_ratios.size()||size>_input.roi_detbg_cts.size()) { return false; } // QVector::size_type pos = 0; double dKTemp; double dVTemp; double dLTemp; double dKtempFactor=0.0; double dVTempFactor=0.0; for(QVector::size_type pos=0;posrData.at(1*group_num+pos_level)) { if(pos>=3)//第三组以后 { double qvctRatiosData1 = _input.roi_ratios.at(pos+pos_one_ratios); double qvctRatiosData2 = _input.roi_ratios.at(pos+pos_two_ratios); if(rData.at(3*group_num+pos_cts)>rData.at(3*group_num+pos_level))//第三组k 大于第三组lk { dKtempFactor = -(qvctRatiosData1*rData.at(1*group_num+pos_cts) + qvctRatiosData2*rData.at(3*group_num+pos_cts)); dVTempFactor = qvctRatiosData1*qvctRatiosData1*rData.at(1*group_num+pos_variance)+qvctRatiosData2*qvctRatiosData2*rData.at(3*group_num+pos_variance); } else { dKtempFactor = -(qvctRatiosData1*rData.at(1*group_num+pos_cts)); dVTempFactor = qvctRatiosData1*qvctRatiosData1*rData.at(1*group_num+pos_variance); } } else // 1 2 组处理 { double qvctRatiosData = _input.roi_ratios.at(pos+pos_one_ratios); dKtempFactor = -(qvctRatiosData*rData.at(1*group_num+pos_cts)); dVTempFactor = qvctRatiosData*qvctRatiosData*rData.at(1*group_num+pos_variance); } } else { if(pos>=3)//第三组以后 { double qvctRatiosData2 = _input.roi_ratios.at(pos+pos_two_ratios); if(rData.at(3*group_num+pos_cts)>rData.at(3*group_num+pos_level))//第三组k 大于第三组lk { dKtempFactor = -(qvctRatiosData2*rData.at(3*group_num+pos_cts)); dVTempFactor = qvctRatiosData2*qvctRatiosData2*rData.at(3*group_num+pos_variance); } else { //没有系数 } } else// 1 2 组处理 { //没有系数 } } } //净计数 dKTemp = _input.roi_cts.at(pos)-_input.ratio*_input.roi_detbg_cts.at(pos)+dKtempFactor; //不确定度 dVTemp = _input.roi_cts.at(pos)+_input.ratio*_input.ratio*_input.roi_detbg_cts.at(pos)+dVTempFactor; //关键水平 if((dVTemp-dKTemp)<0) { return false; } dLTemp = global::cst_k*qSqrt(dVTemp-dKTemp); rData.append(dKTemp); rData.append(dVTemp); rData.append(dLTemp); } _output = rData; return true; } bool CROI::ExtractROIcts(ROIctsI& _input,ROIctsO& _output) { bool bRet = false; //获取总计数 bRet = CalcROIctsByBoundary(_input.roi_boundary,_input.histogram,_output.roi_cts); if(!bRet) { return false; } return true; } bool CROI::CalcROIctsByBoundary(ROIBoundary& _boundary,Histogram& _histogram,QVector& _output) { //10个通道数据 QVector qdDataTemp(10,0); QString qsDataTemp; //参数判断 if(_boundary.ROI_B_start_x.size()<10||\ _boundary.ROI_B_stop_x.size()<10||\ _boundary.ROI_G_start_y.size()<10||\ _boundary.ROI_G_stop_y.size()<10) { return false; } for(int roi=0;roi<10;roi++) //提取 { qdDataTemp[roi] = 0; QVector::size_type base = 0; // int row = 0; int y=0; for(;y<_boundary.ROI_G_start_y[roi];y++) { //row } base = y; // QVector::size_type y=_boundary.ROI_G_start_y[roi]-1; // base = y+1; for(y=0;y<(_boundary.ROI_G_stop_y[roi]-_boundary.ROI_G_start_y[roi]+1);y++) { for(QVector::size_type x=_boundary.ROI_B_start_x[roi];x<=_boundary.ROI_B_stop_x[roi];x++) { if((base+y)*_histogram.b_channels+x<_histogram.counts.size()&&((base+y)*_histogram.b_channels+x)>=0) { qdDataTemp[roi] += _histogram.counts.at((base+y)*_histogram.b_channels+x); } else { return false; } } } } _output = qdDataTemp; return true; } bool CROI::CalcLimitToBoundary(QVector& _ROI_limit,QVector& _cal_coeffs,QVector& _output) { _output.clear(); if(_cal_coeffs.size()<3||_ROI_limit.size()<0) //刻度系数大小错误 或 限制数据不存在 { return false; } int dataTemp = 0; for(QVector::size_type pos=0;pos<_ROI_limit.size();pos++) { dataTemp = int(_cal_coeffs[0]+_cal_coeffs[1]*_ROI_limit[pos]+_cal_coeffs[2]*_ROI_limit[pos]*_ROI_limit[pos]+0.5); _output.append(dataTemp); } return true; }