[BUG]: Coordinates transforms to native space using ANTs are off #388
3 changed files with 15 additions and 4 deletions
1
docs/changes/newsfragments/388.bugfix
Normal file
1
docs/changes/newsfragments/388.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fix coordinates space transformation using ANTs by `Synchon Mandal`_
|
||||
|
|
@ -55,19 +55,24 @@ class ANTsCoordinatesWarper:
|
|||
|
||||
# Save existing coordinates to a tempfile
|
||||
pretransform_coordinates_path = (
|
||||
element_tempdir / "pretransform_coordinates.txt"
|
||||
element_tempdir / "pretransform_coordinates.csv"
|
||||
)
|
||||
|
Not sure I follow, could you please show what L63 should be? Not sure I follow, could you please show what L63 should be?
before L60
before L60
```python
# Convert LPS to RAS
seeds[:, 0] *= -1
seeds[:, 1] *= -1
```
|
||||
# Convert LPS to RAS
|
||||
seeds[:, 0] *= -1
|
||||
seeds[:, 1] *= -1
|
||||
np.savetxt(
|
||||
pretransform_coordinates_path,
|
||||
seeds,
|
||||
delimiter=",",
|
||||
# Add header while saving to make ANTs work
|
||||
header="x,y,z",
|
||||
# Remove comment tag for header
|
||||
comments="",
|
||||
)
|
||||
|
||||
# Create a tempfile for transformed coordinates output
|
||||
transformed_coords_path = (
|
||||
element_tempdir / "coordinates_transformed.txt"
|
||||
element_tempdir / "coordinates_transformed.csv"
|
||||
)
|
||||
# Set antsApplyTransformsToPoints command
|
||||
apply_transforms_to_points_cmd = [
|
||||
|
|
@ -86,9 +91,14 @@ class ANTsCoordinatesWarper:
|
|||
)
|
||||
|
||||
# Load coordinates
|
||||
return np.loadtxt(
|
||||
transformed_seeds = np.loadtxt(
|
||||
# Skip header when reading
|
||||
transformed_coords_path,
|
||||
delimiter=",",
|
||||
skiprows=1,
|
||||
)
|
||||
# Convert RAS to LPS
|
||||
transformed_seeds[:, 0] *= -1
|
||||
transformed_seeds[:, 1] *= -1
|
||||
|
||||
return transformed_seeds
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ class CoordinatesRegistry(BasePipelineDataRegistry, metaclass=Singleton):
|
|||
seeds = ANTsCoordinatesWarper().warp(
|
||||
seeds=seeds,
|
||||
target_data=target_data,
|
||||
warp_data=warper_spec,
|
||||
warp_data=inverse_warper_spec,
|
||||
)
|
||||
|
||||
return seeds, labels
|
||||
|
|
|
|||
Loading…
Reference in a new issue
can we just do
x[0] *= -1... It's more easy to read than a lambda function to multiply two axis by -1 and another axis by 1.