Stimfit 0.12.7
src/stimfit/gui/doc.h
Go to the documentation of this file.
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>=cur().size());
00048     }
00049     void Focus();
00050     void OnNewfromselectedThisMenu( wxCommandEvent& event ) { OnNewfromselectedThis( ); }
00051     void Selectsome(wxCommandEvent& event);
00052     void Unselectsome(wxCommandEvent& event);
00053     void Concatenate(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, APMaxRise, APMaxRiseT, APt50LeftReal, 
00097 //#ifdef WITH_PSLOPE
00098         PSlope,
00099 //#endif
00100         rtLoHi, 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 #ifdef WITH_PSLOPE
00105 #endif
00106 
00107     // currently accessed channel:
00108     std::size_t cc;
00109     // second channel:
00110     std::size_t sc;
00111     // currently accessed section:
00112     std::size_t cs;
00113 
00114     // Indices of the selected sections
00115     std::vector<std::size_t> selectedSections;
00116     // Base line value for each selected trace
00117     Vector_double selectBase;
00118     
00119     std::size_t tLoIndex, tHiIndex, t50LeftIndex, t50RightIndex, APt50LeftIndex, APt50RightIndex;
00120 
00121     bool fromBase, viewCrosshair,viewBaseline,viewBaseSD,viewThreshold, viewPeakzero,viewPeakbase,viewPeakthreshold, viewRTLoHi,
00122         viewT50,viewRD,viewSloperise,viewSlopedecay,viewLatency,
00123 #ifdef WITH_PSLOPE
00124         //viewPSlope,
00125 #endif
00126         viewCursors;
00127 
00128     XZoom xzoom;
00129     std::vector<YZoom> yzoom;
00130 
00131     std::vector< std::vector<stf::SectionAttributes> > sec_attr;
00132     
00133 public:
00134 
00136 
00138     wxStfDoc();
00140     ~wxStfDoc();
00141 
00143 
00145     void OnSwapChannels( wxCommandEvent& event );
00146 
00148 
00152     virtual bool OnOpenDocument(const wxString& filename);
00153 
00155 
00159     virtual bool OnOpenPyDocument(const wxString& filename);
00160 
00162 
00164     virtual bool SaveAs();
00165 
00167 
00170     virtual bool DoSaveDocument(const wxString& filename);
00171 
00173 
00176     virtual bool OnCloseDocument();
00177 
00179 
00181     virtual bool OnNewDocument();
00182 
00184 
00188     void SetData( const Recording& c_Data, const wxStfDoc* Sender, const wxString& title );
00189 
00191 
00193     bool GetIsAverage() const { return !Average.get().empty(); }
00194 
00196 
00198     bool GetPeakAtEnd() const { return peakAtEnd; }
00199 
00201 
00206     bool IsInitialized() const { return initialized; }
00207 
00209 
00211     void SetPeakAtEnd(bool value) { peakAtEnd=value; }
00212 
00214 
00216     const Recording& GetAverage() const { return Average; }
00217 
00219     void CheckBoundaries();
00220 
00222 
00225     bool SetSection(std::size_t section);
00226 
00228 
00230     bool OnNewfromselectedThis( );
00231 
00233 
00235     void Selectall(wxCommandEvent& event);
00236 
00238 
00240     void Deleteselected(wxCommandEvent& event);
00241 
00243     void UpdateSelectedButton();
00244 
00246 
00250     void CreateAverage( bool calcSD, bool align );
00251 
00252 #if 0
00253 
00254 
00256     void Userdef(std::size_t id);
00257 #endif
00258 
00260     void ToggleSelect( );
00261 
00263     void Select();
00264 
00266     void Remove();
00267 
00269 
00271     void Extract(wxCommandEvent& event);
00272 
00274 
00276     void InteractiveEraseEvents(wxCommandEvent& event);
00277     
00279 
00281     void AddEvent( wxCommandEvent& event );
00282 
00284 
00286     bool SubtractBase( );
00287 
00289 
00291     void FitDecay(wxCommandEvent& event);
00292 
00294 
00296     void SetFileMenu( wxMenu* menu ) { doc_file_menu = menu; }
00297     
00299 
00303     void Measure();
00304     
00306     stf::Table CurResultsTable();
00307 
00309 
00311     std::size_t GetCurCh() const { return cc; }
00312 
00314 
00316     std::size_t GetSecCh() const { return sc; }
00317 
00319 
00321     std::size_t GetCurSec() const { return cs; }
00322 
00324 
00326     std::size_t GetMeasCursor() const { return measCursor; }
00327 
00329 
00331     std::size_t GetBaseBeg() const { return baseBeg; }
00332 
00334 
00336     std::size_t GetBaseEnd() const { return baseEnd; }
00337 
00339 
00341     std::size_t GetPeakBeg() const { return peakBeg; }
00342 
00344 
00346     std::size_t GetPeakEnd() const { return peakEnd; }
00347 
00349 
00351     std::size_t GetFitBeg() const { return fitBeg; }
00352 
00354 
00356     std::size_t GetFitEnd() const { return fitEnd; }
00357 
00358 #ifdef WITH_PSLOPE
00359 
00360 
00362     std::size_t GetPSlopeBeg() const { return PSlopeBeg; }
00363 
00365 
00367     std::size_t GetPSlopeEnd() const { return PSlopeEnd; }
00368 #endif // WITH_PSLOPE
00369 
00371 
00373     int GetPM() const { return pM; }
00374 
00375 #ifdef WITH_PSLOPE
00376 
00377 
00379     int GetDeltaT() const { return DeltaT; }
00380 #endif
00381 
00383 
00387     double GetLatencyBeg() const { return latencyStartCursor; }
00388 
00390 
00394     double GetLatencyEnd() const { return latencyEndCursor; }
00395     
00397 
00399     double GetLatency() const { return latency; }
00400 
00402 
00405     double GetTLoReal() const { return tLoReal; }
00406 
00408 
00411     double GetTHiReal() const { return tHiReal; }
00412 
00414 
00417     double GetT50LeftReal() const { return t50LeftReal; }
00418 
00420 
00423     double GetT50RightReal() const { return t50RightReal; }
00424 
00426 
00428     double GetT50Y() const { return t50Y; }
00429 
00431 
00433     double GetMaxRise() const { return maxRise; }
00434 
00436 
00438     double GetMaxDecay() const { return maxDecay; }
00439 
00441 
00445     double GetAPMaxRiseT() const { return APMaxRiseT; }
00446 
00448 
00451     double GetAPMaxT() const { return APMaxT; }
00452 
00454 
00457     double GetAPT50LeftReal() const { return APt50LeftReal; }
00458 
00460 
00462     double GetMaxRiseT() const { return maxRiseT; }
00463 
00465 
00467     double GetMaxRiseY() const { return maxRiseY; }
00468 
00470 
00472     double GetMaxDecayT() const { return maxDecayT; }
00473 
00475 
00477     double GetMaxDecayY() const { return maxDecayY; }
00478     
00480 
00482     double GetMeasValue();
00483     
00485 
00487     double GetPeak() const { return peak; }
00488     
00490 
00492     double GetBase() const { return base; }
00493 
00495 
00497     double GetAPBase() const { return APBase; }
00498     
00500 
00502     double GetBaseSD() const { return baseSD; }
00503     
00505 
00507     double GetThreshold() const { return threshold; }
00508     
00510 
00512     double GetMaxT() const { return maxT; }
00513     
00515 
00518     double GetThrT() const { return thrT; }
00519     
00521 
00523     double GetRTLoHi() const { return rtLoHi; }
00524 
00526 
00528     double GetHalfDuration() const { return halfDuration; }
00529 
00530     
00532 
00534     double GetSlopeRatio() const { return slopeRatio; }
00535 
00537 
00539     int GetRTFactor() const { return RTFactor; }
00540 
00541 //#ifdef WITH_PSLOPE
00543 
00545     double GetPSlope() const { return PSlope; }
00546 //#endif
00547 
00549 
00551     stf::latency_mode GetLatencyStartMode() const { return latencyStartMode; }
00552 
00554 
00556     stf::latency_mode GetLatencyEndMode() const { return latencyEndMode; }
00557     
00559 
00561     stf::latency_window_mode GetLatencyWindowMode() const { return latencyWindowMode; }
00562 
00564 
00566     stf::direction GetDirection() const { return direction; }
00567     
00568 
00569 #ifdef WITH_PSLOPE
00570 
00571 
00573     stf::pslope_mode_beg GetPSlopeBegMode() const { return pslopeBegMode; }
00574 
00576 
00578     stf::pslope_mode_end GetPSlopeEndMode() const { return pslopeEndMode; }
00579 #endif // WITH_PSLOPE
00580 
00582 
00584     bool GetFromBase() const { return fromBase; }
00585 
00587 
00589     bool GetViewCrosshair() const { return viewCrosshair; }
00590 
00592 
00594     bool GetViewBaseline() const { return viewBaseline; }
00595 
00597 
00599     bool GetViewBaseSD() const { return viewBaseSD; }
00600 
00602 
00604     bool GetViewThreshold() const { return viewThreshold; }
00605 
00607 
00609     bool GetViewPeakZero() const { return viewPeakzero; }
00610 
00612 
00614     bool GetViewPeakBase() const { return viewPeakbase; }
00615 
00617 
00619     bool GetViewPeakThreshold() const { return viewPeakthreshold; }
00620 
00622 
00624     bool GetViewRTLoHi() const { return viewRTLoHi; }
00625 
00627 
00629     bool GetViewT50() const { return viewT50; }
00630 
00632 
00634     bool GetViewRD() const { return viewRD; }
00635 
00637 
00639     bool GetViewSlopeRise() const { return viewSloperise; }
00640 
00642 
00644     bool GetViewSlopeDecay() const { return viewSlopedecay; }
00645 
00647 
00649     bool GetViewLatency() const { return viewLatency; }
00650 
00651 #ifdef WITH_PSLOPE
00652 
00653 
00655     bool GetViewPSlope() const { return viewPSlope; }
00656 
00657 #endif
00658 
00659 
00661     bool GetViewCursors() const { return viewCursors; }
00662     
00664 
00666     double GetSlopeForThreshold() const { return slopeForThreshold; }
00667     
00669 
00671     const std::vector<std::size_t>& GetSelectedSections() const { return selectedSections; } 
00672 
00674 
00676     std::vector<std::size_t>& GetSelectedSectionsW() { return selectedSections; } 
00677 
00679 
00681     const Vector_double& GetSelectBase() const { return selectBase; } 
00682 
00684 
00686     Vector_double& GetSelectBaseW() { return selectBase; }
00687 
00689 
00691     const Section& cur() const { return get()[cc][cs]; }
00692 
00694 
00696     Section& cur() { return get()[cc][cs]; }
00697 
00699 
00701     const Section& sec() const { return get()[sc][cs]; }
00702     
00704 
00706     const XZoom& GetXZoom() { return xzoom; }
00707 
00709 
00711     XZoom& GetXZoomW() { return xzoom; }
00712         
00714 
00716     const YZoom& GetYZoom(int ch) { return yzoom.at(ch); }
00717 
00719 
00721     YZoom& GetYZoomW(int ch) { return yzoom.at(ch); }
00722 
00724 
00726     void SetCurCh(std::size_t value);
00727 
00729 
00731     void SetSecCh(std::size_t value);
00732 
00734 
00736     void SetCurSec(std::size_t value);
00737 
00739 
00741     void SelectTrace(std::size_t sectionToSelect);
00742 
00744 
00747     bool UnselectTrace(std::size_t sectionToUnselect);
00748 
00750 
00752     void SetMeasCursor(int value);
00753 
00755 
00757     void SetBaseBeg(int value);
00758 
00760 
00762     void SetBaseEnd(int value);
00763 
00765 
00767     void SetPeakBeg(int value);
00768 
00770 
00772     void SetPeakEnd(int value);
00773 
00775 
00777     void SetFitBeg(int value);
00778 
00780 
00782     void SetFitEnd(int value);
00783 
00785 
00789     void SetLatencyBeg(double value);
00790 
00792 
00796     void SetLatencyEnd(double value);
00797 
00799 
00801     void SetLatency(double value) { latency=value; }
00802 
00803 #ifdef WITH_PSLOPE
00804 
00805 
00807     void SetPSlopeBeg(int value);
00808 
00810 
00812     void SetPSlopeEnd(int value);
00813 
00815 
00817     void SetPSlope(double value) { PSlope=value; }
00818 
00820 
00822     void SetPSlopeBegMode(stf::pslope_mode_beg value) { pslopeBegMode=value; }
00823 
00825 
00827     void SetPSlopeEndMode(stf::pslope_mode_end value) { pslopeEndMode=value; }
00828 
00830 
00832     void SetDeltaT(int value) { DeltaT=value; }
00833 
00834 #endif // WITH_PSLOPE
00835 
00837 
00839     void SetPM(int value) { pM=value; }
00840 
00842 
00845     void SetRTFactor(int value);
00846 
00848 
00850     void SetLatencyStartMode(stf::latency_mode value) { latencyStartMode=value; }
00851 
00853 
00855     void SetLatencyEndMode(stf::latency_mode value) {
00856         latencyEndMode=value;
00857     }
00858 
00860 
00862     void SetLatencyWindowMode(stf::latency_window_mode value) {
00863         latencyWindowMode=value;
00864     }
00865     
00867 
00869     void SetLatencyStartMode(int value);
00870 
00872 
00874     void SetLatencyEndMode(int value);
00875     
00877 
00879     void SetLatencyWindowMode(int value);
00880 
00882 
00884     void SetDirection(stf::direction value) { direction=value; }
00885 
00887 
00889     void SetFromBase(bool frombase) { fromBase = frombase; }
00890     
00892 
00894     void SetViewCrosshair(bool value) { viewCrosshair=value; }
00895 
00897 
00899     void SetViewBaseline(bool value) { viewBaseline=value; }
00900 
00902 
00904     void SetViewBaseSD(bool value) { viewBaseSD=value; }
00905 
00907 
00909     void SetViewThreshold(bool value) { viewThreshold=value; }
00910 
00912 
00914     void SetViewPeakZero(bool value) { viewPeakzero=value; }
00915 
00917 
00919     void SetViewPeakBase(bool value) { viewPeakbase=value; }
00920 
00922 
00924     void SetViewPeakThreshold(bool value) { viewPeakthreshold=value; }
00925 
00927 
00929     void SetViewRTLoHi(bool value) { viewRTLoHi=value; }
00930 
00932 
00934     void SetViewT50(bool value) { viewT50=value; }
00935 
00937 
00939     void SetViewRD(bool value) { viewRD=value; }
00940 
00942 
00944     void SetViewSlopeRise(bool value) { viewSloperise=value; }
00945 
00947 
00949     void SetViewSlopeDecay(bool value) { viewSlopedecay=value; }
00950 
00952 
00954     void SetViewLatency(bool value) { viewLatency=value; }
00955 
00956 #ifdef WITH_PSLOPE
00957 
00958 
00960     void SetViewPSlope(bool value) { viewPSlope=value; }
00961 #endif
00962 
00964 
00966     void SetViewCursors(bool value) { viewCursors=value; }
00967 
00969 
00971     void SetSlopeForThreshold(double value) { slopeForThreshold=value; }
00972     
00974     stf::Table CurAsTable() const;
00975     
00977 
00983     void CopyCursors(const wxStfDoc& c_Recording);
00984 
00986 
00989     virtual void resize(std::size_t c_n_channels);
00990 
00992 
00996     virtual void InsertChannel(Channel& c_Channel, std::size_t pos);
00997 
00998     const stf::SectionAttributes& GetSectionAttributes(std::size_t nchannel, std::size_t nsection) const;
00999     const stf::SectionAttributes& GetCurrentSectionAttributes() const;
01000     stf::SectionAttributes& GetCurrentSectionAttributesW();
01001 
01003     void DeleteFit(std::size_t nchannel, std::size_t nsection);
01004     
01006 
01012     void SetIsFitted( std::size_t nchannel, std::size_t nsection,
01013                       const Vector_double& bestFitP_, stf::storedFunc* fitFunc_,
01014                       double chisqr, std::size_t fitBeg, std::size_t fitEnd );
01015 
01016 
01018 
01020     void SetIsIntegrated(std::size_t nchannel, std::size_t nsection, bool value,
01021                          std::size_t begin, std::size_t end, const Vector_double& quad_p_);
01022     
01024     void ClearEvents(std::size_t nchannel, std::size_t nsection);
01025 
01026     void correctRangeR(int& value);
01027     void correctRangeR(std::size_t& value);
01028     
01029     DECLARE_EVENT_TABLE()
01030 };
01031 
01034 #endif
01035