Browse files

Moved the apply transform code to file.

1) Refactored the apply transform code.
2) Renamed the binary for apply transform workflow.
Future Work:
1) Need to do more manual testing for the apply transform workflow.
2) Need to write test cases for the apply transform workflow.
  • Loading branch information...
Parichit Sharma
Parichit Sharma committed Jul 4, 2018
1 parent 25c3c90 commit 628a562390485f9e957a2f14c7ba910ec8d50081
@@ -6,7 +6,7 @@ method from the workflows.

from dipy.workflows.flow_runner import run_flow
from dipy.workflows.apply_transform import ApplyTransformFlow
from dipy.workflows.align import ApplyTransformFlow

if __name__ == "__main__":
@@ -954,7 +954,7 @@ def _init_optimizer(self, static, moving, transform, params0,

def optimize(self, static, moving, transform, params0,
static_grid2world=None, moving_grid2world=None,
starting_affine=None, ret_metric=False):
r''' Starts the optimization process
@@ -993,11 +993,22 @@ def optimize(self, static, moving, transform, params0,
If None:
Start from identity.
The default is None.
ret_metric : boolean, optional
if True, it returns the parameters for measuring the
similarity between the images (default 'False').
The metric containing optimal parameters and
the distance between the images.
affine_map : instance of AffineMap
the affine resulting affine transformation
xopt : similarity metric
the metric of optimal parameters
fopt : distance
the distance between the images
self._init_optimizer(static, moving, transform, params0,
static_grid2world, moving_grid2world,
@@ -1074,6 +1085,8 @@ def optimize(self, static, moving, transform, params0,
self.params0 = self.transform.get_identity_parameters()

if ret_metric:
return affine_map, opt.xopt, opt.fopt
return affine_map

@@ -1222,4 +1235,4 @@ def transform_origins(static, static_grid2world,
affine_map = AffineMap(transform,
static.shape, static_grid2world,
moving.shape, moving_grid2world)
return affine_map
return affine_map
@@ -45,4 +45,22 @@ def load_affine_matrix(fname):
fname : str
The file containing the saved affine matrix.
return np.loadtxt(fname)
return np.loadtxt(fname)

def save_quality_assur_metric(fname, xopt, fopt):
fname: string
File name to save the metric values.
xopt: numpy array
The metric containing the
optimal parameters for
image registration.
fopt: int
The distance between the registered images.
np.savetxt(fname, xopt, header="Optimal Parameter metric")
with open(fname, 'a') as f:
f.write('# Distance after registration\n')
Oops, something went wrong.

0 comments on commit 628a562

Please sign in to comment.