From: illysam Date: Mon, 22 Feb 2010 20:29:30 +0000 (+0000) Subject: HookeGUI X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2a29557419d3a48fe13517d27ca50e3b29f65be1;p=hooke.git HookeGUI added curvetools.ini added curvetools.py added multidistance.ini added multidistance.py --- diff --git a/plugins/curvetools.ini b/plugins/curvetools.ini new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/plugins/curvetools.ini @@ -0,0 +1 @@ + diff --git a/plugins/curvetools.py b/plugins/curvetools.py new file mode 100644 index 0000000..cd00fc6 --- /dev/null +++ b/plugins/curvetools.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +curvetools.py + +General library of peak detection related functions. + +Copyright ???? by ? +with modifications by Dr. Rolf Schmidt (Concordia University, Canada) + +This program is released under the GNU General Public License version 2. +''' + +class curvetoolsCommands: + + def fit_interval_nm(self, start_index, x_vect, nm, backwards): + ''' + Calculates the number of points to fit, given a fit interval in nm + start_index: index of point + plot: plot to use + backwards: if true, finds a point backwards. + ''' + + c = 0 + i = start_index + maxlen=len(x_vect) + while abs(x_vect[i] - x_vect[start_index]) * (10**9) < nm: + if i == 0 or i == maxlen-1: #we reached boundaries of vector! + return c + if backwards: + i -= 1 + else: + i += 1 + c += 1 + return c + + def pickup_contact_point(self, filename=''): + ''' + macro to pick up the contact point by clicking + ''' + + contact_point = self._measure_N_points(N=1, message='Please click on the contact point.')[0] + contact_point_index = contact_point.index + self.wlccontact_point = contact_point + self.wlccontact_index = contact_point.index + self.wlccurrent = filename + return contact_point, contact_point_index diff --git a/plugins/multidistance.ini b/plugins/multidistance.ini new file mode 100644 index 0000000..778aef4 --- /dev/null +++ b/plugins/multidistance.ini @@ -0,0 +1,83 @@ +[multidistance] + [[apply_plotmanipulators]] + default = all + elements = all, flatten, none + type = enum + value = all + + [[blindwindow]] + default = 20 + maximum = 10000 + minimum = 0 + type = float + value = 20 + + [[color]] + default = black + type = color + value = "(0,0,0)" + + [[convolution]] + default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" + type = string + value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]" + + [[maxcut]] + default = 0.2 + maximum = 1 + minimum = 0 + type = float + value = 0.2 + visible = False + + [[medianfilter]] + default = 7 + maximum = 100 + minimum = 0 + type = integer + value = 7 + + [[mindeviation]] + default = 5 + maximum = 100 + minimum = 0 + type = float + value = 5 + + [[minpeaks]] + default = 5 + maximum = 20 + minimum = 0 + type = integer + value = 5 + + [[positive]] + default = False + type = boolean + value = False + + [[seedouble]] + default = 10 + maximum = 1000 + minimum = 0 + type = integer + value = 10 + + [[size]] + default = 20 + maximum = 10000 + minimum = 1 + type = integer + value = 20 + + [[stable]] + default = 0.005 + maximum = 1 + minimum = 0 + type = float + value = 0.005 + + [[use_convfilt]] + default = False + type = boolean + value = False diff --git a/plugins/multidistance.py b/plugins/multidistance.py new file mode 100644 index 0000000..77b08fa --- /dev/null +++ b/plugins/multidistance.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +''' +multidistance.py + +Calculates the distances between peaks. + +Copyright 2010 by Fabrizio Benedetti +with modifications by Dr. Rolf Schmidt (Concordia University, Canada) + +This program is released under the GNU General Public License version 2. +''' + +import lib.libhooke as lh +import wxversion +wxversion.select(lh.WX_GOOD) + +import copy +from numpy import RankWarning +import os.path +import time + +import warnings +warnings.simplefilter('ignore', RankWarning) + +import lib.plugin +import lib.results + +class multidistanceCommands: + + def do_multidistance(self): + ''' + MULTIDISTANCE + multidistance.py + Based on the convolution recognition automatically gives the distances between the peaks found. + The command allows also to remove the unwanted peaks that can be due to interference. + When you first issue the command, it will ask for a filename. If you are giving a filename + of an existing file, autopeak will resume it and append measurements to it. If you are giving + a new filename, it will create the file and append to it until you close Hooke. + You can also define a minimun deviation of the peaks. + + Syntax: + multidistance [deviation] + deviation = number of times the convolution signal is above the noise absolute deviation. + ''' + + color = self.GetColorFromConfig('multidistance', 'color') + size = self.GetIntFromConfig('multidistance', 'size') + use_convfilt = self.GetBoolFromConfig('multidistance', 'use_convfilt') + + plot = self.GetDisplayedPlotCorrected() + if use_convfilt: + peak_location, peak_size = self.has_peaks(plot) + else: + plugin = lib.plugin.Plugin() + plugin.name = 'multidistance' + plugin.section = 'multidistance' + peak_location, peak_size = self.has_peaks(plot, plugin) + + #if no peaks, we have nothing to plot. exit. + if len(peak_location) == 0: + self.AppendToOutput('No peaks found.') + return + + retraction = plot.curves[lh.RETRACTION] + results = lib.results.ResultsMultiDistance() + + for peak in peak_location: + result = lib.results.Result() + result.result['Distance'] = retraction.x[peak] + result.color = color + result.size = size + result.x = retraction.x[peak] + result.y = retraction.y[peak] + results.results.append(result) + + results.update() + + self.results_str = 'multidistance' + + results.set_multipliers(-1) + plot = self.GetActivePlot() + plot.results['multidistance'] = results + self.UpdatePlot()