|
ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Testing > Procedures > Writing a procedure using the procedure editor Writing a procedure using the procedure editor
IntroductionThe ANY-maze procedure editor is used to write or edit a procedure. The editor appears to the right of the procedure settings pane when a new procedure is created, or an existing procedure is selected for editing. The left-hand side of the procedure editor contains various lists of items that can be used in the procedure. These items are the building blocks of a procedure, and you just need to drag them into the right-hand side of the editor to form the procedure.
Figure 1. The ANY-maze procedure editor.
Writing a simple procedureRather than describe all the different aspects of a procedure, let's start by creating a very simple example. The concepts in this example will be useful for creating your own procedures, and hopefully it'll very quickly demonstrate both the power and simplicity of procedures. For this example, let's say we have set up a water-maze experiment. There's a zone called 'Island', and we want to end the test when the animal enters the Island zone.
If you want to work through this example yourself, you can do so using the example experiment 'Water-maze videoed experiment'. If you'd like to do this, open this example, switch to the Protocol page and select the
Note that the name of the procedure that you've just entered is important - we'll find out why later on in this worked example.
So what do we need our procedure to do? Well, the first thing to do is try and describe what you want to happen as a series of simple steps, i.e.
Let's create a procedure that does this. The first thing we need the procedure to do is to wait for something to happen. So, let's drag a Wait until block into the procedure:
Figure 2. Dragging a Wait until statement into the procedure
There are two things to note here:
So now the procedure is waiting for something, but we need to tell it what it's waiting for. Things that happen in a procedure are called Events, so let's select the Events tab:
Figure 3. The Events tab.
Here we can see a list of all the possible events that are available to procedures. This contains animal position and activity events, zone entries and exits, and any events related to I/O devices being used by the protocol. In this case, we don't have any I/O, but this example experiment does have a number of zones, including the 'Island' zone that we want, and the events for these zones are at the bottom of the list. The headings in the list of events can be expanded or collapsed, just by clicking on them, so we can easily collapse the events that we're not interested in:
Figure 4. Collapsing the events we're not interested in.
Now we need to use the mouse to drag the Animal enters Island zone event, and drop it over the purple 'hole' in the Wait until statement:
Figure 5. Dragging the event into the procedure.
Again, there are a couple of things to note here:
Now our procedure is waiting for the animal to enter the island zone, so next we need to tell it to end the test when that happens. Things that the procedure actually does that affect the test are called Actions, so we need to tell the procedure to take an action that will end the test. So we need to re-select the Statements tab, and this time, drag across an Action statement:
Figure 6. Dragging the Action statement into the procedure.
This is just the statement telling the procedure to execute an action, but we haven't yet told the procedure which action to execute. To do this, we need to switch to the Actions tab to see the available actions:
Figure 7. The Actions tab.
This tab will show you all the actions that a procedure can take to affect the test. This includes test control, actions to start/stop recording, and I/O outputs (if any have been set up in the protocol). Again, all the headings can be expanded to show you everything that's available. Full details of all these actions can be found under Actions available to procedures, but for now we can find the one we're interested in at the top of the list: End the test. Again, note the shape of the actions - they're the same shape as the 'hole' in the statement we've just dragged into the procedure. So we can drag the End the test action into the procedure:
Figure 8. Dragging the action into the procedure.
An important point to note here is that every time a test ends, ANY-maze notes the reason for the test end. A test might end for one of a number of reasons - usually because the test duration elapsed, but it might also be because the user aborted the test, or (as in this case) because of a procedure action. These test end reasons can be used during analysis, for example, to include or exclude results from tests that ended for particular reasons. In this case, the test has ended because the animal found the island. When you use the End the test action, ANY-maze uses the name of the procedure as the test end reason. So you can see why, as I mentioned earlier, the name that you give the procedure is important!
Our procedure should now look like this:
Figure 9. The completed procedure.
As with the event that we dragged earlier, you'll see that the action has a little drop-down arrow at its right-hand side. Again, this can be used to quickly and easily change the action that the Action statement will use. In fact, you might have noticed earlier that this arrow appeared even before we added the action to the Action statement (and the Wait until statement had one as well, before we dragged the event into it). We could just have used these arrows to select the event / action that we wanted, rather than dragging them across from the left-hand side. There's just one last thing to do before we've finished. Procedures can get quite complex, and if there are any errors in a procedure, it won't run (you'll be told about this before you try to run any tests, and you'll need to fix any errors before starting any tests). You can check that your procedure is valid at any stage, by clicking the
Figure 10. The bar at the bottom of the procedure editor, showing that there are no errors or warnings.
If you forget to check the procedure like this, don't worry - the procedure will be automatically checked for errors when you move to a different page, or select another item in the protocol list. If there are any errors that will prevent the procedure from running, you'll be told about it and given the chance to correct them. SummaryTo create a procedure:
What next?An example that introduces some more procedure concepts can be found in the topic Writing a more complex procedure. For even more advanced concepts, such as using multiple procedures and working with I/O, see A worked example using I/O. It's probably a good idea to work through this example even if you don't have any I/O connected, as it introduces some more useful features of procedures. If you require any assistance with writing your own procedures, please contact ANY-maze Support and we'll be happy to help. See also:
© Copyright 2003-2026 Stoelting Co. All rights reserved ANY-maze help topic T0461 |