@@ -76,6 +76,10 @@ class TransformImportForm(forms.Form):
7676 queryset = Stack .objects .all ())
7777 x_factor = forms .FloatField (initial = 1.0 , required = False , help_text = "A factor that is multiplied to each X shift" )
7878 y_factor = forms .FloatField (initial = 1.0 , required = False , help_text = "A factor that is multiplied to each Y shift" )
79+ z_factor = forms .FloatField (initial = 1.0 , required = False , help_text = "A factor that is multiplied to each Z shift" )
80+ x_offset = forms .FloatField (initial = 0.0 , required = False , help_text = "A offset that is added to each X shift" )
81+ y_offset = forms .FloatField (initial = 0.0 , required = False , help_text = "A offset that is added to each Y shift" )
82+ z_offset = forms .FloatField (initial = 0.0 , required = False , help_text = "A offset that is added to each Z shift" )
7983 delimiter = forms .CharField (initial = ',' , required = False , help_text = "The delimiter used in the transform CSV" )
8084 transform_type = forms .ChoiceField (choices = TRANSFORM_TYPE_CHOICES , required = True , help_text = "The type of tranformaton" )
8185 transform_text = forms .CharField (widget = forms .Textarea , label = 'Transform' ,
@@ -323,6 +327,10 @@ def done(self, form_list, **kwargs) -> HttpResponse:
323327 reference_stack = transform_data ['reference_stack' ]
324328 x_factor = transform_data ['x_factor' ]
325329 y_factor = transform_data ['y_factor' ]
330+ z_factor = transform_data ['z_factor' ]
331+ x_offset = transform_data ['x_offset' ]
332+ y_offset = transform_data ['y_offset' ]
333+ z_offset = transform_data ['z_offset' ]
326334 delimiter = transform_data ['delimiter' ]
327335 transform_data_type = transform_data ['transform_type' ]
328336 transform_text = transform_data ['transform_text' ].replace ('\r \n ' , '\n ' ).replace ('\r ' , '\n ' )
@@ -332,8 +340,9 @@ def done(self, form_list, **kwargs) -> HttpResponse:
332340 if transform_data_type == 'csv-z-slices' :
333341 with StringIO (transform_text ) as transform_stream :
334342 reader = csv .reader (transform_stream , delimiter = delimiter )
335- transform = list (map (lambda xy : [x_factor * float (xy [0 ]),
336- y_factor * float (xy [1 ])],
343+ transform = list (map (lambda xy : [x_factor * float (xy [0 ]) + x_offset ,
344+ y_factor * float (xy [1 ]) + y_offset ,
345+ z_offset ],
337346 reader ))
338347 else :
339348 raise ValidationError (f"Unknown transform data type: { transform_data_type } " )
0 commit comments