generalvclamp = True\r
multidistance = True\r
playlist = True\r
+plot = True\r
procplots = True\r
results = True\r
\r
Driver for jpk files.
-Copyright ??? by Massimo Sandal?
+Copyright Copyright 2008 by Massimo Sandal (University of Bologna, Italy)
with modifications by Dr. Rolf Schmidt (Concordia University, Canada)
This program is released under the GNU General Public License version 2.
'''\r
HOOKE - A force spectroscopy review & analysis tool\r
\r
-Copyright 2008 by Massimo Sandal (University of Bologna, Italy).\r
-Copyright 2010 by Rolf Schmidt (Concordia University, Canada).\r
+Copyright 2008 by Massimo Sandal (University of Bologna, Italy)\r
+Copyright 2010 by Rolf Schmidt (Concordia University, Canada)\r
\r
This program is released under the GNU General Public License version 2.\r
'''\r
\r
-import wxversion\r
import lib.libhooke as lh\r
+import wxversion\r
wxversion.select(lh.WX_GOOD)\r
\r
from configobj import ConfigObj\r
from scipy import __version__ as scipy_version\r
from sys import version as python_version\r
from wx import __version__ as wx_version\r
+from matplotlib.ticker import FuncFormatter\r
\r
try:\r
from agw import cubecolourdialog as CCD\r
lh.hookeDir = os.path.abspath(os.path.dirname(__file__))\r
from config.config import config\r
import drivers\r
+import lib.delta\r
import lib.playlist\r
import lib.plotmanipulator\r
+import lib.prettyformat\r
import panels.commands\r
import panels.perspectives\r
import panels.playlist\r
return config[section][key]['value']\r
return None\r
\r
+ def GetPlotmanipulator(self, name):\r
+ '''\r
+ Returns a plot manipulator function from its name\r
+ '''\r
+ for plotmanipulator in self.plotmanipulators:\r
+ if plotmanipulator.name == name:\r
+ return plotmanipulator\r
+ return None\r
+\r
def GetPerspectiveMenuItem(self, name):\r
if self._perspectives.has_key(name):\r
perspectives_list = [key for key, value in self._perspectives.iteritems()]\r
point.find_graph_coords(xvector, yvector)\r
return point\r
\r
- def _delta(self, message='Click 2 points', plugin=None):\r
+ def _delta(self, message='Click 2 points', whatset=lh.RETRACTION):\r
'''\r
calculates the difference between two clicked points\r
'''\r
- if plugin is None:\r
- color = 'black'\r
- show_points = True\r
- size = 20\r
- whatset = lh.RETRACTION\r
- else:\r
- color = self.GetColorFromConfig(plugin.name, plugin.section, plugin.prefix + 'color')\r
- show_points = self.GetBoolFromConfig(plugin.name, plugin.section, plugin.prefix + 'show_points')\r
- size = self.GetIntFromConfig(plugin.name, plugin.section, plugin.prefix + 'size')\r
- whatset_str = self.GetStringFromConfig(plugin.name, plugin.section, plugin.prefix + 'whatset')\r
- if whatset_str == 'extension':\r
- whatset = lh.EXTENSION\r
- if whatset_str == 'retraction':\r
- whatset = lh.RETRACTION\r
-\r
clicked_points = self._measure_N_points(N=2, message=message, whatset=whatset)\r
- dx = abs(clicked_points[0].graph_coords[0] - clicked_points[1].graph_coords[0])\r
- dy = abs(clicked_points[0].graph_coords[1] - clicked_points[1].graph_coords[1])\r
\r
plot = self.GetDisplayedPlotCorrected()\r
-\r
curve = plot.curves[whatset]\r
- unitx = curve.units.x\r
- unity = curve.units.y\r
-\r
- #TODO: move this to clicked_points?\r
- if show_points:\r
- for point in clicked_points:\r
- points = copy.deepcopy(curve)\r
- points.x = point.graph_coords[0]\r
- points.y = point.graph_coords[1]\r
\r
- points.color = color\r
- points.size = size\r
- points.style = 'scatter'\r
- plot.curves.append(points)\r
+ delta = lib.delta.Delta()\r
+ delta.point1.x = clicked_points[0].graph_coords[0]\r
+ delta.point1.y = clicked_points[0].graph_coords[1]\r
+ delta.point2.x = clicked_points[1].graph_coords[0]\r
+ delta.point2.y = clicked_points[1].graph_coords[1]\r
+ delta.units.x = curve.units.x\r
+ delta.units.y = curve.units.y\r
\r
- self.UpdatePlot(plot)\r
-\r
- return dx, unitx, dy, unity\r
+ return delta\r
\r
def _measure_N_points(self, N, message='', whatset=lh.RETRACTION):\r
'''\r
if curve.visible and curve.x and curve.y:\r
destination = (curve.destination.column - 1) * number_of_rows + curve.destination.row - 1\r
axes_list[destination].set_title(curve.title)\r
- axes_list[destination].set_xlabel(curve.units.x)\r
- axes_list[destination].set_ylabel(curve.units.y)\r
+ axes_list[destination].set_xlabel(multiplier_x + curve.units.x)\r
+ axes_list[destination].set_ylabel(multiplier_y + curve.units.y)\r
if curve.style == 'plot':\r
axes_list[destination].plot(curve.x, curve.y, color=curve.color, label=curve.label, lw=curve.linewidth, zorder=1)\r
if curve.style == 'scatter':\r
axes_list[destination].scatter(curve.x, curve.y, color=curve.color, label=curve.label, s=curve.size, zorder=2)\r
\r
+ def get_format_x(x, pos):\r
+ 'The two args are the value and tick position'\r
+ multiplier = lib.prettyformat.get_exponent(multiplier_x)\r
+ decimals_str = '%.' + str(decimals_x) + 'f'\r
+ return decimals_str % (x/(10 ** multiplier))\r
+\r
+ def get_format_y(x, pos):\r
+ 'The two args are the value and tick position'\r
+ multiplier = lib.prettyformat.get_exponent(multiplier_y)\r
+ decimals_str = '%.' + str(decimals_y) + 'f'\r
+ return decimals_str % (x/(10 ** multiplier))\r
+\r
+ decimals_x = self.GetIntFromConfig('plot', 'x_decimals')\r
+ decimals_y = self.GetIntFromConfig('plot', 'y_decimals')\r
+ multiplier_x = self.GetStringFromConfig('plot', 'x_multiplier')\r
+ multiplier_y = self.GetStringFromConfig('plot', 'y_multiplier')\r
+\r
if plot is None:\r
active_file = self.GetActiveFile()\r
if not active_file.driver:\r
for index in range(number_of_rows * number_of_columns):\r
axes_list.append(figure.add_subplot(number_of_rows, number_of_columns, index + 1))\r
\r
+ for axes in axes_list:\r
+ formatter_x = FuncFormatter(get_format_x)\r
+ formatter_y = FuncFormatter(get_format_y)\r
+ axes.xaxis.set_major_formatter(formatter_x)\r
+ axes.yaxis.set_major_formatter(formatter_y)\r
+\r
for curve in self.displayed_plot.curves:\r
add_to_plot(curve)\r
\r
else:\r
self.panelResults.ClearResults()\r
\r
- figure.canvas.draw()\r
-\r
+ legend = self.GetBoolFromConfig('plot', 'legend')\r
for axes in axes_list:\r
- #TODO: add legend as global option or per graph option\r
- #axes.legend()\r
- axes.figure.canvas.draw()\r
-\r
+ if legend:\r
+ axes.legend()\r
+ figure.canvas.draw()\r
\r
if __name__ == '__main__':\r
\r
History\r
2009 07 16: added negative number support\r
added decimal-formatted output\r
+2010 02 25: renamed variables to a more pythonic style\r
+ added whitespace stripping option to prettyformat()\r
+ added get_multiplier()\r
+ added get_exponent()\r
+ updated examples\r
\r
Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
\r
import math\r
from numpy import isnan\r
\r
-def pretty_format(fValue, sUnit='', iDecimals=-1, iMultiplier=1, bLeadingSpaces=False):\r
- if fValue == 0:\r
+def pretty_format(value, unit='', decimals=-1, multiplier=0, leading_spaces=False):\r
+ if value == 0:\r
return '0'\r
- if isnan(fValue):\r
+ if isnan(value):\r
return 'NaN'\r
\r
- iLeadingSpaces = 0\r
- if bLeadingSpaces:\r
- iLeadingSpaces = 5\r
- if iMultiplier == 1:\r
- iMultiplier=get_multiplier(fValue)\r
- sUnitString = ''\r
- if sUnit != '':\r
- sUnitString = ' ' + get_prefix(iMultiplier) + sUnit\r
- if iDecimals >= 0:\r
- formatString = '% ' + repr(iLeadingSpaces + iDecimals) + '.' + repr(iDecimals) + 'f'\r
- return formatString % (fValue / iMultiplier) + sUnitString\r
+ output_str = ''\r
+ leading_spaces_int = 0\r
+ if leading_spaces:\r
+ leading_spaces_int = 5\r
+ if multiplier == 0:\r
+ multiplier=get_multiplier(value)\r
+ unit_str = ''\r
+ if unit != '':\r
+ unit_str = ' ' + get_prefix(multiplier) + unit\r
+ if decimals >= 0:\r
+ format_str = '% ' + repr(leading_spaces_int + decimals) + '.' + repr(decimals) + 'f'\r
+ output_str = format_str % (value / multiplier) + unit_str\r
else:\r
- return str(fValue / iMultiplier) + sUnitString\r
- return str(fValue / iMultiplier) + ' ' + get_prefix(fValue / iMultiplier) + sUnit\r
+ output_str = str(value / multiplier) + unit_str\r
\r
-def get_multiplier(fValue):\r
- return pow(10, get_power(fValue))\r
+ if decimals < 0:\r
+ output_str = str(value / multiplier) + ' ' + get_prefix(value / multiplier) + unit\r
\r
-def get_power(fValue):\r
- if fValue != 0 and not isnan(fValue):\r
- #get the log10 from fValue (make sure the value is not negative)\r
- dHelp = math.floor(math.log10(math.fabs(fValue)))\r
+ if leading_spaces_int == 0:\r
+ output_str = output_str.lstrip()\r
+\r
+ return output_str\r
+\r
+def get_multiplier(value):\r
+ return pow(10, get_power(value))\r
+\r
+def get_power(value):\r
+ if value != 0 and not isnan(value):\r
+ #get the log10 from value (make sure the value is not negative)\r
+ value_temp = math.floor(math.log10(math.fabs(value)))\r
#reduce the log10 to a multiple of 3 and return it\r
- return dHelp-(dHelp % 3)\r
+ return value_temp - (value_temp % 3)\r
else:\r
return 0\r
\r
-def get_prefix(fValue):\r
+def get_exponent(prefix):\r
+ #set up a dictionary to find the exponent\r
+ exponent = {\r
+ 'Y': 24,\r
+ 'Z': 21,\r
+ 'E': 18,\r
+ 'P': 15,\r
+ 'T': 12,\r
+ 'G': 9,\r
+ 'M': 6,\r
+ 'k': 3,\r
+ '': 0,\r
+ 'm': -3,\r
+ u'\u00B5': -6,\r
+ 'n': -9,\r
+ 'p': -12,\r
+ 'f': -15,\r
+ 'a': -18,\r
+ 'z': -21,\r
+ 'y': -24,\r
+ }\r
+ if exponent.has_key(prefix):\r
+ return exponent[prefix]\r
+ else:\r
+ return 1\r
+\r
+def get_prefix(value):\r
#set up a dictionary to find the prefix\r
prefix = {\r
24: lambda: 'Y',\r
-21: lambda: 'z',\r
-24: lambda: 'y',\r
}\r
- if fValue != 0 and not isnan(fValue):\r
- #get the log10 from fValue\r
- dHelp = math.floor(math.log10(math.fabs(fValue)))\r
+ if value != 0 and not isnan(value):\r
+ #get the log10 from value\r
+ value_temp = math.floor(math.log10(math.fabs(value)))\r
else:\r
- dHelp = 0\r
+ value_temp = 0\r
#reduce the log10 to a multiple of 3 and create the return string\r
- return prefix.get(dHelp - (dHelp % 3))()\r
+ return prefix.get(value_temp - (value_temp % 3))()\r
\r
'''\r
-dTestValue=-2.4115665714484597e-008\r
-print 'Value: '+str(dTestValue)+')'\r
+test_value=-2.4115665714484597e-008\r
+print 'Value: '+str(test_value)+')'\r
print 'pretty_format example (value, unit)'\r
-print pretty_format(dTestValue, 'N')\r
+print pretty_format(test_value, 'N')\r
print'-----------------------'\r
print 'pretty_format example (value, unit, decimals)'\r
-print pretty_format(dTestValue, 'N', 3)\r
+print pretty_format(test_value, 'N', 3)\r
print'-----------------------'\r
print 'pretty_format example (value, unit, decimals, multiplier)'\r
-print pretty_format(dTestValue, 'N', 5, 0.000001)\r
+print pretty_format(test_value, 'N', 5, 0.000001)\r
print'-----------------------'\r
print 'pretty_format example (value, unit, decimals, multiplier, leading spaces)'\r
print pretty_format(0.0166276297705, 'N', 3, 0.001, True)\r
print pretty_format(0.0136453282825, 'N', 3, 0.001, True)\r
'''\r
'''\r
-#example use autoFormatValue\r
-dTestValue=0.00000000567\r
-print 'autoFormatValue example ('+str(dTestValue)+')'\r
-print autoFormatValue(dTestValue, 'N')\r
-#outputs 5.67 nN\r
-'''\r
-'''\r
-#example use of decimalFormatValue(fValue, iDecimals, sUnit):\r
-dTestValue=-2.4115665714484597e-008\r
-iDecimals=3\r
-print 'decimalFormatValue example ('+str(dTestValue)+')'\r
-print decimalFormatValue(dTestValue, iDecimals, 'N')\r
-#outputs -24.116 nN\r
-#change iDecimals to see the effect\r
-'''\r
-'''\r
-#example use formatValue\r
-dTestValue=0.000000000567\r
-print 'formatValue example ('+str(dTestValue)+')'\r
-#find the (common) multiplier\r
-iMultiplier=get_multiplier(dTestValue)\r
-#use the multiplier and a unit to format the value\r
-print formatValue(dTestValue, iMultiplier, 'N')\r
-#outputs 567.0 pN\r
-'''\r
-'''\r
#to output a scale:\r
#choose any value on the axis and find the multiplier and prefix for it\r
#use those to format the rest of the scale\r
#as values can span several orders of magnitude, you have to decide what units to use\r
\r
#tuple of values:\r
-scaleValues=0.000000000985, 0.000000001000, 0.000000001015\r
+scale_values=0.000000000985, 0.000000001000, 0.000000001015\r
#use this element (change to 1 or 2 to see the effect on the scale and label)\r
-iIndex=0\r
-#get the multiplier from the value at iIndex\r
-iMultiplier=get_multiplier(scaleValues[iIndex])\r
+index=0\r
+#get the multiplier from the value at index\r
+multiplier=get_multiplier(scale_values[index])\r
print '\nScale example'\r
-iDecimals=3\r
+decimals=3\r
#print the scale\r
-for aValue in scaleValues: print decimalFormat(aValue/iMultiplier, iDecimals),\r
-#print the scale label using the value at iIndex\r
-print '\n'+get_prefix(scaleValues[iIndex])+'N'\r
+for aValue in scale_values: print decimalFormat(aValue/multiplier, decimals),\r
+#print the scale label using the value at index\r
+print '\n'+get_prefix(scale_values[index])+'N'\r
'''
\ No newline at end of file
Automatic peak detection and analysis.
-Copyright ???? by ?
+Copyright 2008 Massimo Sandal, Fabrizio Benedetti, Marco Brucale
with modifications by Dr. Rolf Schmidt (Concordia University, Canada)
This program is released under the GNU General Public License version 2.
Configuration
-------------
- apply_plotmanipulators:
- - all (all selected plotmanipulators will be applied)
- - flatten (only the flatten plotmanipulator will be applied)
- - none (no plotmanipulators will be applied)
fit_function: type of function to use for elasticity. If "wlc" worm-like chain is used, if "fjc" freely jointed
chain is used
if not usepl:
pl_value = None
else:
- pl_value = persistence_length / 10**9
+ pl_value = persistence_length / 10 ** 9
usepoints = self.GetBoolFromConfig('autopeak', 'usepoints')
whatset_str = self.GetStringFromConfig('autopeak', 'whatset')
if whatset_str == 'extension':
plot = self.GetDisplayedPlotCorrected()
filename = self.GetActiveFile().name
- TODO: add convfilt option?
+ #TODO: add convfilt option?
#--Using points instead of nm interval
if not usepoints:
fit_points = None
import scipy.stats
import scipy.odr
-from lib.libhooke import coth
-
class fitCommands(object):
'''
Do not use any of the following commands directly:
therm=Kb*T
#x=(therm*pii/4.0) * (((1-(x*lambd))**-2) - 1 + (4*x*lambd))
- x=(1/lambd)*(coth(f*(1/pii)/therm) - (therm*pii)/f)
+ x=(1/lambd)*(lh.coth(f*(1/pii)/therm) - (therm*pii)/f)
return x
def x_fjc_plfix(params,f,pl_value=pl_value,T=T):
Kb=(1.38065e-23)
therm=Kb*T
#y=(therm*pii/4.0) * (((1-(x*lambd))**-2) - 1 + (4*x*lambd))
- x=(1/lambd)*(coth(f*(1/pii)/therm) - (therm*pii)/f)
+ x=(1/lambd)*(lh.coth(f*(1/pii)/therm) - (therm*pii)/f)
return x
#make the ODR fit
Kb = (1.38065e-23) #Boltzmann constant
therm = Kb * T #so we have thermal energy
#return ( (therm*pii/4.0) * (((1-(x*lambd))**-2.0) - 1 + (4.0*x*lambd)) )
- return (1 / lambd) * (coth(y * (1 / pii) / therm) - (therm * pii) / y)
+ return (1 / lambd) * (lh.coth(y * (1 / pii) / therm) - (therm * pii) / y)
#STEP 3: plotting the fit
#x=(therm*pii/4.0) * (((1-(x*lambd))**-2) - 1 + (4*x*lambd))
- x=(1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (coth(f*(1/pii)/therm) - (therm*pii)/f)
+ x=(1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (lh.coth(f*(1/pii)/therm) - (therm*pii)/f)
return x
def x_fjcPEG_plfix(params,f,pl_value=pl_value,T=T):
Kb=(1.38065e-23)
therm=Kb*T
#y=(therm*pii/4.0) * (((1-(x*lambd))**-2) - 1 + (4*x*lambd))
- x=(1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (coth(f*(1/pii)/therm) - (therm*pii)/f)
+ x=(1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (lh.coth(f*(1/pii)/therm) - (therm*pii)/f)
return x
#make the ODR fit
Kb = (1.38065e-23) #Boltzmann constant
therm = Kb * T #so we have thermal energy
#return ( (therm*pii/4.0) * (((1-(x*lambd))**-2.0) - 1 + (4.0*x*lambd)) )
- return (1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (coth(y*(1/pii)/therm) - (therm*pii)/y)
+ return (1/lambd)*(1 / (exp(delta_G) + 1) + (L_helical/L_planar) * (1 / (exp(-delta_G) + 1))) * (lh.coth(y*(1/pii)/therm) - (therm*pii)/y)
#STEP 3: plotting the fit
#handle contact point arguments correctly
if 'reclick' in args.split():
print 'Click contact point'
- contact_point=self._measure_N_points(N=1, whatset=1)[0]
+ contact_point=self._measure_N_points(N=1, whatset=lh.RETRACTION)[0]
contact_point_index=contact_point.index
self.wlccontact_point=contact_point
self.wlccontact_index=contact_point.index
elif 'noauto' in args.split():
if self.wlccontact_index is None or self.wlccurrent != self.current.path:
print 'Click contact point'
- contact_point=self._measure_N_points(N=1, whatset=1)[0]
+ contact_point=self._measure_N_points(N=1, whatset=lh.RETRACTION)[0]
contact_point_index=contact_point.index
self.wlccontact_point=contact_point
self.wlccontact_index=contact_point.index
contact_point.is_marker=True
print 'Click edges of chunk'
- points=self._measure_N_points(N=2, whatset=1)
+ points=self._measure_N_points(N=2, whatset=lh.RETRACTION)
points=[contact_point]+points
try:
if self.config['fit_function']=='wlc':
Plugin dependencies:
procplots.py (plot processing plugin)
-Copyright ???? by ?
+Copyright 2008 Massimo Sandal, Fabrizio Benedetti
with modifications by Dr. Rolf Schmidt (Concordia University, Canada)
This program is released under the GNU General Public License version 2.
file_index += 1
try:
current_file.identify(self.drivers)
- plot = self.ApplyPlotmanipulators(current_file.plot, current_file)
+ if apply_plotmanipulators == 'all':
+ plot = self.ApplyPlotmanipulators(current_file.plot, current_file)
+ if apply_plotmanipulators == 'flatten':
+ plotmanipulator = self.GetPlotmanipulator('flatten')
+ plot = plotmanipulator.method(current_file.plot, current_file)
+ if apply_plotmanipulators == 'none':
+ plot = copy.deepcopy(current_file.plot)
+
peak_location, peak_size = self.has_peaks(plot)
number_of_peaks = len(peak_location)
if number_of_peaks != 1:
[[color]]\r
default = black\r
type = color\r
- value = "(128,0,128)"\r
+ value = "(0,0,0)"\r
+ \r
+ [[decimals]]\r
+ default = 2\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 2\r
+ \r
+ [[multiplier]]\r
+ default = n\r
+ elements = n, p\r
+ type = enum\r
+ value = n\r
\r
[[show]]\r
default = True\r
type = boolean\r
value = True\r
\r
+ [[show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
[[size]]\r
default = 20\r
maximum = 10000\r
minimum = 1\r
type = integer\r
- value = 100\r
+ value = 20\r
\r
[[whatset]]\r
default = retraction\r
[[color]]\r
default = black\r
type = color\r
- value = "(0,255,0)"\r
+ value = "(0,0,0)"\r
+ \r
+ [[decimals]]\r
+ default = 2\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 2\r
+ \r
+ [[multiplier]]\r
+ default = p\r
+ elements = n, p\r
+ type = enum\r
+ value = p\r
\r
[[show]]\r
default = True\r
type = boolean\r
- value = False\r
+ value = True\r
+ \r
+ [[show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
\r
[[size]]\r
default = 20\r
maximum = 10000\r
minimum = 1\r
type = integer\r
- value = 100\r
+ value = 20\r
\r
[[whatset]]\r
default = retraction\r
type = none\r
value = 1\r
\r
- [[color]]\r
+ [[baseline_color]]\r
default = black\r
type = color\r
- value = "(255,0,128)"\r
+ value = "(0,0,0)"\r
+ \r
+ [[baseline_show]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
+ [[baseline_show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
+ [[baseline_size]]\r
+ default = 20\r
+ maximum = 10000\r
+ minimum = 1\r
+ type = integer\r
+ value = 20\r
+ \r
+ [[decimals]]\r
+ default = 2\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 2\r
\r
[[max]]\r
default = False\r
type = boolean\r
value = False\r
\r
- [[rebase]]\r
- default = False\r
+ [[maximum_color]]\r
+ default = black\r
+ type = color\r
+ value = "(0,0,0)"\r
+ \r
+ [[maximum_show]]\r
+ default = True\r
type = boolean\r
- value = False\r
+ value = True\r
\r
- [[show]]\r
+ [[maximum_show_in_legend]]\r
default = True\r
type = boolean\r
value = True\r
\r
- [[size]]\r
+ [[maximum_size]]\r
+ default = 20\r
+ maximum = 10000\r
+ minimum = 1\r
+ type = integer\r
+ value = 20\r
+ \r
+ [[maximumrange_color]]\r
+ default = black\r
+ type = color\r
+ value = "(0,0,0)"\r
+ \r
+ [[maximumrange_show]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
+ [[maximumrange_show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
+ [[maximumrange_size]]\r
default = 20\r
maximum = 10000\r
minimum = 1\r
type = integer\r
- value = 50\r
+ value = 20\r
+ \r
+ [[multiplier]]\r
+ default = p\r
+ elements = n, p\r
+ type = enum\r
+ value = p\r
+ \r
+ [[rebase]]\r
+ default = False\r
+ type = boolean\r
+ value = False\r
\r
[[whatset]]\r
default = retraction\r
maximum = 100\r
minimum = 0\r
type = float\r
- value = 2\r
+ value = 1\r
\r
[slope]\r
+ [[decimals]]\r
+ default = 5\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 5\r
+ \r
[[fitspan]]\r
default = 0\r
maximum = 10000\r
minimum = 0\r
type = integer\r
- value = 60\r
+ value = 0\r
\r
[[point_color]]\r
default = black\r
type = color\r
- value = "(0,255,0)"\r
+ value = "(0,0,0)"\r
\r
[[point_show]]\r
default = False\r
type = boolean\r
value = False\r
\r
+ [[point_show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = False\r
+ \r
[[point_size]]\r
default = 20\r
maximum = 10000\r
minimum = 1\r
type = integer\r
- value = 10\r
+ value = 20\r
\r
[[slope_color]]\r
default = black\r
type = color\r
- value = "(255,0,128)"\r
+ value = "(0,0,0)"\r
\r
[[slope_linewidth]]\r
default = 1\r
maximum = 10000\r
minimum = 1\r
type = integer\r
- value = 2\r
+ value = 1\r
\r
[[slope_show]]\r
default = True\r
type = boolean\r
value = True\r
\r
+ [[slope_show_in_legend]]\r
+ default = True\r
+ type = boolean\r
+ value = True\r
+ \r
[[whatset]]\r
default = retraction\r
elements = extension, retraction\r
Plugin regarding general velocity clamp measurements
-Copyright ???? by ?
+Copyright 2008 by Massimo Sandal (University of Bologna, Italy)
with modifications by Dr. Rolf Schmidt (Concordia University, Canada)
This program is released under the GNU General Public License version 2.
import wxversion
wxversion.select(lh.WX_GOOD)
-from copy import deepcopy
import numpy as np
import scipy as sp
warnings.simplefilter('ignore', np.RankWarning)
import lib.curve
+import lib.prettyformat
class generalvclampCommands:
-----------------
Syntax: distance
'''
+ color = self.GetColorFromConfig('generalvclamp', 'distance', 'color')
+ decimals = self.GetIntFromConfig('generalvclamp', 'distance', 'decimals')
+ multiplier_str = self.GetStringFromConfig('generalvclamp', 'distance', 'multiplier')
+ multiplier = lib.prettyformat.get_exponent(multiplier_str)
+ show = self.GetBoolFromConfig('generalvclamp', 'distance', 'show')
+ show_in_legend = self.GetBoolFromConfig('generalvclamp', 'distance', 'show_in_legend')
+ size = self.GetIntFromConfig('generalvclamp', 'distance', 'size')
+ whatset_str = self.GetStringFromConfig('generalvclamp', 'distance', 'whatset')
+ whatset = 'retraction'
+ if whatset_str == 'extension':
+ whatset = lh.EXTENSION
+ if whatset_str == 'retraction':
+ whatset = lh.RETRACTION
+
active_file = self.GetActiveFile()
- plot = self.GetActivePlot()
if active_file.driver.experiment == 'clamp':
self.AppendToOutput('You wanted to use zpiezo perhaps?')
return
plugin = lib.plugin.Plugin()
plugin.name = 'generalvclamp'
plugin.section = 'distance'
- dx, unitx, dy, unity = self._delta(message='Click 2 points to measure the distance.', plugin=plugin)
- #TODO: pretty format
- self.AppendToOutput(str(dx * (10 ** 9)) + ' nm')
+ delta = self._delta(message='Click 2 points to measure the distance.', whatset=whatset)
+
+ plot = self.GetDisplayedPlotCorrected()
+ if show:
+ #add the points to the plot
+ points = lib.curve.Curve()
+ points.color = color
+ if show_in_legend:
+ points.label = 'distance'
+ else:
+ points.label = '_nolegend_'
+ points.size = size
+ points.style = 'scatter'
+ points.units.x = delta.units.x
+ points.units.y = delta.units.y
+ points.x = [delta.point1.x, delta.point2.x]
+ points.y = [delta.point1.y, delta.point2.y]
+ plot.curves.append(points)
+
+ self.UpdatePlot(plot)
+
+ output_str = lib.prettyformat.pretty_format(abs(delta.get_delta_x()), delta.units.x, decimals, 10 ** multiplier)
+ self.AppendToOutput(''.join(['Distance: ', output_str]))
def do_force(self):
'''
---------------
Syntax: force
'''
+ color = self.GetColorFromConfig('generalvclamp', 'force', 'color')
+ decimals = self.GetIntFromConfig('generalvclamp', 'force', 'decimals')
+ multiplier_str = self.GetStringFromConfig('generalvclamp', 'force', 'multiplier')
+ multiplier = lib.prettyformat.get_exponent(multiplier_str)
+ show = self.GetBoolFromConfig('generalvclamp', 'force', 'show')
+ show_in_legend = self.GetBoolFromConfig('generalvclamp', 'force', 'show_in_legend')
+ size = self.GetIntFromConfig('generalvclamp', 'force', 'size')
+ whatset_str = self.GetStringFromConfig('generalvclamp', 'force', 'whatset')
+ whatset = 'retraction'
+ if whatset_str == 'extension':
+ whatset = lh.EXTENSION
+ if whatset_str == 'retraction':
+ whatset = lh.RETRACTION
+
active_file = self.GetActiveFile()
- plot = self.GetActivePlot()
if active_file.driver.experiment == 'clamp':
self.AppendToOutput('This command makes no sense for a force clamp experiment.')
return
plugin = lib.plugin.Plugin()
plugin.name = 'generalvclamp'
plugin.section = 'force'
- dx, unitx, dy, unity = self._delta(message='Click 2 points to measure the force.', plugin=plugin)
- #TODO: pretty format
- self.AppendToOutput(str(dy * (10 ** 12)) + ' pN')
+ delta = self._delta(message='Click 2 points to measure the force.', whatset=whatset)
+
+ plot = self.GetDisplayedPlotCorrected()
+ if show:
+ #add the points to the plot
+ points = lib.curve.Curve()
+ points.color = color
+ if show_in_legend:
+ points.label = 'force'
+ else:
+ points.label = '_nolegend_'
+ points.size = size
+ points.style = 'scatter'
+ points.units.x = delta.units.x
+ points.units.y = delta.units.y
+ points.x = [delta.point1.x, delta.point2.x]
+ points.y = [delta.point1.y, delta.point2.y]
+ plot.curves.append(points)
+
+ self.UpdatePlot(plot)
+
+ output_str = lib.prettyformat.pretty_format(abs(delta.get_delta_y()), delta.units.y, decimals, 10 ** multiplier)
+ self.AppendToOutput(''.join(['Force: ', output_str]))
def do_forcebase(self):
'''
max: Instead of asking for a point to measure, asks for two points and use
the maximum peak in between
'''
- color = self.GetColorFromConfig('generalvclamp', 'forcebase', 'color')
+ baseline_color = self.GetColorFromConfig('generalvclamp', 'forcebase', 'baseline_color')
+ baseline_show = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'baseline_show')
+ baseline_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'baseline_show_in_legend')
+ baseline_size = self.GetIntFromConfig('generalvclamp', 'forcebase', 'baseline_size')
+ decimals = self.GetIntFromConfig('generalvclamp', 'forcebase', 'decimals')
+ maximum_color = self.GetColorFromConfig('generalvclamp', 'forcebase', 'maximum_color')
+ maximum_show = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'maximum_show')
+ maximum_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'maximum_show_in_legend')
+ maximum_size = self.GetIntFromConfig('generalvclamp', 'forcebase', 'maximum_size')
+ maximumrange_color = self.GetColorFromConfig('generalvclamp', 'forcebase', 'maximumrange_color')
+ maximumrange_show = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'maximumrange_show')
+ maximumrange_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'maximumrange_show_in_legend')
+ maximumrange_size = self.GetIntFromConfig('generalvclamp', 'forcebase', 'maximumrange_size')
maxpoint = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'max')
+ multiplier_str = self.GetStringFromConfig('generalvclamp', 'forcebase', 'multiplier')
+ multiplier = lib.prettyformat.get_exponent(multiplier_str)
rebase = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'rebase')
- show_points = self.GetBoolFromConfig('generalvclamp', 'forcebase', 'show_points')
- size = self.GetIntFromConfig('generalvclamp', 'forcebase', 'size')
whatset_str = self.GetStringFromConfig('generalvclamp', 'forcebase', 'whatset')
whatset = 'retraction'
if whatset_str == 'extension':
plot = self.GetDisplayedPlotCorrected()
- clicked_points = []
-
filename = self.GetActiveFile().name
if rebase or (self.basecurrent != filename):
self.basepoints = self._measure_N_points(N=2, message='Click on 2 points to select the baseline.', whatset=whatset)
self.basecurrent = filename
- clicked_points = self.basepoints
- #TODO: maxpoint does not seem to be picking up the 'real' minimum (at least not with test.hkp/default.000)
+ #TODO: maxpoint does not seem to be picking up the 'real' maximum (at least not with test.hkp/default.000)
+ maximumrange_points = []
+ maximum_point = []
if maxpoint:
- boundpoints = []
- points = self._measure_N_points(N=2, message='Click 2 points to select the range for maximum detection.', whatset=whatset)
- boundpoints = [points[0].index, points[1].index]
+ maximumrange_points = self._measure_N_points(N=2, message='Click 2 points to select the range for maximum detection.', whatset=whatset)
+ boundpoints = [maximumrange_points[0].index, maximumrange_points[1].index]
boundpoints.sort()
- clicked_points += points
try:
vector_x = plot.curves[whatset].x[boundpoints[0]:boundpoints[1]]
vector_y = plot.curves[whatset].y[boundpoints[0]:boundpoints[1]]
y = min(vector_y)
index = vector_y.index(y)
- clicked_points += [self._clickize(vector_x, vector_y, index)]
+ maximum_point = [self._clickize(vector_x, vector_y, index)]
except ValueError:
self.AppendToOutput('Chosen interval not valid. Try picking it again. Did you pick the same point as begin and end of the interval?')
return
else:
- points = self._measure_N_points(N=1, message='Click on the point to measure.', whatset=whatset)
- y = points[0].graph_coords[1]
- clicked_points += [points[0]]
+ maximum_point = self._measure_N_points(N=1, message='Click on the point to measure.', whatset=whatset)
+ y = maximum_point[0].graph_coords[1]
boundaries = [self.basepoints[0].index, self.basepoints[1].index]
boundaries.sort()
avg = np.mean(to_average)
forcebase = abs(y - avg)
- if show_points:
- curve = plot.curves[whatset]
- for point in clicked_points:
- points = deepcopy(curve)
- points.x = point.graph_coords[0]
- points.y = point.graph_coords[1]
-
- points.color = color
- points.size = size
- points.style = 'scatter'
- plot.curves.append(points)
+ curve = plot.curves[whatset]
+ if self.basepoints and baseline_show:
+ #add the baseline points to the plot
+ baseline = lib.curve.Curve()
+ baseline.color = baseline_color
+ if baseline_show_in_legend:
+ baseline.label = 'baseline'
+ else:
+ baseline.label = '_nolegend_'
+ baseline.size = baseline_size
+ baseline.style = 'scatter'
+ baseline.units.x = curve.units.x
+ baseline.units.y = curve.units.y
+ for point in self.basepoints:
+ baseline.x += [point.graph_coords[0]]
+ baseline.y += [point.graph_coords[1]]
+ plot.curves.append(baseline)
+
+ if maximumrange_points and maximumrange_show:
+ #add the range points to the plot
+ maximumrange = lib.curve.Curve()
+ maximumrange.color = maximumrange_color
+ if maximumrange_show_in_legend:
+ maximumrange.label = 'maximumrange'
+ else:
+ maximumrange.label = '_nolegend_'
+ maximumrange.size = maximumrange_size
+ maximumrange.style = 'scatter'
+ maximumrange.units.x = curve.units.x
+ maximumrange.units.y = curve.units.y
+ for point in maximumrange_points:
+ maximumrange.x += [point.graph_coords[0]]
+ maximumrange.y += [point.graph_coords[1]]
+ plot.curves.append(maximumrange)
+
+ if maximum_show:
+ #add the maximum to the plot
+ maximum = lib.curve.Curve()
+ maximum.color = maximum_color
+ if maximum_show_in_legend:
+ maximum.label = 'maximum'
+ else:
+ maximum.label = '_nolegend_'
+ maximum.size = maximum_size
+ maximum.style = 'scatter'
+ maximum.units.x = curve.units.x
+ maximum.units.y = curve.units.y
+ maximum.x = [maximum_point[0].graph_coords[0]]
+ maximum.y = [maximum_point[0].graph_coords[1]]
+ plot.curves.append(maximum)
self.UpdatePlot(plot)
- #TODO: pretty format
- self.AppendToOutput(str(forcebase * (10 ** 12)) + ' pN')
+
+ unit_str = plot.curves[whatset].units.y
+ output_str = lib.prettyformat.pretty_format(forcebase, unit_str, decimals, 10 ** multiplier)
+ self.AppendToOutput(''.join(['Force: ', output_str]))
def plotmanip_multiplier(self, plot, current, customvalue=False):
'''
Copyright 2008 by Marco Brucale, Massimo Sandal
'''
+ decimals = self.GetIntFromConfig('generalvclamp', 'slope', 'decimals')
fitspan = self.GetIntFromConfig('generalvclamp', 'slope', 'fitspan')
point_color = self.GetColorFromConfig('generalvclamp', 'slope', 'point_color')
point_show = self.GetBoolFromConfig('generalvclamp', 'slope', 'point_show')
+ point_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'slope', 'point_show_in_legend')
point_size = self.GetIntFromConfig('generalvclamp', 'slope', 'point_size')
slope_color = self.GetColorFromConfig('generalvclamp', 'slope', 'slope_color')
slope_linewidth = self.GetIntFromConfig('generalvclamp', 'slope', 'slope_linewidth')
slope_show = self.GetBoolFromConfig('generalvclamp', 'slope', 'slope_show')
- whatset_str = self.GetStringFromConfig('generalvclamp', 'forcebase', 'whatset')
+ slope_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'slope', 'slope_show_in_legend')
+ whatset_str = self.GetStringFromConfig('generalvclamp', 'slope', 'whatset')
whatset = 'retraction'
if whatset_str == 'extension':
whatset = lh.EXTENSION
#TODO: add an option 'mode' with options 'chunk' and 'point'
if fitspan == 0:
# Gets the Xs of two clicked points as indexes on the curve curve vector
- clickedpoints = []
+ clicked_points = []
points = self._measure_N_points(N=2, message='Click 2 points to select the chunk.', whatset=whatset)
- clickedpoints = [points[0].index, points[1].index]
- clickedpoints.sort()
+ clicked_points = [points[0].index, points[1].index]
+ clicked_points.sort()
else:
- clickedpoints = []
+ clicked_points = []
points = self._measure_N_points(N=1, message='Click on the leftmost point of the chunk (i.e.usually the peak).', whatset=whatset)
- clickedpoints = [points[0].index - fitspan, points[0].index]
+ clicked_points = [points[0].index - fitspan, points[0].index]
# Calls the function linefit_between
parameters = [0, 0, [], []]
try:
- parameters = self.linefit_between(clickedpoints[0], clickedpoints[1], whatset=whatset)
+ parameters = self.linefit_between(clicked_points[0], clicked_points[1], whatset=whatset)
except:
self.AppendToOutput('Cannot fit. Did you click the same point twice?')
return
- # Outputs the relevant slope parameter
- #TODO: pretty format with units
- self.AppendToOutput(''.join(['Slope: ', str(parameters[0])]))
-
- #TODO: add option to keep previous slope
plot = self.GetDisplayedPlotCorrected()
-
# Makes a vector with the fitted parameters and sends it to the GUI
xtoplot=parameters[2]
ytoplot=[]
clickvector_x.append(item.graph_coords[0])
clickvector_y.append(item.graph_coords[1])
+ if point_show:
+ #add the clicked point to the plot
+ point = lib.curve.Curve()
+ point.color = point_color
+ if point_show_in_legend:
+ point.label = 'clicked point'
+ else:
+ point.label = '_nolegend_'
+ point.size = point_size
+ point.style = 'scatter'
+ point.x = clickvector_x
+ point.y = clickvector_y
+ plot.curves.append(point)
+
if slope_show:
#add the slope to the plot
slope = lib.curve.Curve()
slope.color = slope_color
- slope.label = 'slope'
+ if slope_show_in_legend:
+ slope.label = 'slope'
+ else:
+ slope.label = '_nolegend_'
slope.linewidth = slope_linewidth
slope.style = 'plot'
+ slope.units.x = plot.curves[whatset].units.x
+ slope.units.y = plot.curves[whatset].units.y
slope.x = xtoplot
slope.y = ytoplot
plot.curves.append(slope)
- if point_show:
- #add the clicked points to the plot
- points = lib.curve.Curve()
- points.color = point_color
- points.label = 'points'
- points.size = point_size
- points.style = 'scatter'
- points.x = clickvector_x
- points.y = clickvector_y
- plot.curves.append(points)
-
self.UpdatePlot(plot)
- def linefit_between(self, index1, index2, whatset=1):
+ # Outputs the relevant slope parameter
+ unit_str = plot.curves[whatset].units.x + '/' + plot.curves[whatset].units.y
+ output_str = lib.prettyformat.pretty_format(parameters[0], unit_str, decimals, 1)
+ self.AppendToOutput(''.join(['Slope: ', output_str]))
+
+ def linefit_between(self, index1, index2, whatset=lh.RETRACTION):
'''
Creates two vectors (xtofit, ytofit) slicing out from the
curve return trace a portion delimited by the two indeces
[[folder]]\r
default = ""\r
type = folder\r
- value = R:\Programming\Python\Gui\data\Ecoil good data set 1 week35_surface251_16.5pNnm\r
+ value = C:\Hooke\r
\r
[[filemask]]\r
default = *.*\r
[[filename]]\r
default = untitled.hkp\r
type = filename\r
- value = R:\Programming\Python\Gui\untitled2.hkp\r
+ value = C:\Hooke\playlists\test.hkp\r
-\r
+[plot]\r
+ [[legend]]\r
+ default = False\r
+ type = boolean\r
+ value = True\r
+ \r
+ [[x_decimals]]\r
+ default = 2\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 1\r
+ \r
+ [[x_multiplier]]\r
+ default = n\r
+ elements = n, p\r
+ type = enum\r
+ value = n\r
+ \r
+ [[y_decimals]]\r
+ default = 2\r
+ maximum = 10\r
+ minimum = 0\r
+ type = integer\r
+ value = 1\r
+ \r
+ [[y_multiplier]]\r
+ default = n\r
+ elements = n, p\r
+ type = enum\r
+ value = n\r
+ \r
+ \r
'''
plot.py
-Plot commands for Hooke.
+Global settings for plots
Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)
This program is released under the GNU General Public License version 2.
'''
-class plotCommands(object):
- '''
- Plot commands to replot the original data with fits (if applicable)
- but without secondary plots (unless they are part of the original data)
- '''
+class plotCommands:
- def _plug_init(self):
- pass
-
- def do_replot(self):
- '''
- Replots the current force curve from scratch eliminating any secondary plots.
- '''
- self.UpdatePlot()
+ def do_plot(self):
+ self.UpdatePlot();
whatset = [lh.EXTENSION, lh.RETRACTION]
if select:
- points = self._measure_N_points(N=2, message='Please select a region by clicking on the start and the end point.', whatset=1)
+ points = self._measure_N_points(N=2, message='Please select a region by clicking on the start and the end point.', whatset=lh.RETRACTION)
boundaries = [points[0].index, points[1].index]
boundaries.sort()
else:
[show_results]\r
- [[fit_function]]\r
+ [[result_type]]\r
default = wlc\r
- elements = wlc, fjc, fjcPEG\r
+ elements = wlc, fjc, fjcPEG, multidistance\r
type = enum\r
value = wlc\r