-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforms.py
More file actions
117 lines (95 loc) · 6.16 KB
/
forms.py
File metadata and controls
117 lines (95 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired
from wtforms import StringField, SubmitField, SelectField, IntegerField
from wtforms.validators import Length, NumberRange, Optional
LENGTH_MESSAGE = 'Length must be between %(min)d and %(max)d.'
class CreateCategoricalSessionForm(FlaskForm):
session_name = StringField('Session Name',
validators=[Length(3, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'My Session'})
prompt = StringField('Label Prompt',
validators=[Length(0, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'What is the level of artifacting in this image?'})
label_values = StringField('Label Options',
validators=[Length(1, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'None, Mild, Moderate, Severe'})
submit_button = SubmitField('Create')
class CreateCategoricalSliceSessionForm(FlaskForm):
session_name = StringField('Session Name',
validators=[Length(3, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'My Session'})
prompt = StringField('Label Prompt',
validators=[Length(0, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'What is the level of artifacting in this slice?'})
label_values = StringField('Label Options',
validators=[Length(1, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'None, Mild, Moderate, Severe'})
comparisons = SelectField('Use Slices From', choices=[])
submit_button = SubmitField('Create')
class ComparisonNumberRange(NumberRange):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __call__(self, form, field):
# Only validate comparison fields if new comparisons are being generated
if form.comparisons.data == 'create':
super().__call__(form, field)
class CreateComparisonSessionForm(FlaskForm):
session_name = StringField('Session Name',
validators=[Length(3, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'My Session'})
prompt = StringField('Label Prompt',
validators=[Length(0, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'Which slice has more severe artifacts?'})
label_values = StringField('Additional Label Options',
validators=[Length(0, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'No Difference, Not Sure',
'value': 'No Difference, Not Sure'})
comparisons = SelectField('Comparisons', choices=[('create', 'Create New')])
slice_type = SelectField('Orientation', choices=[('SAGITTAL', 'Sagittal'),
('CORONAL', 'Coronal'),
('AXIAL', 'Axial')])
image_count = IntegerField('Number of Images')
slice_count = IntegerField('Total Number of Slices', validators=[ComparisonNumberRange(min=2)],
render_kw={'placeholder': 1000,
'value': 1000})
comparison_count = IntegerField('Number of Comparisons', validators=[Optional(), ComparisonNumberRange(min=1)],
render_kw={'placeholder': 2000,
'value': 2000})
max_comparisons_per_slice = IntegerField('Max Comparisons per Slice',
validators=[Optional(), ComparisonNumberRange(min=1)],
render_kw={'placeholder': 5})
min_slice_percent = IntegerField('Min Slice (%)', validators=[ComparisonNumberRange(min=0, max=99)],
render_kw={'placeholder': 0,
'value': 10})
max_slice_percent = IntegerField('Max Slice (%)', validators=[ComparisonNumberRange(min=1, max=100)],
render_kw={'placeholder': 100,
'value': 90})
submit_button = SubmitField('Create')
class CreateSortSessionForm(FlaskForm):
session_name = StringField('Session Name',
validators=[Length(3, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'My Session'})
prompt = StringField('Label Prompt',
validators=[Length(0, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'Which slice has more severe artifacts?'})
slices_from = SelectField('Use Slices From', choices=[('create', 'Create New')])
slice_type = SelectField('Orientation', choices=[('SAGITTAL', 'Sagittal'),
('CORONAL', 'Coronal'),
('AXIAL', 'Axial')])
image_count = IntegerField('Number of Images')
slice_count = IntegerField('Total Number of Slices', validators=[NumberRange(min=2)],
render_kw={'placeholder': 1000,
'value': 1000})
min_slice_percent = IntegerField('Min Slice (%)', validators=[NumberRange(min=0, max=99)],
render_kw={'placeholder': 0,
'value': 10})
max_slice_percent = IntegerField('Max Slice (%)', validators=[NumberRange(min=1, max=100)],
render_kw={'placeholder': 100,
'value': 90})
submit_button = SubmitField('Create')
class ImportSessionForm(FlaskForm):
session_name = StringField('Session Name',
validators=[Length(3, 100, LENGTH_MESSAGE)],
render_kw={'placeholder': 'My Session'})
session_file = FileField('Session File', validators=[FileRequired()])
submit_button = SubmitField('Import')