Refine Refactor documentation » History » Version 17
Amber Herold, 09/13/2012 12:32 PM
1 | 11 | Amber Herold | h1. Refinement Web User Interface documentation |
---|---|---|---|
2 | 2 | Amber Herold | |
3 | 5 | Amber Herold | |
4 | h2. Class Diagram |
||
5 | |||
6 | The following class diagram shows the BasicForm class with it's extended classes as well as the FormParameter class and it's extended classes. |
||
7 | 1 | Amber Herold | It also shows associations among the classes. |
8 | 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. |
||
9 | Other forms, such as RunParameters and stack prep, just use the base FormParameters class that their parent, BasicForm, uses. |
||
10 | |||
11 | !refineClassDiagram.png! |
||
12 | 10 | Amber Herold | |
13 | h2. Sequence Diagram |
||
14 | |||
15 | 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. |
||
16 | |||
17 | !refine_sequence_diagram.png! |
||
18 | 6 | Amber Herold | |
19 | h2. Steps to add a new refinement method to the pipeline |
||
20 | |||
21 | 14 | Amber Herold | # Add an entry to selectRefinementType.php for the new method. |
22 | 16 | Amber Herold | ## Add a logo image to the myamiweb/processing/img file if it does not already exist. |
23 | 14 | Amber Herold | ## In myamiweb/processing, open selectRefinementType.php and copy and existing methods code block. |
24 | ## Replace the logo image file with the appropriate file name |
||
25 | ## 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> |
||
26 | 15 | Amber Herold | ## Edit the description of the method to be informative to a novice user. |
27 | 17 | Amber Herold | # Create a python class to run the preprefine step. 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. |
28 | 6 | Amber Herold | # Create a new class which extends BasicRefineForm |
29 | # Create a new class which extends RefineFormParameters. This is optional, but recommended. |
||
30 | # Decide what information you need to collect from the user and add a form parameter for each item. |
||
31 | ## example: adding parameters to a new parameter class |
||
32 | ### 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. |
||
33 | ### use the addParam(name, value, label) method to add parameters specific to your refine method to your form. |
||
34 | ### 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. |
||
35 | <pre> |
||
36 | class XmippParams extends RefineFormParameters |
||
37 | { |
||
38 | function __construct( $id='', $label='', $outerMaskRadius='', $innerMaskRadius='', $outerAlignRadius='', |
||
39 | $innerAlignRadius='', $symmetry='', $numIters='', $angSampRate='', $percentDiscard='', |
||
40 | $filterEstimated='', $filterResolution='', $filterComputed='', $filterConstant='', |
||
41 | $mask='', $maxAngularChange='', $maxChangeOffset='', $search5DShift='', $search5DStep='', |
||
42 | $reconMethod='', $ARTLambda='', $doComputeResolution='', $fourierMaxFrequencyOfInterest='' ) |
||
43 | { |
||
44 | parent::__construct($id, $label, $outerMaskRadius, $innerMaskRadius, $outerAlignRadius, |
||
45 | $innerAlignRadius, $symmetry, $numIters, $angSampRate, $percentDiscard, |
||
46 | $filterEstimated, $filterResolution, $filterComputed, $filterConstant ); |
||
47 | |||
48 | $this->addParam( "mask", $mask, "Mask filename" ); |
||
49 | $this->addParam( "maxAngularChange", $maxAngularChange, "Max. Angular change " ); |
||
50 | $this->addParam( "maxChangeOffset", $maxChangeOffset, "Maximum change offset " ); |
||
51 | $this->addParam( "search5DShift", $search5DShift, "Search range for 5D translational search " ); |
||
52 | $this->addParam( "search5DStep", $search5DStep, "Step size for 5D translational search " ); |
||
53 | $this->addParam( "reconMethod", $reconMethod, "Reconstruction method " ); |
||
54 | $this->addParam( "ARTLambda", $ARTLambda, "Values of lambda for ART " ); |
||
55 | $this->addParam( "doComputeResolution", $doComputeResolution, "Compute resolution? " ); |
||
56 | $this->addParam( "fourierMaxFrequencyOfInterest", $fourierMaxFrequencyOfInterest, "Initial maximum frequency used by reconstruct fourier " ); |
||
57 | |||
58 | // disable any general params that do not apply to this method |
||
59 | $this->hideParam("innerMaskRadius"); |
||
60 | } |
||
61 | |||
62 | function validate() |
||
63 | { |
||
64 | $msg = parent::validate(); |
||
65 | |||
66 | if ( !empty($this->params["mask"]["value"]) && !empty($this->params["outerMaskRadius"]["value"]) ) |
||
67 | $msg .= "<b>Error:</b> You may not define both the outer mask raduis and a mask file."; |
||
68 | |||
69 | return $msg; |
||
70 | } |
||
71 | } |
||
72 | </pre> |
||
73 | 7 | Amber Herold | ## example: adding parameters to the form constructor method |
74 | # define any restrictions that should be applied to the parameters. |
||
75 | 9 | Amber Herold | # Override the advancedParamForm() function to add a user input field for each one. |
76 | # Override the buildCommand() function. There is a default implementation available which adds all form parameters as --<name>=<value>. |
||
77 | 12 | Amber Herold | # create your new form type in selectPreparedRecon.php |
78 | <pre> |
||
79 | // based on the type of refinement the user has selected, |
||
80 | // create the proper form type here. If a new type is added to |
||
81 | // Appion, it's form class should be included in this file |
||
82 | // and it should be added to this function. No other modifications |
||
83 | // to this file should be necessary. |
||
84 | function createSelectedRefineForm( $method, $stacks='', $models='' ) |
||
85 | { |
||
86 | switch ( $method ) { |
||
87 | case emanrecon: |
||
88 | $selectedRefineForm = new EmanRefineForm( $method, $stacks, $models ); |
||
89 | break; |
||
90 | case frealignrecon: |
||
91 | $selectedRefineForm = new FrealignRefineForm( $method, $stacks, $models ); |
||
92 | break; |
||
93 | case xmipprecon: |
||
94 | $selectedRefineForm = new XmippRefineForm( $method, $stacks, $models ); |
||
95 | break; |
||
96 | case xmippml3drecon: |
||
97 | $selectedRefineForm = new XmippML3DRefineForm( $method, $stacks, $models ); |
||
98 | break; |
||
99 | default: |
||
100 | Throw new Exception("Error: Not Implemented - There is no RefineForm class avaialable for method: $method"); |
||
101 | } |
||
102 | |||
103 | return $selectedRefineForm; |
||
104 | } |
||
105 | 13 | Amber Herold | </pre> |