-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from richardbeare/BuildTemplateFix
updated build_template with affine shape correction
- Loading branch information
Showing
10 changed files
with
151 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include "antscore/AverageAffineTransform.h" | ||
#include "antscore/AverageAffineTransformNoRigid.h" | ||
|
||
namespace py = pybind11; | ||
|
||
int AverageAffineTransform( std::vector<std::string> instring ) | ||
{ | ||
return ants::AverageAffineTransform(instring, NULL); | ||
} | ||
|
||
PYBIND11_MODULE(AverageAffineTransform, m) | ||
{ | ||
m.def("AverageAffineTransform", &AverageAffineTransform); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include "antscore/AverageAffineTransformNoRigid.h" | ||
|
||
namespace py = pybind11; | ||
|
||
int AverageAffineTransformNoRigid( std::vector<std::string> instring ) | ||
{ | ||
return ants::AverageAffineTransformNoRigid(instring, NULL); | ||
} | ||
|
||
PYBIND11_MODULE(AverageAffineTransformNoRigid, m) | ||
{ | ||
m.def("AverageAffineTransformNoRigid", &AverageAffineTransformNoRigid); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef ANTS_REGISTER_TRANSFORM_H_ | ||
#define ANTS_REGISTER_TRANSFORM_H_ | ||
|
||
#include "itkTransform.h" | ||
#include "itkTransformFactory.h" | ||
|
||
void register_transforms() | ||
{ | ||
using MatrixOffsetTransformTypeA = itk::MatrixOffsetTransformBase<double, 3, 3>; | ||
itk::TransformFactory<MatrixOffsetTransformTypeA>::RegisterTransform(); | ||
|
||
using MatrixOffsetTransformTypeB = itk::MatrixOffsetTransformBase<float, 3, 3>; | ||
itk::TransformFactory<MatrixOffsetTransformTypeB>::RegisterTransform(); | ||
|
||
using MatrixOffsetTransformTypeC = itk::MatrixOffsetTransformBase<double, 2, 2>; | ||
itk::TransformFactory<MatrixOffsetTransformTypeC>::RegisterTransform(); | ||
|
||
using MatrixOffsetTransformTypeD = itk::MatrixOffsetTransformBase<float, 2, 2>; | ||
itk::TransformFactory<MatrixOffsetTransformTypeC>::RegisterTransform(); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from .. import utils, core | ||
from tempfile import mktemp | ||
import os | ||
|
||
|
||
|
||
def _average_affine_transform_driver(transformlist, referencetransform=None, funcname="AverageAffineTransform"): | ||
""" | ||
takes a list of transforms (files at the moment) | ||
and returns the average | ||
""" | ||
|
||
# AverageAffineTransform deals with transform files, | ||
# so this function will need to deal with already | ||
# loaded files. Doesn't look like the magic | ||
# available for images has been added for transforms. | ||
res_temp_file = mktemp(suffix='.mat') | ||
|
||
# could do some stuff here to cope with transform lists that | ||
# aren't files | ||
|
||
# load one of the transforms to figure out the dimension | ||
tf = core.ants_transform_io.read_transform(transformlist[0]) | ||
if referencetransform is None: | ||
args = [tf.dimension, res_temp_file] + transformlist | ||
else: | ||
args = [tf.dimension, res_temp_file] + ['-R', referencetransform] + transformlist | ||
pargs = utils._int_antsProcessArguments(args) | ||
print(pargs) | ||
libfun = utils.get_lib_fn(funcname) | ||
status = libfun(pargs) | ||
|
||
res = core.ants_transform_io.read_transform(res_temp_file) | ||
os.remove(res_temp_file) | ||
return res | ||
|
||
def average_affine_transform(transformlist, referencetransform=None): | ||
return _average_affine_transform_driver(transformlist, referencetransform, "AverageAffineTransform") | ||
|
||
|
||
def average_affine_transform_no_rigid(transformlist, referencetransform=None): | ||
return _average_affine_transform_driver(transformlist, referencetransform, "AverageAffineTransformNoRigid") | ||
|