Skip to content

Commit 74efcfa

Browse files
committed
fix: missing copy method
1 parent 4e78742 commit 74efcfa

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

roiloc/registration.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
from pathlib import PosixPath
23
from typing import Optional
34

@@ -6,12 +7,14 @@
67
from rich import print
78

89

9-
def register(fixed: ANTsImage,
10-
moving: ANTsImage,
11-
type_of_transform: list,
12-
outprefix: str = "",
13-
path: Optional[PosixPath] = None,
14-
mask: Optional[str] = None) -> dict:
10+
def register(
11+
fixed: ANTsImage,
12+
moving: ANTsImage,
13+
type_of_transform: list,
14+
outprefix: str = "",
15+
path: Optional[PosixPath] = None,
16+
mask: Optional[str] = None,
17+
) -> dict:
1518
"""Registration wrapper around ANTs
1619
1720
Args:
@@ -28,27 +31,29 @@ def register(fixed: ANTsImage,
2831
if mask:
2932
mask_path = list(path.glob(mask))
3033
if mask_path:
31-
mask = ants.image_read(str(mask_path[0]),
32-
pixeltype="unsigned int",
33-
reorient="LPI")
34+
mask = ants.image_read(
35+
str(mask_path[0]), pixeltype="unsigned int", reorient="LPI"
36+
)
3437
print(f"\tUsing mask {str(mask_path[0])}")
3538
else:
36-
print(
37-
"\t[bold red]Warning: no mask found. Registering without mask..."
38-
)
39+
print("\t[bold red]Warning: no mask found. Registering without mask...")
3940

40-
return ants.registration(fixed=fixed,
41-
moving=moving,
42-
type_of_transform=type_of_transform,
43-
mask=mask,
44-
outprefix=outprefix)
41+
return ants.registration(
42+
fixed=fixed,
43+
moving=moving,
44+
type_of_transform=type_of_transform,
45+
mask=mask,
46+
outprefix=outprefix,
47+
)
4548

4649

47-
def get_roi(registered_atlas: ANTsImage,
48-
idx: int,
49-
output_dir: Optional[str] = None,
50-
output_file: Optional[str] = None,
51-
save: bool = True) -> ANTsImage:
50+
def get_roi(
51+
registered_atlas: ANTsImage,
52+
idx: int,
53+
output_dir: Optional[str] = None,
54+
output_file: Optional[str] = None,
55+
save: bool = True,
56+
) -> ANTsImage:
5257
"""Get the registered ROI from CerebrA atlas, into a
5358
subject's native space.
5459
@@ -64,7 +69,7 @@ def get_roi(registered_atlas: ANTsImage,
6469
Returns:
6570
ANTsImage: ROI in native space
6671
"""
67-
roi = registered_atlas.copy()
72+
roi = deepcopy(registered_atlas)
6873
roi[roi != idx] = 0
6974
# roi[~np.isin(roi, idx)] = 0
7075

0 commit comments

Comments
 (0)