Skip to content

Commit a47f632

Browse files
committed
copilot and robert address
1 parent 302e216 commit a47f632

5 files changed

Lines changed: 10 additions & 141 deletions

File tree

TPTBox/core/np_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,11 @@ def np_dilate_msk_euclid(arr: np.ndarray, n_pixel: int = 3, use_crop=True, label
462462
463463
Assigns each newly covered voxel to the nearest existing label.
464464
"""
465+
arr_bin = arr.copy()
466+
if labels is not None:
467+
arr_bin[np_isin(arr_bin, labels, invert=True)] = 0
468+
465469
if use_crop:
466-
arr_bin = arr.copy()
467-
if labels is not None:
468-
arr_bin[np_isin(arr_bin, labels, invert=True)] = 0
469470
crop = np_bbox_binary(arr_bin, px_dist=1 + n_pixel, raise_error=False)
470471
arrc = arr[crop]
471472
else:

TPTBox/core/poi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,9 @@ def calc_centroids(
13041304
coords = tqdm(coords)
13051305
for i, out_coord in coords:
13061306
if second_stage == -1:
1307-
ctd_list[first_stage, i] = out_coord
1307+
ctd_list[first_stage, int(i)] = out_coord
13081308
else:
1309-
ctd_list[i, second_stage] = out_coord
1309+
ctd_list[int(i), second_stage] = out_coord
13101310
return POI(ctd_list, **msk_nii._extract_affine(), **args)
13111311

13121312

TPTBox/tests/speedtests/speedtest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def speed_test(
5454
functions: list[Callable],
5555
repeats: int = 20,
5656
assert_equal_function: Callable | None = None,
57+
print_first_speed_output: bool = False,
5758
*args,
5859
**kwargs,
5960
):
@@ -72,7 +73,7 @@ def speed_test(
7273
*args,
7374
functions=functions,
7475
assert_equal_function=assert_equal_function,
75-
print_output=repeat_idx == 0,
76+
print_output=repeat_idx == 0 if print_first_speed_output else False,
7677
**kwargs,
7778
)
7879
for k, v in time_measures.items():

TPTBox/tests/speedtests/speedtest_bids_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# build N real BIDS_FILE candidates once (touches a tempdir; not part of the timed comparison)
1111
tmp = Path(tempfile.mkdtemp())
1212
formats = ["T1w", "T2w", "ct", "msk", "dixon"]
13-
N = 2000
13+
N = 100
1414
CANDIDATES = []
1515
for i in range(N):
1616
fmt = formats[i % len(formats)]
@@ -37,7 +37,7 @@ def get_input():
3737

3838
print(f"\n=== Searchquery.filter flatten mode ({N} candidates, keep {keep}) ===")
3939
speed_test(
40-
repeats=12,
40+
repeats=25,
4141
get_input_func=get_input,
4242
functions=[old_filter, new_filter],
4343
assert_equal_function=lambda x, y: [f.BIDS_key for f in x] == [f.BIDS_key for f in y],

unit_tests/test_auto_segmentation.py

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)