Unverified Commit 4b9e5742 authored by Christoph Schmidt-Hieber's avatar Christoph Schmidt-Hieber Committed by GitHub

Merge pull request #72 from JoseGuzman/master

Simplified event detection documentation
parents d78b0c52 40d224dc
......@@ -49,7 +49,7 @@ master_doc = 'contents'
# General information about the project.
project = u'Stimfit'
copyright = u'2015, Christoph Schmidt-Hieber'
copyright = u'2018, Christoph Schmidt-Hieber'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......
......@@ -7,10 +7,20 @@
#include "./../../stf.h"
#include "./eventdlg.h"
#include "./../app.h"
enum {wxID_COMBOTEMPLATES};
enum {
wxID_COMBOTEMPLATES,
wxID_CRITERIA,
wxDETECTIONCLEMENTS,
wxDETECTIONJONAS,
wxDETECTIONPERNIA
};
BEGIN_EVENT_TABLE( wxStfEventDlg, wxDialog )
EVT_RADIOBUTTON( wxDETECTIONCLEMENTS, wxStfEventDlg::OnClements )
EVT_RADIOBUTTON( wxDETECTIONJONAS, wxStfEventDlg::OnJonas )
EVT_RADIOBUTTON( wxDETECTIONPERNIA, wxStfEventDlg::OnPernia )
END_EVENT_TABLE()
wxStfEventDlg::wxStfEventDlg(wxWindow* parent, const std::vector<stf::SectionPointer>& templateSections,
......@@ -58,7 +68,7 @@ wxDialog( parent, id, title, pos, size, style ), m_threshold(4.0), m_mode(stf::c
wxStaticText* staticTextThr;
staticTextThr =
new wxStaticText( this, wxID_ANY, wxT("Threshold:"), wxDefaultPosition, wxDefaultSize, 0 );
new wxStaticText( this, wxID_CRITERIA, wxT("Threshold:"), wxDefaultPosition, wxDefaultSize, 0 );
gridSizer->Add( staticTextThr, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2 );
wxString def; def << m_threshold;
m_textCtrlThr =
......@@ -77,16 +87,30 @@ wxDialog( parent, id, title, pos, size, style ), m_threshold(4.0), m_mode(stf::c
topSizer->Add( gridSizer, 0, wxALIGN_CENTER | wxALL, 5 );
//*** Radio options for event detection methods ***//
m_radioBox = new wxStaticBoxSizer( wxVERTICAL, this, wxT("Detection method"));
wxString m_radioBoxChoices[] = {
wxT("Use template scaling (Clements && Bekkers)"),
wxT("Use correlation coefficient (Jonas et al.)"),
wxT("Use deconvolution (Pernia-Andrade et al.)")
wxT("Template scaling (Clements && Bekkers)"),
wxT("Correlation coefficient (Jonas et al.)"),
wxT("Deconvolution (Pernia-Andrade et al.)")
};
int m_radioBoxNChoices = sizeof( m_radioBoxChoices ) / sizeof( wxString );
m_radioBox =
new wxRadioBox( this, wxID_ANY, wxT("Select method"), wxDefaultPosition, wxDefaultSize,
m_radioBoxNChoices, m_radioBoxChoices, 0, wxRA_SPECIFY_ROWS );
m_radioBox->SetSelection(0);
wxRadioButton* wxRadioClements = new wxRadioButton(this, wxDETECTIONCLEMENTS, m_radioBoxChoices[0],
wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
wxRadioButton* wxRadioJonas = new wxRadioButton(this, wxDETECTIONJONAS, m_radioBoxChoices[1],
wxDefaultPosition, wxDefaultSize);
wxRadioButton* wxRadioPernia = new wxRadioButton(this, wxDETECTIONPERNIA, m_radioBoxChoices[2],
wxDefaultPosition, wxDefaultSize);
m_radioBox->Add(wxRadioClements, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2);
m_radioBox->Add(wxRadioJonas, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2);
m_radioBox->Add(wxRadioPernia, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2);
//m_radioBox->SetSelection(0);
topSizer->Add( m_radioBox, 0, wxALIGN_CENTER | wxALL, 5 );
}
......@@ -103,18 +127,29 @@ wxDialog( parent, id, title, pos, size, style ), m_threshold(4.0), m_mode(stf::c
}
void wxStfEventDlg::EndModal(int retCode) {
wxCommandEvent unusedEvent;
// similar to overriding OnOK in MFC (I hope...)
if (retCode==wxID_OK) {
switch( retCode) {
case wxID_OK:
if (!OnOK()) {
wxLogMessage(wxT("Select a detection method"));
return;
}
break;
case wxID_CANCEL:
break;
default:
return;
}
wxDialog::EndModal(retCode);
}
bool wxStfEventDlg::OnOK() {
// Read template:
m_template=m_comboBoxTemplates->GetCurrentSelection();
m_template = m_comboBoxTemplates->GetCurrentSelection();
if (m_template<0) {
wxLogMessage(wxT("Please select a valid template"));
return false;
......@@ -125,7 +160,22 @@ bool wxStfEventDlg::OnOK() {
long tempLong;
m_textCtrlDist->GetValue().ToLong( &tempLong );
m_minDistance = (int)tempLong;
switch (m_radioBox->GetSelection()) {
wxRadioButton* wxRadioClements = (wxRadioButton*)FindWindow(wxDETECTIONCLEMENTS);
wxRadioButton* wxRadioJonas = (wxRadioButton*)FindWindow(wxDETECTIONJONAS);
wxRadioButton* wxRadioPernia = (wxRadioButton*)FindWindow(wxDETECTIONPERNIA);
if ( wxRadioClements->GetValue() )
m_mode = stf::criterion;
else if ( wxRadioJonas->GetValue() )
m_mode = stf::correlation;
else if ( wxRadioPernia->GetValue() )
m_mode = stf::deconvolution;
else
return false;
/*switch (m_radioBox->GetSelection()) {
case 0:
m_mode = stf::criterion;
break;
......@@ -135,7 +185,7 @@ bool wxStfEventDlg::OnOK() {
case 2:
m_mode = stf::deconvolution;
break;
}
}*/
if (m_mode==stf::correlation && (m_threshold<0 || m_threshold>1)) {
wxLogMessage(wxT("Please select a value between 0 and 1 for the correlation coefficient"));
return false;
......@@ -143,3 +193,45 @@ bool wxStfEventDlg::OnOK() {
}
return true;
}
void wxStfEventDlg::OnClements( wxCommandEvent& event) {
event.Skip();
wxRadioButton* wxRadioClements = (wxRadioButton*)FindWindow(wxDETECTIONCLEMENTS);
wxStaticText* staticTextThr = (wxStaticText*)FindWindow(wxID_CRITERIA);
if (wxRadioClements == NULL || staticTextThr == NULL){
wxGetApp().ErrorMsg(wxT("Null pointer in wxStfEvenDlg::OnClements()"));
return;
}
staticTextThr->SetLabel(wxT("Threshold:"));
}
void wxStfEventDlg::OnJonas( wxCommandEvent& event) {
event.Skip();
wxRadioButton* wxRadioJonas = (wxRadioButton*)FindWindow(wxDETECTIONJONAS);
wxStaticText* staticTextThr = (wxStaticText*)FindWindow(wxID_CRITERIA);
if (wxRadioJonas == NULL || staticTextThr == NULL){
wxGetApp().ErrorMsg(wxT("Null pointer in wxStfEvenDlg::OnJonas()"));
return;
}
staticTextThr->SetLabel(wxT("Correlation:"));
}
void wxStfEventDlg::OnPernia( wxCommandEvent& event) {
event.Skip();
wxRadioButton* wxRadioPernia = (wxRadioButton*)FindWindow(wxDETECTIONPERNIA);
wxStaticText* staticTextThr = (wxStaticText*)FindWindow(wxID_CRITERIA);
if (wxRadioPernia == NULL || staticTextThr == NULL){
wxGetApp().ErrorMsg(wxT("Null pointer in wxStfEvenDlg::OnPernia()"));
return;
}
staticTextThr->SetLabel( wxT("Standard deviation:") );
}
......@@ -42,9 +42,19 @@ private:
int m_template;
wxStdDialogButtonSizer* m_sdbSizer;
wxTextCtrl *m_textCtrlThr, *m_textCtrlDist;
wxRadioBox* m_radioBox;
wxStaticBoxSizer* m_radioBox;
wxComboBox* m_comboBoxTemplates;
wxStaticText* staticTextThr;
wxRadioButton* wxRadioClements;
wxRadioButton* wxRadioJonas;
wxRadioButton* wxRadioPernia;
void OnClements( wxCommandEvent & event );
void OnJonas( wxCommandEvent & event );
void OnPernia( wxCommandEvent & event );
//! Only called when a modal dialog is closed with the OK button.
/*! \return true if all dialog entries could be read successfully
*/
......
"""Performs fits as decribed in the manual to create
preliminary and final templates from minis.dat.
last revision: May 09, 2008
"""
minidemo.py
This script sets base, peak and fit cursors to
perform events detection as decribed in the Stimfit manual [1]
It creates a preliminary and final templates from a file 'minis.dat'.
You can download the file here: http://stimfit.org/tutorial/minis.dat
last revision: Wed Sep 5 09:38:41 CEST 2018
C. Schmidt-Hieber
[1] https://neurodroid.github.io/stimfit/manual/event_extraction.html
"""
import stf
from wx import MessageBox
if stf.get_filename()[-9:] != 'minis.dat':
MessageBox('Use minis.dat for this demo.', 'Warning')
def preliminary():
"""Creates a preliminary template"""
stf.set_peak_start(209900)
stf.set_peak_end(210500)
stf.set_fit_start(209900)
stf.set_fit_end(210400)
"""
Sets peak, base and fit cursors around a synaptic event
and performs a biexponential fit to create the preliminary template
for event detection.
"""
stf.base.cursor_index = (209600, 209900)
stf.peak.cursor_index = (209900, 210500)
stf.fit.cursor_index = (209900, 210400)
stf.set_peak_mean(3)
stf.set_base_start(209600)
stf.set_base_end(209900)
stf.measure()
stf.measure() # update cursors
return stf.leastsq(5)
def final():
"""Creates a final template"""
stf.set_peak_start(100)
stf.set_peak_end(599)
stf.set_fit_start(100)
stf.set_fit_end(599)
"""
Sets peak, base and fit cursors around a synaptic event
and performs a biexponetial fit to create the final template
for event detection.
"""
stf.base.cursor_index = (000, 100)
stf.peak.cursor_index = (100, 599)
stf.fit.cursor_index = (100, 599)
stf.set_peak_mean(3)
stf.set_base_start(0)
stf.set_base_end(100)
stf.measure()
stf.measure() # update cursors
return stf.leastsq(5)
def batch_cursors():
"""Sets appropriate cursor positions for analysing
the extracted events."""
stf.set_peak_start(100)
stf.set_peak_end(598)
stf.set_fit_start(120)
stf.set_fit_end(598)
"""
Sets peak, base and fit cursors around a synaptic event
for the batch analysis of the extracted events.
"""
stf.base.cursor_index = (000, 100)
stf.peak.cursor_index = (100, 598)
stf.fit.cursor_index = (120, 598)
stf.set_peak_mean(3)
stf.set_base_start(0)
stf.set_base_end(100)
stf.measure()
stf.measure() # update cursors
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment