/
_schemas.py
72 lines (66 loc) · 2.24 KB
/
_schemas.py
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
import marshmallow as mm
from argschema.schemas import ArgSchema, DefaultSchema
from argschema.fields import (
InputFile, List, Float, Int, Nested
)
from neuron_morphology.transforms.affine_transformer._schemas import (
AffineDictSchema
)
def validate_neighbors(num):
if num<4 or (num % 2) != 0:
err_msg = ("The number of neighbors for interpolation must be an even and greater than 4")
raise mm.ValidationError(err_msg)
class InputParameters(ArgSchema):
gradient_path = InputFile(
description=(
"File at this location is a netcdf-formatted 2D gradient field."
"Dimensions are x, y, dim, where dim defines the component (dx "
"or dy) of the gradient"
),
required=True
)
node = List(Float,
description='[x,y,z] location in gradient field to get angle',
cli_as_single_argument=True,
default=[0, 0, 0],
required=False,
)
step = Int(
description=(
"The input gradient field will be decimated isometrically by "
"this factor"
),
default=1,
required=False,
)
neighbors = Int(
description=('number of x and y neighbor idxs to use for interpolation, '
'must even and greater > 4'
),
required=False,
default=12,
# min data points must be >= (k+1)**2, k=1 for linear
)
swc_path = InputFile(
description='path to swc file for soma location',
required=True
)
@mm.validates_schema
def validate_schema_input(self, data, **kwargs):
validate_neighbors(data.get('neighbors'))
class OutputParameters(DefaultSchema):
inputs = Nested(
InputParameters,
description="The parameters argued to this executable",
required=True
)
upright_angle = Float(
description=(
"Angle of rotation about the soma required to upright the input "
"morphology. In radians counterclockwise from horizontal axis"
),
required=True
)
upright_transform_dict = Nested(AffineDictSchema,
required=False,
description='Dictionary defining an affine transform')