Changeset 7024
 Timestamp:
 10/04/10 18:51:55 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/maven/projects/slimplugin/src/main/java/loci/SLIMProcessor.java
r7017 r7024 65 65 import loci.curvefitter.JaolhoCurveFitter; 66 66 import loci.curvefitter.MarkwardtCurveFitter; 67 import loci.curvefitter.SLIMCurveFitter; 67 68 import loci.formats.ChannelSeparator; 68 69 import loci.formats.FormatException; … … 92 93 private static final Character LAMBDA = '\u03bb'; 93 94 private static final Character SIGMA = '\u03c3'; 95 private static final Character SUB_1 = '\u2081'; 96 private static final Character SUB_2 = '\u2082'; 97 private static final Character SUB_3 = '\u2083'; 94 98 95 99 //TODO total kludge; just to get started … … 148 152 private int m_y; 149 153 150 private double m_fitA1; 151 private double m_fitT1; 152 private double m_fitA2; 153 private double m_fitT2; 154 private double m_fitA3; 155 private double m_fitT3; 156 private double m_fitC; 154 private double[] m_param = new double[7]; 155 private boolean[] m_free = { true, true, true, true, true, true, true }; 157 156 158 157 private boolean m_fitA1fixed; … … 163 162 private boolean m_fitT3fixed; 164 163 private boolean m_fitCfixed; 165 private boolean m_free[] = { true, true, true, true, true, true, true };166 164 167 165 private int m_startBin; … … 544 542 } 545 543 switch (m_function) { 544 /* 546 545 case SINGLE_EXPONENTIAL: 547 546 dialog.addNumericField("A", m_fitA1, 5); … … 582 581 case STRETCHED_EXPONENTIAL: 583 582 break; 583 */ 584 case SINGLE_EXPONENTIAL: 585 dialog.addNumericField("A", 586 m_param[0], 5); 587 dialog.addCheckbox("Fix", 588 !m_free[0]); 589 dialog.addNumericField("" + LAMBDA, 590 m_param[1], 5); 591 dialog.addCheckbox("Fix", 592 !m_free[1]); 593 dialog.addNumericField("C", 594 m_param[2], 5); 595 dialog.addCheckbox("Fix", 596 !m_free[2]); 597 break; 598 case DOUBLE_EXPONENTIAL: 599 dialog.addNumericField("A" + SUB_1, 600 m_param[0], 5); 601 dialog.addCheckbox("Fix", 602 !m_free[0]); 603 dialog.addNumericField("" + LAMBDA + SUB_1, 604 m_param[1], 5); 605 dialog.addCheckbox("Fix", 606 !m_free[1]); 607 dialog.addNumericField("A" + SUB_2, 608 m_param[2], 5); 609 dialog.addCheckbox("Fix", 610 !m_free[2]); 611 dialog.addNumericField("" + LAMBDA + SUB_2, 612 m_param[3], 5); 613 dialog.addCheckbox("Fix", 614 !m_free[3]); 615 dialog.addNumericField("C", 616 m_param[4], 5); 617 dialog.addCheckbox("Fix", 618 !m_free[4]); 619 break; 620 case TRIPLE_EXPONENTIAL: 621 dialog.addNumericField("A" + SUB_1, 622 m_param[0], 5); 623 dialog.addCheckbox("Fix", 624 !m_free[0]); 625 dialog.addNumericField("" + LAMBDA + SUB_1, 626 m_param[1], 5); 627 dialog.addCheckbox("Fix", 628 !m_free[1]); 629 dialog.addNumericField("A" + SUB_2, 630 m_param[2], 5); 631 dialog.addCheckbox("Fix", 632 !m_free[2]); 633 dialog.addNumericField("" + LAMBDA + SUB_2, 634 m_param[3], 5); 635 dialog.addCheckbox("Fix", 636 !m_free[3]); 637 dialog.addNumericField("A" + SUB_3, 638 m_param[4], 5); 639 dialog.addCheckbox("Fix", 640 !m_free[4]); 641 dialog.addNumericField("" + LAMBDA + SUB_3, 642 m_param[5], 5); 643 dialog.addCheckbox("Fix", 644 !m_free[5]); 645 dialog.addNumericField("C", 646 m_param[6], 5); 647 dialog.addCheckbox("Fix", 648 !m_free[6]); 649 break; 650 case STRETCHED_EXPONENTIAL: 651 break; 652 584 653 } 585 654 if (0 == m_stopBin) { … … 601 670 switch (m_function) { 602 671 case SINGLE_EXPONENTIAL: 603 m_ fitA1= dialog.getNextNumber();604 m_f itA1fixed =dialog.getNextBoolean();605 m_ fitT1= dialog.getNextNumber();606 m_f itT1fixed =dialog.getNextBoolean();607 m_ fitC= dialog.getNextNumber();608 m_f itCfixed =dialog.getNextBoolean();672 m_param[0] = dialog.getNextNumber(); 673 m_free[0] = !dialog.getNextBoolean(); 674 m_param[1] = dialog.getNextNumber(); 675 m_free[1] = !dialog.getNextBoolean(); 676 m_param[2] = dialog.getNextNumber(); 677 m_free[2] = !dialog.getNextBoolean(); 609 678 break; 610 679 case DOUBLE_EXPONENTIAL: 611 m_ fitA1= dialog.getNextNumber();612 m_f itA1fixed =dialog.getNextBoolean();613 m_ fitT1= dialog.getNextNumber();614 m_f itT1fixed =dialog.getNextBoolean();615 m_ fitA2= dialog.getNextNumber();616 m_f itA2fixed =dialog.getNextBoolean();617 m_ fitT2= dialog.getNextNumber();618 m_f itT2fixed =dialog.getNextBoolean();619 m_ fitC= dialog.getNextNumber();620 m_f itCfixed =dialog.getNextBoolean();680 m_param[0] = dialog.getNextNumber(); 681 m_free[0] = !dialog.getNextBoolean(); 682 m_param[1] = dialog.getNextNumber(); 683 m_free[1] = !dialog.getNextBoolean(); 684 m_param[2] = dialog.getNextNumber(); 685 m_free[2] = !dialog.getNextBoolean(); 686 m_param[3] = dialog.getNextNumber(); 687 m_free[3] = !dialog.getNextBoolean(); 688 m_param[4] = dialog.getNextNumber(); 689 m_free[4] = !dialog.getNextBoolean(); 621 690 break; 622 691 case TRIPLE_EXPONENTIAL: 623 m_ fitA1= dialog.getNextNumber();624 m_f itA1fixed =dialog.getNextBoolean();625 m_ fitT1= dialog.getNextNumber();626 m_f itT1fixed =dialog.getNextBoolean();627 m_ fitA2= dialog.getNextNumber();628 m_f itA2fixed =dialog.getNextBoolean();629 m_ fitT2= dialog.getNextNumber();630 m_f itT2fixed =dialog.getNextBoolean();631 m_ fitA3= dialog.getNextNumber();632 m_f itA3fixed =dialog.getNextBoolean();633 m_ fitT3= dialog.getNextNumber();634 m_f itT3fixed =dialog.getNextBoolean();635 m_ fitC= dialog.getNextNumber();636 m_f itCfixed =dialog.getNextBoolean();692 m_param[0] = dialog.getNextNumber(); 693 m_free[0] = !dialog.getNextBoolean(); 694 m_param[1] = dialog.getNextNumber(); 695 m_free[1] = !dialog.getNextBoolean(); 696 m_param[2] = dialog.getNextNumber(); 697 m_free[2] = !dialog.getNextBoolean(); 698 m_param[3] = dialog.getNextNumber(); 699 m_free[3] = !dialog.getNextBoolean(); 700 m_param[4] = dialog.getNextNumber(); 701 m_free[4] = !dialog.getNextBoolean(); 702 m_param[5] = dialog.getNextNumber(); 703 m_free[5] = !dialog.getNextBoolean(); 704 m_param[6] = dialog.getNextNumber(); 705 m_free[6] = !dialog.getNextBoolean(); 637 706 break; 638 707 case STRETCHED_EXPONENTIAL: … … 668 737 case SINGLE_EXPONENTIAL: 669 738 params = new double[3]; 670 params[0] = m_ fitA1;671 params[1] = m_ fitT1;672 params[2] = m_ fitC;739 params[0] = m_param[0]; 740 params[1] = m_param[1]; 741 params[2] = m_param[2]; 673 742 break; 674 743 case DOUBLE_EXPONENTIAL: 675 744 params = new double[5]; 676 params[0] = m_ fitA1;677 params[1] = m_ fitT1;678 params[2] = m_ fitA2;679 params[3] = m_ fitT2;680 params[4] = m_ fitC;745 params[0] = m_param[0]; 746 params[1] = m_param[1]; 747 params[2] = m_param[2]; 748 params[3] = m_param[3]; 749 params[4] = m_param[4]; 681 750 break; 682 751 case TRIPLE_EXPONENTIAL: 683 752 params = new double[7]; 684 params[0] = m_ fitA1;685 params[1] = m_ fitT1;686 params[2] = m_ fitA2;687 params[3] = m_ fitT2;688 params[4] = m_ fitA3;689 params[5] = m_ fitT3;690 params[6] = m_ fitC;753 params[0] = m_param[0]; 754 params[1] = m_param[1]; 755 params[2] = m_param[2]; 756 params[3] = m_param[3]; 757 params[4] = m_param[4]; 758 params[5] = m_param[5]; 759 params[6] = m_param[6]; 691 760 break; 692 761 case STRETCHED_EXPONENTIAL: 693 762 break; 694 763 } 695 params[0] = m_fitA1;696 params[1] = m_fitT1;697 params[2] = m_fitC;698 764 699 765 // build the data 700 766 ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>(); 701 767 ICurveFitData curveFitData; 702 double y DataArray[];768 double yCount[]; 703 769 double yFitted[]; 704 770 switch (m_region) { … … 707 773 curveFitData = new CurveFitData(); 708 774 curveFitData.setParams(params); 709 y DataArray= new double[m_timeBins];775 yCount = new double[m_timeBins]; 710 776 for (int b = 0; b < m_timeBins; ++b) { 711 y DataArray[b] = 0.0;777 yCount[b] = 0.0; 712 778 } 713 779 int photons = 0; … … 715 781 for (int x = 0; x < m_width; ++x) { 716 782 for (int b = 0; b < m_timeBins; ++b) { 717 y DataArray[b] += m_data[0][y][x][b];783 yCount[b] += m_data[0][y][x][b]; 718 784 photons += m_data[0][y][x][b]; 719 785 } … … 721 787 } 722 788 System.out.println("SUMMED photons " + photons); 723 curveFitData.setY Data(yDataArray);789 curveFitData.setYCount(yCount); 724 790 yFitted = new double[m_timeBins]; 725 791 curveFitData.setYFitted(yFitted); … … 732 798 curveFitData = new CurveFitData(); 733 799 curveFitData.setParams(params.clone()); 734 y DataArray= new double[m_timeBins];800 yCount = new double[m_timeBins]; 735 801 for (int b = 0; b < m_timeBins; ++b) { 736 y DataArray[b] = 0.0;802 yCount[b] = 0.0; 737 803 } 738 804 Rectangle bounds = roi.getBounds(); … … 742 808 System.out.println("roi " + roiNumber + " x " + x + " Y " + y); 743 809 for (int b = 0; b < m_timeBins; ++b) { 744 y DataArray[b] += m_data[0][y][x][b];810 yCount[b] += m_data[0][y][x][b]; 745 811 } 746 812 } 747 813 } 748 814 } 749 curveFitData.setY Data(yDataArray);815 curveFitData.setYCount(yCount); 750 816 yFitted = new double[m_timeBins]; 751 817 curveFitData.setYFitted(yFitted); … … 756 822 curveFitData = new CurveFitData(); 757 823 curveFitData.setParams(params); 758 y DataArray= new double[m_timeBins];824 yCount = new double[m_timeBins]; 759 825 for (int b = 0; b < m_timeBins; ++b) { 760 y DataArray[b] = m_data[0][m_height  m_y  1][m_x][b];761 } 762 curveFitData.setY Data(yDataArray);826 yCount[b] = m_data[0][m_height  m_y  1][m_x][b]; 827 } 828 curveFitData.setYCount(yCount); 763 829 yFitted = new double[m_timeBins]; 764 830 curveFitData.setYFitted(yFitted); … … 775 841 curveFitData = new CurveFitData(); 776 842 curveFitData.setParams(params.clone()); //TODO if you don't clone here each pixel fit uses results of previous fit to start 777 y DataArray= new double[m_timeBins];843 yCount = new double[m_timeBins]; 778 844 for (int b = 0; b < m_timeBins; ++b) { 779 y DataArray[b] = m_data[0][y][x][b];845 yCount[b] = m_data[0][y][x][b]; 780 846 } 781 curveFitData.setY Data(yDataArray);847 curveFitData.setYCount(yCount); 782 848 yFitted = new double[m_timeBins]; 783 849 curveFitData.setYFitted(yFitted); … … 793 859 curveFitData = new CurveFitData(); 794 860 curveFitData.setParams(params.clone()); //TODO if you don't clone here each pixel fit uses results of previous fit to start 795 y DataArray= new double[m_timeBins];861 yCount = new double[m_timeBins]; 796 862 for (int b = 0; b < m_timeBins; ++b) { 797 y DataArray[b] = m_data[0][y][x][b];863 yCount[b] = m_data[0][y][x][b]; 798 864 } 799 curveFitData.setY Data(yDataArray);865 curveFitData.setYCount(yCount); 800 866 yFitted = new double[m_timeBins]; 801 867 curveFitData.setYFitted(yFitted); … … 832 898 curveFitter = new GrayNRCurveFitter(1); 833 899 break; 834 //case SLIMCURVE_RLD:835 //curveFitter = new SLIMCurveFitter(0);836 //break;837 //case SLIMCURVE_LMA:838 //curveFitter = new SLIMCurveFitter(1);839 //break;900 case SLIMCURVE_RLD: 901 curveFitter = new SLIMCurveFitter(0); 902 break; 903 case SLIMCURVE_LMA: 904 curveFitter = new SLIMCurveFitter(1); 905 break; 840 906 } 841 907 curveFitter.setXInc(m_timeRange); … … 927 993 switch (m_function) { 928 994 case SINGLE_EXPONENTIAL: 929 m_ fitA1= params[0];930 m_ fitT1= params[1];931 m_ fitC= params[2];995 m_param[0] = params[0]; 996 m_param[1] = params[1]; 997 m_param[2] = params[2]; 932 998 break; 933 999 case DOUBLE_EXPONENTIAL: 934 m_ fitA1= params[0];935 m_ fitT1= params[1];936 m_ fitA2= params[2];937 m_ fitT2= params[3];938 m_ fitC= params[4];1000 m_param[0] = params[0]; 1001 m_param[1] = params[1]; 1002 m_param[2] = params[2]; 1003 m_param[3] = params[3]; 1004 m_param[4] = params[4]; 939 1005 break; 940 1006 case TRIPLE_EXPONENTIAL: 941 m_ fitA1= params[0];942 m_ fitT1= params[1];943 m_ fitA2= params[2];944 m_ fitT2= params[3];945 m_ fitA3= params[4];946 m_ fitT3= params[5];947 m_ fitC= params[6];1007 m_param[0] = params[0]; 1008 m_param[1] = params[1]; 1009 m_param[2] = params[2]; 1010 m_param[3] = params[3]; 1011 m_param[4] = params[4]; 1012 m_param[5] = params[5]; 1013 m_param[6] = params[6]; 948 1014 break; 949 1015 case STRETCHED_EXPONENTIAL: … … 976 1042 case SINGLE_EXPONENTIAL: 977 1043 params = new double[3]; 978 params[0] = m_ fitA1;979 params[1] = m_ fitT1;980 params[2] = m_ fitC;1044 params[0] = m_param[0]; 1045 params[1] = m_param[1]; 1046 params[2] = m_param[2]; 981 1047 break; 982 1048 case DOUBLE_EXPONENTIAL: 983 1049 params = new double[5]; 984 params[0] = m_ fitA1;985 params[1] = m_ fitT1;986 params[2] = m_ fitA2;987 params[3] = m_ fitT2;988 params[4] = m_ fitC;1050 params[0] = m_param[0]; 1051 params[1] = m_param[1]; 1052 params[2] = m_param[2]; 1053 params[3] = m_param[3]; 1054 params[4] = m_param[4]; 989 1055 break; 990 1056 case TRIPLE_EXPONENTIAL: 991 1057 params = new double[7]; 992 params[0] = m_ fitA1;993 params[1] = m_ fitT1;994 params[2] = m_ fitA2;995 params[3] = m_ fitT2;996 params[4] = m_ fitA3;997 params[5] = m_ fitT3;998 params[6] = m_ fitC;1058 params[0] = m_param[0]; 1059 params[1] = m_param[1]; 1060 params[2] = m_param[2]; 1061 params[3] = m_param[3]; 1062 params[4] = m_param[4]; 1063 params[5] = m_param[5]; 1064 params[6] = m_param[6]; 999 1065 break; 1000 1066 case STRETCHED_EXPONENTIAL: 1001 1067 break; 1002 1068 } 1003 //TODO problem: only use predetermined params for a fixed fit?1004 for (int i = 0; i < params.length; ++i) {1005 params[i] = 1.0;1006 }1007 params[0] = m_fitA1;1008 params[1] = m_fitT1;1009 params[2] = m_fitC;1010 1069 1011 1070 // show colorized lifetimes … … 1019 1078 ArrayList<ChunkyPixel> pixelList = new ArrayList<ChunkyPixel>(); 1020 1079 ICurveFitData curveFitData; 1021 double y DataArray[];1080 double yCount[]; 1022 1081 double yFitted[]; 1023 1082 … … 1034 1093 curveFitData = new CurveFitData(); 1035 1094 curveFitData.setParams(params.clone()); 1036 y DataArray= new double[m_timeBins];1095 yCount = new double[m_timeBins]; 1037 1096 for (int b = 0; b < m_timeBins; ++b) { 1038 y DataArray[b] = m_data[0][pixel.getY()][pixel.getX()][b];1039 } 1040 curveFitData.setY Data(yDataArray);1097 yCount[b] = m_data[0][pixel.getY()][pixel.getX()][b]; 1098 } 1099 curveFitData.setYCount(yCount); 1041 1100 yFitted = new double[m_timeBins]; 1042 1101 curveFitData.setYFitted(yFitted); … … 1096 1155 curveFitter = new GrayNRCurveFitter(1); 1097 1156 break; 1098 //case SLIMCURVE_RLD:1099 //curveFitter = new SLIMCurveFitter(0);1100 //break;1101 //case SLIMCURVE_LMA:1102 //curveFitter = new SLIMCurveFitter(1);1103 //break;1157 case SLIMCURVE_RLD: 1158 curveFitter = new SLIMCurveFitter(0); 1159 break; 1160 case SLIMCURVE_LMA: 1161 curveFitter = new SLIMCurveFitter(1); 1162 break; 1104 1163 } 1105 1164 curveFitter.setXInc(m_timeRange); … … 1114 1173 1115 1174 //TODO debugging: 1116 if (lifetime > 2 * m_ fitT1) {1175 if (lifetime > 2 * m_param[1]) { 1117 1176 System.out.println("BAD FIT??? x " + pixel.getX() + " y " + pixel.getY() + " fitted lifetime " + lifetime); 1118 1177 }
Note: See TracChangeset
for help on using the changeset viewer.