Merged my unitary FFT wrappers (FFT_tools) as hooke.util.fft.
[hooke.git] / doc / tutorial.txt
1 ********
2 Tutorial
3 ********
4
5 `A short video showing Hooke in action`_! (courtesy of Fabrizio
6 Benedetti, EPFL, Lausanne)
7
8 .. _A short video showing Hooke in action:
9   https://documents.epfl.ch/users/f/fb/fbenedet/www/hooke_short_demostration.ogv
10
11 .. toctree::
12    :maxdepth: 2
13
14    gui
15
16 Introduction
17 ============
18
19 This tutorial will focus on the command-line interface as the most
20 powerful, and leave the :doc:`gui` interface to another document.
21
22 .. _command-line: `Command-line interface`_
23
24 Installation
25 ============
26
27 See :doc:`install` for details on downloading and installing Hooke.
28
29
30 Command-line interface
31 ======================
32
33 Running the hooke shell
34 -----------------------
35
36 Hooke has a set of commands that depend on the loaded
37 :class:`hooke.plugin.Plugin`\s.  To access these commands, you'll need
38 to run the Hooke shell.::
39
40     $ hooke
41
42 If you are running hooke from the source directory (see
43 :doc:`install`), the equivalent command is::
44
45     $ python bin/hooke
46
47 You may need to give the full path for Python on Windows systems.
48
49 As Hooke launches, you should see something like the following in your
50 terminal::
51
52     Hooke version 0.8.0 Seinei
53
54     COPYRIGHT
55     ----
56     hooke>
57
58 The final line, ``hooke>``, is the Hooke prompt.  It allows you to
59 enter commands to interact with the interpreter.
60
61 Help
62 ----
63
64 All commands have help text explaining their purpose and usage.  The
65 text is stored in the code itself, and therefore more likely to be up
66 to date than this tutorial.  You can get a list of commands and topics
67 with::
68
69     hooke> help
70
71 Or see specific help on ``TOPIC`` with::
72
73     hooke> help TOPIC
74
75 for example::
76
77     hooke> help current
78
79 will give help on the ``current`` command.
80
81 Creating a playlist
82 -------------------
83
84 To start analyzing your curves, you first have to build a playlist. The
85 playlist is just an index of the force curve files you want to
86 analyze. Imagine it as a music playlist (that’s why it is called a
87 playlist), but with data files instead of audio files.
88
89 Suppose you have 100 PicoForce curve files in your curves directory,
90 starting from :file:`mycurve.000` and ending in :file:`mycurve.100`
91 and you want to analyze them all.
92
93 You then can ``cd`` (change directory) to the directory::
94
95     hooke> cd c:\curves
96
97 Type ``pwd`` (print working directory) to check the directory is correct.::
98
99     hooke> pwd
100     c:\curves
101
102 You can list the files in the directory using ``ls`` or ``dir``
103 (they’re synonyms).::
104
105     hooke> ls
106     [’mycurve.000’, ’mycurve.001’, ...
107     ]
108
109 Now you are ready to generate the playlist. The command to use is
110 ``genlist``.::
111
112     hooke> genlist mycurve.*
113
114 You can also generate a playlist containing all what you find in the
115 directory by typing:
116
117     hooke> genlist c:\curves
118
119 If you want to select what curves to see, based on the filename, you
120 can use wildcards.  For example::
121
122     hooke> genlist mycurve.05*
123
124 will take only curves from :file:`mycurve.050` to :file:`mycurve.059`.
125
126 Note that by using ``genlist`` you just generate the playlist in the
127 local session. To save your playlist to a file for future reuse,
128 type::
129
130     hooke> savelist mylist
131
132 In this example, the list will be saved in the file
133 :file:`mylist.hkp`.  Hooke will add the extension ``.hkp`` (Hooke
134 playlist) to the playlist if you forget to.  The ``.hkp`` file is an
135 XML file you can read and edit with any text editor (i.e. Wordpad), if
136 needed.  If you want to load it, simply issue ``loadlist mylist.hkp``
137 or ``loadlist mylist``, Hooke will add ``.hkp`` if necessary.
138
139 If, generating the playlist, you are including by chance a non-force
140 curve file that Hooke cannot open, Hooke will print an error and
141 continue on.
142
143 Navigating the playlist
144 -----------------------
145
146 Now you can navigate through your playlist using the commands `next`
147 and `previous` or, their aliases `n` and `p`. You don’t need to
148 type `n` every time to run along a list of curves.  If you press
149 Return to an empty prompt, Hooke will repeat the last command you
150 issued explicitly.  You can also navigate through the command history
151 by using the up and down arrows.  From the last curve of your
152 playlist, `n` will wrap around to the first curve.  Analogously,
153 issuing `p` at the first curve will jump to the last.
154
155 You can also jump to a given curve::
156
157     hooke> jump c:\curves\mycurve.012
158
159 where the path can be either an absolute path, or a path relative to
160 the directory holding the playlist file.
161
162 Taking notes
163 ------------
164
165 You can take notes about the curves you are looking at.  Just type
166 `note` followed by the text you want to append to that curve.  Hooke
167 will save the text in your current playlist and in an external log
168 file.  The output will look like this::
169
170     Notes taken at Sun Sep 17 20:42:07 2006
171     /home/cyclopia/work/tris/20060620a.041 |             This is a note
172     /home/cyclopia/work/tris/20060620a.207 |             This is another note
173     /home/cyclopia/work/tris/20060620a.286 |             This is a third one
174
175 The log file name can be configured (:doc:`config`), but it defaults
176 to :file:`hooke.log`.
177
178 Usually curves you annotated are useful later.  You can copy the curves
179 you annotated to a different directory by using the ``copylog``
180 command.
181
182     hooke> copylog c:\nicecurves
183
184 will copy all curves you have annotated to the :file:`c:\nicecurves`
185 directory.  Make sure that the directory already exists before doing
186 that.  TODO: replace with::
187
188     hooke> copylist --log c:\curves\nice.hkp
189
190 Exporting curves
191 ----------------
192
193 You can export Hooke curves as images and as text columns. To export
194 as images, issue the ``export`` command followed by the filename.
195 Supported formats are PNG (raster) and EPS (Encapsulated Postscript,
196 vector).  The export format is determined by the filename extension,
197 so ``export foo.png`` and ``export foo.eps`` will save PNG and EPS
198 files respectively.
199
200 To export as text, use the ``txt`` command, followed by the
201 filename. The output is a text file containing columns (first two are
202 X and Y of extension, second two are X and Y of retraction).
203
204 TODO: multiple cycles?  Solution: blank lines for "breaks", add option
205 to extract specific sections using Python's slice notation.
206
207
208 Interacting with the plot
209 -------------------------
210
211 (no plots in command line mode...)
212
213 Measuring distances and forces
214 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215
216 You can easily zoom in the plot by dragging a rectangle on it with the
217 left mouse button.  To zoom out, click the right mouse
218 button. Sometimes by zooming in and out too much, you can lose the
219 picture (this is probably a small bug in Matplotlib).  Just type
220 ``plot`` at the command line and the curve will be refreshed.
221
222 You can measure distances and forces directly in the plot. Just issue
223 the command ``distance``.  You will be asked to click two points.
224 When you click a point, a blue dot should appear.  When you click the
225 second point, the distances (in nanometers and piconewtons) will
226 appear on the command line.  You can use ``delta`` if you prefer,
227 which gives meaningful values for every kind of graph (not only force
228 curves). If you want to know the coordinates of a single point, use
229 ``point``.
230
231 Hooke automatically adjusts the position of the clicked point to the
232 nearest point in the graph, so you will be always measuring distances
233 and forces between points in the graph.
234
235 The commands ``force`` and ``distance`` are present in the
236 ``generalvclamp`` plugin.
237
238 Worm like chain and freely jointed chain fitting
239 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240
241 You can measure by hand the parameters relative to a force peak using
242 a worm-like chain fitting with the ``fit`` command.  The command by
243 default automatically finds the contact point, asks for two points
244 delimiting the portion to fit, and performs a two-variable fit, with
245 contour length, persistence length, and their relative errors as
246 output.  If desired, one can use the ``noauto`` option to manually
247 click the contact point, and/or the ``pl=NUMBER`` options to impose a
248 specific persistence or Kuhn length (in nanometers). You can choose
249 which model to use with ``set fit_function wlc`` or ``set fit_function
250 fjc``.  See the help of the ``fit`` command from the Hooke command
251 line for details.
252
253 Multiple curve fitting and measuring
254 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
255
256 You can cycle through all your current playlist obtaining WLC fit, FJC
257 fit, rupture force and slope (loading rate) information from each
258 curve using the ``multifit`` command.  The collected data can be saved
259 in a text file for further analysis in your favourite spreadsheet or
260 statistical program.  If you want to check your parameters on the
261 current curve before fitting all the files in your playlist, use
262 ``multifit justone``.  See the ``multifit`` help for more options.
263
264 Fast curve reviewing and saving
265 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266
267 When automatic routines are not good enough to filter your data, use
268 ``review`` command to cycle through your playlist presenting ten
269 curves in the same graph.  You can then enter the numbers of the
270 interesting curves and automatically save a copy of them into another
271 directory.
272
273 Configuring Hooke
274 -----------------
275
276 You can set environment variables to influence the behaviour of
277 Hooke. The command to use is ``set``.
278
279 You can alter permanently the behaviour of Hooke by setting these
280 variables in a Hooke configuration file.  See :doc:`config` for
281 details.