File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -848,6 +848,7 @@ class _BIDSFreeSurferDirInputSpec(BaseInterfaceInputSpec):
848
848
overwrite_fsaverage = traits .Bool (
849
849
False , usedefault = True , desc = "Overwrite fsaverage directories, if present"
850
850
)
851
+ minimum_fs_version = traits .Enum ("7.0.0" , desc = "Minimum FreeSurfer version for compatibility" )
851
852
852
853
853
854
class _BIDSFreeSurferDirOutputSpec (TraitedSpec ):
@@ -911,6 +912,16 @@ def _run_interface(self, runtime):
911
912
else :
912
913
raise FileNotFoundError ("Expected to find '%s' to copy" % source )
913
914
915
+ if (
916
+ space == 'fsaverage'
917
+ and dest .exists ()
918
+ and self .inputs .minimum_fs_version == "7.0.0"
919
+ ):
920
+ label = dest / 'label' / 'rh.FG1.mpm.vpnl.label' # new in FS7
921
+ if not label .exists ():
922
+ # remove previous output and let us recopy
923
+ shutil .rmtree (dest )
924
+
914
925
# Finesse is overrated. Either leave it alone or completely clobber it.
915
926
if dest .exists () and self .inputs .overwrite_fsaverage :
916
927
shutil .rmtree (dest )
Original file line number Diff line number Diff line change @@ -697,3 +697,30 @@ def test_fsdir_missing_space(tmp_path):
697
697
bintfs .BIDSFreeSurferDir (
698
698
derivatives = str (tmp_path ), spaces = ["fsaverage2" ], freesurfer_home = fshome
699
699
).run ()
700
+
701
+
702
+ @pytest .mark .skipif (not os .getenv ("FREESURFER_HOME" ), reason = "No FreeSurfer" )
703
+ @pytest .mark .parametrize ('min_version' , [None , '7.0.0' ])
704
+ def test_fsdir_min_version (tmp_path , min_version ):
705
+ fshome = os .environ ["FREESURFER_HOME" ]
706
+ subjects_dir = tmp_path / "freesurfer"
707
+
708
+ patched_subject_dir = subjects_dir / 'fsaverage' / 'older'
709
+ patched_subject_dir .mkdir (parents = True )
710
+
711
+ bfsd = bintfs .BIDSFreeSurferDir (
712
+ subjects_dir = subjects_dir ,
713
+ derivatives = str (tmp_path ),
714
+ spaces = ["fsaverage" ],
715
+ freesurfer_home = fshome ,
716
+ )
717
+
718
+ if min_version :
719
+ bfsd .inputs .minimum_fs_version = min_version
720
+
721
+ bfsd .run ()
722
+ if min_version :
723
+ # should have been overwritten with proper subjects dir
724
+ assert not patched_subject_dir .exists ()
725
+ else :
726
+ assert patched_subject_dir .exists ()
You can’t perform that action at this time.
0 commit comments