From 03b33df4562aa0a309aab0eee321c7b5f451e649 Mon Sep 17 00:00:00 2001 From: Jackson Nolan Date: Mon, 3 Aug 2026 17:36:01 -0400 Subject: [PATCH 1/2] Added additional step to load input volumes and extract geometry in the case that no lta files are passed. Ensures that downstream all transform objects are of type surfa.Affine, so the additional wrapper call to do this in the SamsegLongitudinal calls can be dropped --- samseg/cli/run_samseg_long.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samseg/cli/run_samseg_long.py b/samseg/cli/run_samseg_long.py index 1748e63..e9f1cf3 100644 --- a/samseg/cli/run_samseg_long.py +++ b/samseg/cli/run_samseg_long.py @@ -169,7 +169,8 @@ def check_lta_file(filepath): else: print("Assuming an identity transformation between base and each time point") for tp in args.timepoint: - tpToBaseTransforms.append(sf.Affine(np.eye(4))) + tpVol = sf.load_volume(tp) + tpToBaseTransforms.append(sf.Affine(np.eye(4), source=tpVol.geom, target=tpVol.geom)) # ------ Run Samsegment ------ From 4be07f3d43a3929e2e8336d43d1e9304caa4ab50 Mon Sep 17 00:00:00 2001 From: Jackson Nolan Date: Mon, 3 Aug 2026 17:40:15 -0400 Subject: [PATCH 2/2] Removed wrapper calls to sf.Affine. All transforms are handled in the cli entry point, and will be proper sf.Affine objects with the correct geometry --- samseg/SamsegLongitudinal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samseg/SamsegLongitudinal.py b/samseg/SamsegLongitudinal.py index f4ed2f1..282cd6a 100644 --- a/samseg/SamsegLongitudinal.py +++ b/samseg/SamsegLongitudinal.py @@ -855,12 +855,12 @@ def generateSubjectSpecificTemplate(self, saveWarp=False): # Read in the various time point images, and compute the average numberOfTimepoints = len(contrastImageFileNames) image0 = sf.load_volume(contrastImageFileNames[0]) - imageBuffer = image0.transform(sf.Affine(self.tpToBaseTransforms[0])) + imageBuffer = image0.transform(self.tpToBaseTransforms[0]) # Make sure that we are averaging only non zero voxels count = np.zeros(imageBuffer.shape) count[imageBuffer > 0] += 1 for timepointNumber in range(1, numberOfTimepoints): - tmp = sf.load_volume(contrastImageFileNames[timepointNumber]).transform(sf.Affine(self.tpToBaseTransforms[timepointNumber])).data + tmp = sf.load_volume(contrastImageFileNames[timepointNumber]).transform(self.tpToBaseTransforms[timepointNumber]).data imageBuffer += tmp count[tmp > 0] += 1 # Make sure that we are not dividing by zero for, e.g., background voxels