Refine Refactor documentation » History » Version 21
Amber Herold, 09/13/2012 01:31 PM
1 | 11 | Amber Herold | h1. Refinement Web User Interface documentation |
---|---|---|---|
2 | 2 | Amber Herold | |
3 | 6 | Amber Herold | h2. Steps to add a new refinement method to the pipeline |
4 | |||
5 | 14 | Amber Herold | # Add an entry to selectRefinementType.php for the new method. |
6 | 16 | Amber Herold | ## Add a logo image to the myamiweb/processing/img file if it does not already exist. |
7 | 14 | Amber Herold | ## In myamiweb/processing, open selectRefinementType.php and copy and existing methods code block. |
8 | ## Replace the logo image file with the appropriate file name |
||
9 | ## Replace the method key with an appropriate short name that indicates the type of method you are adding. This key will be used in other files to identify the type of refinement to launch. For example, in the following line of code *method=eman* should be replaced with an appropriate method name.<pre><h3><a href='selectStackForm.php?expId=$expId&method=eman'>EMAN1 projection-matching refinement</a></h3></pre> |
||
10 | 15 | Amber Herold | ## Edit the description of the method to be informative to a novice user. |
11 | 19 | Amber Herold | |
12 | 18 | Amber Herold | # Add a reference paper related to the method. |
13 | ## Open myamiweb/processing/inc/publicationList.inc and copy a $PUBLICATIONS array entry code block. |
||
14 | ## Modify the fields for the publication that should be referenced for the method you are adding. |
||
15 | ## Modify the $PUBLICATIONS array key to match the method key that you defined in selectRefinementType.php. |
||
16 | 19 | Amber Herold | |
17 | 20 | Amber Herold | # Create a python class to run the preprefine step. |
18 | ## You must name the file prepRefineMethod.py where _Method_ is the same method key that you used in the previous step, except the first leter of the method is capitalized. This file should be located in myami/appion/bin and can be created by copying a similar existing methods prepRefine file. |
||
19 | 19 | Amber Herold | |
20 | 6 | Amber Herold | # Create a new class which extends BasicRefineForm |
21 | # Create a new class which extends RefineFormParameters. This is optional, but recommended. |
||
22 | # Decide what information you need to collect from the user and add a form parameter for each item. |
||
23 | ## example: adding parameters to a new parameter class |
||
24 | ### note that the parent constuctor is called first, passing any default values along. The RefineFormParameters base class defines parameters that are common to most refinement methods. You only need to add parameters that are not already defined in the base class. |
||
25 | ### use the addParam(name, value, label) method to add parameters specific to your refine method to your form. |
||
26 | ### if you find that the base class includes a parameter that your method does not need, you can remove the parameter from the form with the hideParam(name) method. |
||
27 | <pre> |
||
28 | class XmippParams extends RefineFormParameters |
||
29 | { |
||
30 | function __construct( $id='', $label='', $outerMaskRadius='', $innerMaskRadius='', $outerAlignRadius='', |
||
31 | $innerAlignRadius='', $symmetry='', $numIters='', $angSampRate='', $percentDiscard='', |
||
32 | $filterEstimated='', $filterResolution='', $filterComputed='', $filterConstant='', |
||
33 | $mask='', $maxAngularChange='', $maxChangeOffset='', $search5DShift='', $search5DStep='', |
||
34 | $reconMethod='', $ARTLambda='', $doComputeResolution='', $fourierMaxFrequencyOfInterest='' ) |
||
35 | { |
||
36 | parent::__construct($id, $label, $outerMaskRadius, $innerMaskRadius, $outerAlignRadius, |
||
37 | $innerAlignRadius, $symmetry, $numIters, $angSampRate, $percentDiscard, |
||
38 | $filterEstimated, $filterResolution, $filterComputed, $filterConstant ); |
||
39 | |||
40 | $this->addParam( "mask", $mask, "Mask filename" ); |
||
41 | $this->addParam( "maxAngularChange", $maxAngularChange, "Max. Angular change " ); |
||
42 | $this->addParam( "maxChangeOffset", $maxChangeOffset, "Maximum change offset " ); |
||
43 | $this->addParam( "search5DShift", $search5DShift, "Search range for 5D translational search " ); |
||
44 | $this->addParam( "search5DStep", $search5DStep, "Step size for 5D translational search " ); |
||
45 | $this->addParam( "reconMethod", $reconMethod, "Reconstruction method " ); |
||
46 | $this->addParam( "ARTLambda", $ARTLambda, "Values of lambda for ART " ); |
||
47 | $this->addParam( "doComputeResolution", $doComputeResolution, "Compute resolution? " ); |
||
48 | $this->addParam( "fourierMaxFrequencyOfInterest", $fourierMaxFrequencyOfInterest, "Initial maximum frequency used by reconstruct fourier " ); |
||
49 | |||
50 | // disable any general params that do not apply to this method |
||
51 | $this->hideParam("innerMaskRadius"); |
||
52 | } |
||
53 | |||
54 | function validate() |
||
55 | { |
||
56 | $msg = parent::validate(); |
||
57 | |||
58 | if ( !empty($this->params["mask"]["value"]) && !empty($this->params["outerMaskRadius"]["value"]) ) |
||
59 | $msg .= "<b>Error:</b> You may not define both the outer mask raduis and a mask file."; |
||
60 | |||
61 | return $msg; |
||
62 | } |
||
63 | } |
||
64 | </pre> |
||
65 | 7 | Amber Herold | ## example: adding parameters to the form constructor method |
66 | # define any restrictions that should be applied to the parameters. |
||
67 | 9 | Amber Herold | # Override the advancedParamForm() function to add a user input field for each one. |
68 | # Override the buildCommand() function. There is a default implementation available which adds all form parameters as --<name>=<value>. |
||
69 | 12 | Amber Herold | # create your new form type in selectPreparedRecon.php |
70 | <pre> |
||
71 | // based on the type of refinement the user has selected, |
||
72 | // create the proper form type here. If a new type is added to |
||
73 | // Appion, it's form class should be included in this file |
||
74 | // and it should be added to this function. No other modifications |
||
75 | // to this file should be necessary. |
||
76 | function createSelectedRefineForm( $method, $stacks='', $models='' ) |
||
77 | { |
||
78 | switch ( $method ) { |
||
79 | case emanrecon: |
||
80 | $selectedRefineForm = new EmanRefineForm( $method, $stacks, $models ); |
||
81 | break; |
||
82 | 1 | Amber Herold | case frealignrecon: |
83 | $selectedRefineForm = new FrealignRefineForm( $method, $stacks, $models ); |
||
84 | break; |
||
85 | case xmipprecon: |
||
86 | $selectedRefineForm = new XmippRefineForm( $method, $stacks, $models ); |
||
87 | break; |
||
88 | case xmippml3drecon: |
||
89 | $selectedRefineForm = new XmippML3DRefineForm( $method, $stacks, $models ); |
||
90 | break; |
||
91 | default: |
||
92 | Throw new Exception("Error: Not Implemented - There is no RefineForm class avaialable for method: $method"); |
||
93 | } |
||
94 | |||
95 | return $selectedRefineForm; |
||
96 | } |
||
97 | 12 | Amber Herold | </pre> |
98 | 21 | Amber Herold | |
99 | h2. Class Diagram |
||
100 | |||
101 | The following class diagram shows the BasicForm class with it's extended classes as well as the FormParameter class and it's extended classes. |
||
102 | It also shows associations among the classes. |
||
103 | Notice that the specific refine parameter classes use polymorphism to override the validate() function. This allows the extended classes to provide more complex validations than a typical form requires. |
||
104 | Other forms, such as RunParameters and stack prep, just use the base FormParameters class that their parent, BasicForm, uses. |
||
105 | |||
106 | !refineClassDiagram.png! |
||
107 | |||
108 | h2. Sequence Diagram |
||
109 | |||
110 | The following sequence diagram shows how the Form and Parameter classes work together to display a form, validate the user input, and create a command string. |
||
111 | |||
112 | !refine_sequence_diagram.png! |