Stimfit
0.13.15
|
00001 // This program is free software; you can redistribute it and/or 00002 // modify it under the terms of the GNU General Public License 00003 // as published by the Free Software Foundation; either version 2 00004 // of the License, or (at your option) any later version. 00005 00006 // This program is distributed in the hope that it will be useful, 00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00009 // GNU General Public License for more details. 00010 00011 // You should have received a copy of the GNU General Public License 00012 // along with this program; if not, write to the Free Software 00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00014 00021 #ifndef _DOC_H 00022 #define _DOC_H 00023 00028 #include "./../stf.h" 00029 00031 00034 class StfDll wxStfDoc: public wxDocument, public Recording 00035 { 00036 #ifndef FROM_PYTHON 00037 DECLARE_DYNAMIC_CLASS(wxStfDoc) 00038 #endif 00039 private: 00040 bool peakAtEnd, initialized, progress; 00041 Recording Average; 00042 int InitCursors(); 00043 void PostInit(); 00044 bool ChannelSelDlg(); 00045 void WriteToReg(); 00046 bool outOfRange(std::size_t check) { 00047 return (check >= cursec().size()); 00048 } 00049 void Focus(); 00050 void OnNewfromselectedThisMenu( wxCommandEvent& event ) { OnNewfromselectedThis( ); } 00051 void Selectsome(wxCommandEvent& event); 00052 void Unselectsome(wxCommandEvent& event); 00053 void ConcatenateMultiChannel(wxCommandEvent& event); 00054 void OnAnalysisBatch( wxCommandEvent& event ); 00055 void OnAnalysisIntegrate( wxCommandEvent& event ); 00056 void OnAnalysisDifferentiate( wxCommandEvent& event ); 00057 //void OnSwapChannels( wxCommandEvent& event ); 00058 void Multiply(wxCommandEvent& event); 00059 void SubtractBaseMenu( wxCommandEvent& event ) { SubtractBase( ); } 00060 void LFit(wxCommandEvent& event); 00061 void LnTransform(wxCommandEvent& event); 00062 void Filter(wxCommandEvent& event); 00063 void P_over_N(wxCommandEvent& event); 00064 void Plotextraction(stf::extraction_mode mode); 00065 void Plotcriterion(wxCommandEvent& event); 00066 void Plotcorrelation(wxCommandEvent& event); 00067 void Plotdeconvolution(wxCommandEvent& event); 00068 void MarkEvents(wxCommandEvent& event); 00069 void Threshold(wxCommandEvent& event); 00070 void Viewtable(wxCommandEvent& event); 00071 void Fileinfo(wxCommandEvent& event); 00072 Recording ReorderChannels(); 00073 00074 wxMenu* doc_file_menu; 00075 00076 00077 stf::latency_mode latencyStartMode, latencyEndMode; 00078 stf::latency_window_mode latencyWindowMode; 00079 stf::direction direction; //of peak detection: UP, DOWN or BOTH 00080 #ifdef WITH_PSLOPE 00081 stf::pslope_mode_beg pslopeBegMode; // for left mode PSlope cursor 00082 stf::pslope_mode_end pslopeEndMode; // for right mode PSlope cursor 00083 #endif 00084 std::size_t baseBeg, baseEnd, peakBeg, peakEnd, fitBeg, fitEnd; 00085 #ifdef WITH_PSLOPE 00086 std::size_t PSlopeBeg, PSlopeEnd; 00087 int DeltaT; // distance (number of points) from the first cursor 00088 bool viewPSlope; 00089 #endif 00090 std::size_t measCursor; 00091 double latencyStartCursor, 00092 latencyEndCursor, 00093 latency, //time from latency cursor to beginning of event 00094 base, APBase, baseSD, threshold, slopeForThreshold, peak, APPeak, tLoReal, tHiReal, t50LeftReal, t50RightReal, 00095 maxT, thrT, maxRiseY, maxRiseT, maxDecayY, maxDecayT, maxRise, maxDecay, 00096 t50Y, APMaxT, APMaxRiseY, APMaxRiseT, APt50LeftReal, 00097 #ifdef WITH_PSLOPE 00098 PSlope, 00099 #endif 00100 rtLoHi, InnerLoRT, InnerHiRT, OuterLoRT, OuterHiRT, halfDuration, slopeRatio, t0Real; 00101 // cursor windows: 00102 int pM; //peakMean, number of points used for averaging 00103 int RTFactor; // Lower point for the rise-time calculation 00104 00105 std::size_t tLoIndex, tHiIndex, t50LeftIndex, t50RightIndex, APt50LeftIndex, APt50RightIndex; 00106 00107 bool fromBase, viewCrosshair,viewBaseline,viewBaseSD,viewThreshold, viewPeakzero,viewPeakbase,viewPeakthreshold, 00108 viewRTLoHi, viewInnerRiseTime, viewOuterRiseTime, 00109 viewT50,viewRD,viewSloperise,viewSlopedecay,viewLatency, 00110 viewCursors; 00111 00112 XZoom xzoom; 00113 std::vector<YZoom> yzoom; 00114 00115 std::vector< std::vector<stf::SectionAttributes> > sec_attr; 00116 00117 public: 00118 00120 00122 wxStfDoc(); 00124 ~wxStfDoc(); 00125 00127 00129 void OnSwapChannels( wxCommandEvent& event ); 00130 00132 00136 virtual bool OnOpenDocument(const wxString& filename); 00137 00139 00143 virtual bool OnOpenPyDocument(const wxString& filename); 00144 00146 00148 virtual bool SaveAs(); 00149 00150 #ifndef TEST_MINIMAL 00151 00152 00155 virtual bool DoSaveDocument(const wxString& filename); 00156 #endif 00157 00158 00161 virtual bool OnCloseDocument(); 00162 00164 00166 virtual bool OnNewDocument(); 00167 00169 00173 void SetData( const Recording& c_Data, const wxStfDoc* Sender, const wxString& title ); 00174 00176 00178 bool GetIsAverage() const { return !Average.get().empty(); } 00179 00181 00183 bool GetPeakAtEnd() const { return peakAtEnd; } 00184 00186 00191 bool IsInitialized() const { return initialized; } 00192 00194 00196 void SetPeakAtEnd(bool value) { peakAtEnd=value; } 00197 00199 00201 const Recording& GetAverage() const { return Average; } 00202 00204 void CheckBoundaries(); 00205 00207 00210 bool SetSection(std::size_t section); 00211 00213 00215 bool OnNewfromselectedThis( ); 00216 00218 00220 void Selectall(wxCommandEvent& event); 00221 00223 00225 void Deleteselected(wxCommandEvent& event); 00226 00228 void UpdateSelectedButton(); 00229 00231 00235 void CreateAverage( bool calcSD, bool align ); 00236 00237 #if 0 00238 00239 00241 void Userdef(std::size_t id); 00242 #endif 00243 00245 void ToggleSelect( ); 00246 00248 void Select(); 00249 00251 void Remove(); 00252 00254 00256 void Extract(wxCommandEvent& event); 00257 00259 00261 void InteractiveEraseEvents(wxCommandEvent& event); 00262 00264 00266 void AddEvent( wxCommandEvent& event ); 00267 00269 00271 bool SubtractBase( ); 00272 00274 00276 void FitDecay(wxCommandEvent& event); 00277 00279 00281 void SetFileMenu( wxMenu* menu ) { doc_file_menu = menu; } 00282 00284 00288 void Measure(); 00289 00291 stf::Table CurResultsTable(); 00292 00294 00296 std::size_t GetMeasCursor() const { return measCursor; } 00297 00299 00301 std::size_t GetBaseBeg() const { return baseBeg; } 00302 00304 00306 std::size_t GetBaseEnd() const { return baseEnd; } 00307 00309 00311 std::size_t GetPeakBeg() const { return peakBeg; } 00312 00314 00316 std::size_t GetPeakEnd() const { return peakEnd; } 00317 00319 00321 std::size_t GetFitBeg() const { return fitBeg; } 00322 00324 00326 std::size_t GetFitEnd() const { return fitEnd; } 00327 00328 #ifdef WITH_PSLOPE 00329 00330 00332 std::size_t GetPSlopeBeg() const { return PSlopeBeg; } 00333 00335 00337 std::size_t GetPSlopeEnd() const { return PSlopeEnd; } 00338 #endif // WITH_PSLOPE 00339 00341 00343 int GetPM() const { return pM; } 00344 00345 #ifdef WITH_PSLOPE 00346 00347 00349 int GetDeltaT() const { return DeltaT; } 00350 #endif 00351 00353 00357 double GetLatencyBeg() const { return latencyStartCursor; } 00358 00360 00364 double GetLatencyEnd() const { return latencyEndCursor; } 00365 00367 00369 double GetLatency() const { return latency; } 00370 00372 00375 double GetTLoReal() const { return tLoReal; } 00376 00378 00381 double GetTHiReal() const { return tHiReal; } 00382 00384 00387 double GetInnerLoRT() const { return InnerLoRT; } 00388 00390 00393 double GetInnerHiRT() const { return InnerHiRT; } 00394 00396 00399 double GetOuterLoRT() const { return OuterLoRT; } 00400 00402 00405 double GetOuterHiRT() const { return OuterHiRT; } 00406 00408 00411 double GetT50LeftReal() const { return t50LeftReal; } 00412 00414 00417 double GetT50RightReal() const { return t50RightReal; } 00418 00420 00422 double GetT50Y() const { return t50Y; } 00423 00425 00427 double GetMaxRise() const { return maxRise; } 00428 00430 00432 double GetMaxDecay() const { return maxDecay; } 00433 00435 00439 double GetAPMaxRiseT() const { return APMaxRiseT; } 00440 00442 00445 double GetAPMaxT() const { return APMaxT; } 00446 00448 00451 double GetAPT50LeftReal() const { return APt50LeftReal; } 00452 00454 00456 double GetMaxRiseT() const { return maxRiseT; } 00457 00459 00461 double GetMaxRiseY() const { return maxRiseY; } 00462 00464 00466 double GetMaxDecayT() const { return maxDecayT; } 00467 00469 00471 double GetMaxDecayY() const { return maxDecayY; } 00472 00474 00476 double GetMeasValue(); 00477 00479 00481 double GetPeak() const { return peak; } 00482 00484 00486 double GetPeakTime() const { return maxT; } 00487 00489 00491 double GetBase() const { return base; } 00492 00494 00496 double GetAPBase() const { return APBase; } 00497 00499 00501 double GetBaseSD() const { return baseSD; } 00502 00504 00506 double GetThreshold() const { return threshold; } 00507 00509 00511 double GetMaxT() const { return maxT; } 00512 00514 00517 double GetThrT() const { return thrT; } 00518 00520 00522 double GetRTLoHi() const { return rtLoHi; } 00523 00525 00527 double GetInnerRiseTime() const { return (InnerHiRT-InnerLoRT); } 00528 00530 00532 double GetOuterRiseTime() const { return (OuterHiRT-OuterLoRT); } 00533 00535 00537 double GetHalfDuration() const { return halfDuration; } 00538 00539 00541 00543 double GetSlopeRatio() const { return slopeRatio; } 00544 00546 00548 int GetRTFactor() const { return RTFactor; } 00549 00550 #ifdef WITH_PSLOPE 00551 00552 00554 double GetPSlope() const { return PSlope; } 00555 #endif 00556 00558 00560 stf::latency_mode GetLatencyStartMode() const { return latencyStartMode; } 00561 00563 00565 stf::latency_mode GetLatencyEndMode() const { return latencyEndMode; } 00566 00568 00570 stf::latency_window_mode GetLatencyWindowMode() const { return latencyWindowMode; } 00571 00573 00575 stf::direction GetDirection() const { return direction; } 00576 00577 00578 #ifdef WITH_PSLOPE 00579 00580 00582 stf::pslope_mode_beg GetPSlopeBegMode() const { return pslopeBegMode; } 00583 00585 00587 stf::pslope_mode_end GetPSlopeEndMode() const { return pslopeEndMode; } 00588 #endif // WITH_PSLOPE 00589 00591 00593 bool GetFromBase() const { return fromBase; } 00594 00596 00598 bool GetViewCrosshair() const { return viewCrosshair; } 00599 00601 00603 bool GetViewBaseline() const { return viewBaseline; } 00604 00606 00608 bool GetViewBaseSD() const { return viewBaseSD; } 00609 00611 00613 bool GetViewThreshold() const { return viewThreshold; } 00614 00616 00618 bool GetViewPeakZero() const { return viewPeakzero; } 00619 00621 00623 bool GetViewPeakBase() const { return viewPeakbase; } 00624 00626 00628 bool GetViewPeakThreshold() const { return viewPeakthreshold; } 00629 00631 00633 bool GetViewRTLoHi() const { return viewRTLoHi; } 00634 00636 00638 bool GetViewInnerRiseTime() const { return viewInnerRiseTime; } 00639 00641 00643 bool GetViewOuterRiseTime() const { return viewOuterRiseTime; } 00644 00646 00648 bool GetViewT50() const { return viewT50; } 00649 00651 00653 bool GetViewRD() const { return viewRD; } 00654 00656 00658 bool GetViewSlopeRise() const { return viewSloperise; } 00659 00661 00663 bool GetViewSlopeDecay() const { return viewSlopedecay; } 00664 00666 00668 bool GetViewLatency() const { return viewLatency; } 00669 00670 #ifdef WITH_PSLOPE 00671 00672 00674 bool GetViewPSlope() const { return viewPSlope; } 00675 00676 #endif 00677 00678 00680 bool GetViewCursors() const { return viewCursors; } 00681 00683 00685 double GetSlopeForThreshold() const { return slopeForThreshold; } 00686 00688 00690 const XZoom& GetXZoom() { return xzoom; } 00691 00693 00695 XZoom& GetXZoomW() { return xzoom; } 00696 00698 00700 const YZoom& GetYZoom(int ch) { return yzoom.at(ch); } 00701 00703 00705 YZoom& GetYZoomW(int ch) { return yzoom.at(ch); } 00706 00708 00710 void SetMeasCursor(int value); 00711 00713 00715 void SetBaseBeg(int value); 00716 00718 00720 void SetBaseEnd(int value); 00721 00723 00725 void SetPeakBeg(int value); 00726 00728 00730 void SetPeakEnd(int value); 00731 00733 00735 void SetFitBeg(int value); 00736 00738 00740 void SetFitEnd(int value); 00741 00743 00747 void SetLatencyBeg(double value); 00748 00750 00754 void SetLatencyEnd(double value); 00755 00757 00759 void SetLatency(double value) { latency=value; } 00760 00761 #ifdef WITH_PSLOPE 00762 00763 00765 void SetPSlopeBeg(int value); 00766 00768 00770 void SetPSlopeEnd(int value); 00771 00773 00775 void SetPSlope(double value) { PSlope=value; } 00776 00778 00780 void SetPSlopeBegMode(stf::pslope_mode_beg value) { pslopeBegMode=value; } 00781 00783 00785 void SetPSlopeEndMode(stf::pslope_mode_end value) { pslopeEndMode=value; } 00786 00788 00790 void SetDeltaT(int value) { DeltaT=value; } 00791 00792 #endif // WITH_PSLOPE 00793 00795 00797 void SetPM(int value) { pM=value; } 00798 00800 00803 void SetRTFactor(int value); 00804 00806 00808 void SetLatencyStartMode(stf::latency_mode value) { latencyStartMode=value; } 00809 00811 00813 void SetLatencyEndMode(stf::latency_mode value) { 00814 latencyEndMode=value; 00815 } 00816 00818 00820 void SetLatencyWindowMode(stf::latency_window_mode value) { 00821 latencyWindowMode=value; 00822 } 00823 00825 00827 void SetLatencyStartMode(int value); 00828 00830 00832 void SetLatencyEndMode(int value); 00833 00835 00837 void SetLatencyWindowMode(int value); 00838 00840 00842 void SetDirection(stf::direction value) { direction=value; } 00843 00845 00847 void SetFromBase(bool frombase) { fromBase = frombase; } 00848 00850 00852 void SetViewCrosshair(bool value) { viewCrosshair=value; } 00853 00855 00857 void SetViewBaseline(bool value) { viewBaseline=value; } 00858 00860 00862 void SetViewBaseSD(bool value) { viewBaseSD=value; } 00863 00865 00867 void SetViewThreshold(bool value) { viewThreshold=value; } 00868 00870 00872 void SetViewPeakZero(bool value) { viewPeakzero=value; } 00873 00875 00877 void SetViewPeakBase(bool value) { viewPeakbase=value; } 00878 00880 00882 void SetViewPeakThreshold(bool value) { viewPeakthreshold=value; } 00883 00885 00887 void SetViewRTLoHi(bool value) { viewRTLoHi=value; } 00888 00890 00892 void SetViewInnerRiseTime(bool value) { viewInnerRiseTime=value; } 00893 00895 00897 void SetViewOuterRiseTime(bool value) { viewOuterRiseTime=value; } 00898 00900 00902 void SetViewT50(bool value) { viewT50=value; } 00903 00905 00907 void SetViewRD(bool value) { viewRD=value; } 00908 00910 00912 void SetViewSlopeRise(bool value) { viewSloperise=value; } 00913 00915 00917 void SetViewSlopeDecay(bool value) { viewSlopedecay=value; } 00918 00920 00922 void SetViewLatency(bool value) { viewLatency=value; } 00923 00924 #ifdef WITH_PSLOPE 00925 00926 00928 void SetViewPSlope(bool value) { viewPSlope=value; } 00929 #endif 00930 00932 00934 void SetViewCursors(bool value) { viewCursors=value; } 00935 00937 00939 void SetSlopeForThreshold(double value) { slopeForThreshold=value; } 00940 00942 stf::Table CurAsTable() const; 00943 00945 00951 void CopyCursors(const wxStfDoc& c_Recording); 00952 00954 00957 virtual void resize(std::size_t c_n_channels); 00958 00960 00964 virtual void InsertChannel(Channel& c_Channel, std::size_t pos); 00965 00966 const stf::SectionAttributes& GetSectionAttributes(std::size_t nchannel, std::size_t nsection) const; 00967 const stf::SectionAttributes& GetCurrentSectionAttributes() const; 00968 stf::SectionAttributes& GetCurrentSectionAttributesW(); 00969 00971 void DeleteFit(std::size_t nchannel, std::size_t nsection); 00972 00974 00980 void SetIsFitted( std::size_t nchannel, std::size_t nsection, 00981 const Vector_double& bestFitP_, stf::storedFunc* fitFunc_, 00982 double chisqr, std::size_t fitBeg, std::size_t fitEnd ); 00983 00984 00986 00988 void SetIsIntegrated(std::size_t nchannel, std::size_t nsection, bool value, 00989 std::size_t begin, std::size_t end, const Vector_double& quad_p_); 00990 00992 void ClearEvents(std::size_t nchannel, std::size_t nsection); 00993 00994 void correctRangeR(int& value); 00995 void correctRangeR(std::size_t& value); 00996 00997 DECLARE_EVENT_TABLE() 00998 }; 00999 01002 #endif 01003