I have attached SamsegLongitudinal.py to fix the python error. Copy it to /Applications/freesurfer/8.0.0/python/packages/gems/SamsegLongitudinal.py

 

Yujing

 

From: freesurfer-bounces@nmr.mgh.harvard.edu <freesurfer-bounces@nmr.mgh.harvard.edu> On Behalf Of Paola Di Filippo
Sent: Sunday, March 9, 2025 8:28 AM
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Longitudinal samseg not working - TypeError: transform() got an unexpected keyword argument 'affine'

 

        External Email - Use Caution        

Hi everyone, I am trying to launch longitudinal samseg with the lesion flag for an MS subject, in Freesurfer 8.0. I followed instructions, cross sectional samseg for the same subject at T0 worked fine, but now I am having troubles, described as follows:

 

MBP-di-Paola:~ paoladifilippo$ export FS_LICENSE=$HOME/license.txt

MBP-di-Paola:~ paoladifilippo$ export FREESURFER_HOME=/Applications/freesurfer/8.0.0

MBP-di-Paola:~ paoladifilippo$ source $FREESURFER_HOME/SetUpFreeSurfer.sh

-------- freesurfer-macOS-darwin_arm64-8.0.0-20250205-0f2bd3a --------

Setting up environment for FreeSurfer/FS-FAST (and FSL)

FREESURFER_HOME   /Applications/freesurfer/8.0.0

FSFAST_HOME       /Applications/freesurfer/8.0.0/fsfast

FSF_OUTPUT_FORMAT nii.gz

SUBJECTS_DIR      /Applications/freesurfer/8.0.0/subjects

MNI_DIR           /Applications/freesurfer/8.0.0/mni

MBP-di-Paola:~ paoladifilippo$ export LD_LIBRARY_PATH=$FREESURFER_HOME/MCRv97/runtime/maci64:$FREESURFER_HOME/MCRv97/bin/maci64:$FREESURFER_HOME/MCRv97/sys/os/maci64:$FREESURFER_HOME/MCRv97/extern/bin/maci64

MBP-di-Paola:~ paoladifilippo$ cd /Users/paoladifilippo/RM.OCT.NFL/A.C/LONGITUDINAL.SAMSEG

MBP-di-Paola:LONGITUDINAL.SAMSEG paoladifilippo$ run_samseg_long --timepoint A.C.2.4.91.MRI.12.9.22_t1_reg.mgz A.C.2.4.91.MRI.12.9.22_flair_reg.mgz --timepoint A.C.2.4.91.MRI.13.2.23_t1_reg.mgz A.C.2.4.91.MRI.13.2.23_flair_reg.mgz --timepoint A.C.2.4.91.MRI.20.09.23_t1_reg.mgz A.C.2.4.91.MRI.20.09.23_flair_reg.mgz --pallidum-separate --lesion --lesion-mask-pattern 0 1 --output /Users/paoladifilippo/RM.OCT.NFL/A.C/LONG.SAMSEG.OUTPUT/

Assuming an identity transformation between base and each time point

WARNING:tensorflow:From /Applications/freesurfer/8.0.0/python/miniconda3_apple_dist/py3_8_13/lib/python3.8/site-packages/tensorflow/python/compat/v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.

Instructions for updating:

non-resource variables are not supported in the long term

Traceback (most recent call last):

  File "/Applications/freesurfer/8.0.0/python/scripts/run_samseg_long", line 209, in <module>

    samsegLongitudinal.segment(saveWarp=args.save_warp, initTransformFile=args.init_reg)

  File "/Applications/freesurfer/8.0.0/python/packages/gems/SamsegLongitudinal.py", line 181, in segment

    self.constructAndRegisterSubjectSpecificTemplate(initTransformFile)

  File "/Applications/freesurfer/8.0.0/python/packages/gems/SamsegLongitudinal.py", line 200, in constructAndRegisterSubjectSpecificTemplate

    self.sstFileNames = self.generateSubjectSpecificTemplate()

  File "/Applications/freesurfer/8.0.0/python/packages/gems/SamsegLongitudinal.py", line 835, in generateSubjectSpecificTemplate

    imageBuffer = image0.transform(affine=self.tpToBaseTransforms[0])

TypeError: transform() got an unexpected keyword argument 'affine'





I am working on Apple M4 Pro with 48 GB RAM, MacOS 15.2. Any ideas on how to fix this? Thanks in advance