Project

General

Profile

Refine Refactor documentation » History » Version 14

Amber Herold, 09/13/2012 11:52 AM

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
## Add a logo image to the myamiweb/img file if it does not already exist.
23
## 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 6 Amber Herold
# Create a new class which extends BasicRefineForm
27
# Create a new class which extends RefineFormParameters. This is optional, but recommended.
28
# Decide what information you need to collect from the user and add a form parameter for each item.
29
## example: adding parameters to a new parameter class
30
### 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.
31
### use the addParam(name, value, label) method to add parameters specific to your refine method to your form.
32
### 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.
33
<pre>
34
class XmippParams extends RefineFormParameters
35
{
36
	function __construct( $id='', $label='', $outerMaskRadius='', $innerMaskRadius='', $outerAlignRadius='', 
37
							$innerAlignRadius='', $symmetry='', $numIters='', $angSampRate='', $percentDiscard='',  
38
							$filterEstimated='', $filterResolution='', $filterComputed='', $filterConstant='',
39
							$mask='', $maxAngularChange='', $maxChangeOffset='', $search5DShift='', $search5DStep='',
40
							$reconMethod='', $ARTLambda='', $doComputeResolution='', $fourierMaxFrequencyOfInterest='' ) 
41
	{
42
		parent::__construct($id, $label, $outerMaskRadius, $innerMaskRadius, $outerAlignRadius, 
43
							$innerAlignRadius, $symmetry, $numIters, $angSampRate, $percentDiscard,  
44
							$filterEstimated, $filterResolution, $filterComputed, $filterConstant );
45
									
46
		$this->addParam( "mask", $mask, "Mask filename" );
47
		$this->addParam( "maxAngularChange", $maxAngularChange, "Max. Angular change " );		
48
		$this->addParam( "maxChangeOffset", $maxChangeOffset, "Maximum change offset " );
49
		$this->addParam( "search5DShift", $search5DShift, "Search range for 5D translational search " );
50
		$this->addParam( "search5DStep", $search5DStep, "Step size for 5D translational search " );
51
		$this->addParam( "reconMethod", $reconMethod, "Reconstruction method " );
52
		$this->addParam( "ARTLambda", $ARTLambda, "Values of lambda for ART " );
53
		$this->addParam( "doComputeResolution", $doComputeResolution, "Compute resolution? " );
54
		$this->addParam( "fourierMaxFrequencyOfInterest", $fourierMaxFrequencyOfInterest, "Initial maximum frequency used by reconstruct fourier " );
55
		
56
		// disable any general params that do not apply to this method
57
		$this->hideParam("innerMaskRadius");		
58
	}
59
	
60
	function validate() 
61
	{
62
		$msg = parent::validate();
63
64
		if ( !empty($this->params["mask"]["value"]) && !empty($this->params["outerMaskRadius"]["value"]) )
65
			$msg .= "<b>Error:</b> You may not define both the outer mask raduis and a mask file.";
66
				
67
		return $msg;
68
	}
69
}
70
</pre>
71 7 Amber Herold
## example: adding parameters to the form constructor method
72
# define any restrictions that should be applied to the parameters.
73 9 Amber Herold
# Override the advancedParamForm() function to add a user input field for each one.
74
# Override the buildCommand() function. There is a default implementation available which adds all form parameters as --<name>=<value>.
75 12 Amber Herold
# create your new form type in selectPreparedRecon.php
76
<pre>
77
// based on the type of refinement the user has selected,
78
// create the proper form type here. If a new type is added to
79
// Appion, it's form class should be included in this file
80
// and it should be added to this function. No other modifications
81
// to this file should be necessary.
82
function createSelectedRefineForm( $method, $stacks='', $models='' )
83
{
84
	switch ( $method ) {
85
		case emanrecon:
86
			$selectedRefineForm = new EmanRefineForm( $method, $stacks, $models );
87
			break;
88
		case frealignrecon:
89
			$selectedRefineForm = new FrealignRefineForm( $method, $stacks, $models );
90
			break;
91
		case xmipprecon:
92
			$selectedRefineForm = new XmippRefineForm( $method, $stacks, $models );
93
			break;
94
		case xmippml3drecon:
95
			$selectedRefineForm = new XmippML3DRefineForm( $method, $stacks, $models );
96
			break;
97
		default:
98
			Throw new Exception("Error: Not Implemented - There is no RefineForm class avaialable for method: $method"); 
99
	}		
100
	
101
	return $selectedRefineForm;
102
}
103 13 Amber Herold
</pre>