@@ -923,6 +923,77 @@ def _gen_outfilename(self):
923
923
_ , name , ext = split_filename (self .inputs .in_file )
924
924
return name + ext + '_' + str (self .inputs .label_value )
925
925
926
+
927
+ class MRIPretessInputSpec (FSTraitedSpec ):
928
+ in_filled = File (exists = True , mandatory = True , position = - 4 , argstr = '%s' ,
929
+ desc = ('filled volume, usually wm.mgz' ))
930
+ label = traits .Either (traits .Str ('wm' ), traits .Int (1 ), argstr = '%s' , default = 'wm' ,
931
+ mandatory = True , usedefault = True , position = - 3 ,
932
+ desc = ('label to be picked up, can be a Freesurfer\' s string like '
933
+ '\' wm\' or a label value (e.g. 127 for rh or 255 for lh)' ))
934
+ in_norm = File (exists = True , mandatory = True , position = - 2 , argstr = '%s' ,
935
+ desc = ('the normalized, brain-extracted T1w image. Usually norm.mgz' ))
936
+ out_file = File (position = - 1 , argstr = '%s' , genfile = True ,
937
+ desc = ('the output file after mri_pretess.' ))
938
+
939
+
940
+ nocorners = traits .Bool (False , argstr = '-nocorners' , desc = ('do not remove corner configurations'
941
+ ' in addition to edge ones.' ))
942
+ keep = traits .Bool (False , argstr = '-keep' , desc = ('keep WM edits' ))
943
+ test = traits .Bool (False , argstr = '-test' , desc = ('adds a voxel that should be removed by '
944
+ 'mri_pretess. The value of the voxel is set to that of an ON-edited WM, '
945
+ 'so it should be kept with -keep. The output will NOT be saved.' ))
946
+
947
+ class MRIPretessOutputSpec (TraitedSpec ):
948
+ out_file = File (exists = True , desc = 'output file after mri_pretess' )
949
+
950
+
951
+ class MRIPretess (FSCommand ):
952
+ """
953
+ Uses Freesurfer's mri_pretess to prepare volumes to be tessellated.
954
+
955
+ Description
956
+ -----------
957
+
958
+ Changes white matter (WM) segmentation so that the neighbors of all
959
+ voxels labeled as WM have a face in common - no edges or corners
960
+ allowed.
961
+
962
+ Example
963
+ -------
964
+
965
+ >>> import nipype.interfaces.freesurfer as fs
966
+ >>> pretess = fs.MRIPretess()
967
+ >>> pretess.inputs.in_filled = 'wm.mgz'
968
+ >>> pretess.inputs.in_norm = 'norm.mgz'
969
+ >>> pretess.inputs.nocorners = True
970
+ >>> pretess.cmdline
971
+ 'mri_pretess -nocorners wm.mgz wm norm.mgz wm_pretesswm.mgz'
972
+ >>> pretess.run() # doctest: +SKIP
973
+ """
974
+ _cmd = 'mri_pretess'
975
+ input_spec = MRIPretessInputSpec
976
+ output_spec = MRIPretessOutputSpec
977
+
978
+ def _list_outputs (self ):
979
+ outputs = self .output_spec ().get ()
980
+ outputs ['out_file' ] = os .path .abspath (self ._gen_outfilename ())
981
+ return outputs
982
+
983
+ def _gen_filename (self , name ):
984
+ if name is 'out_file' :
985
+ return self ._gen_outfilename ()
986
+ else :
987
+ return None
988
+
989
+ def _gen_outfilename (self ):
990
+ if isdefined (self .inputs .out_file ):
991
+ return self .inputs .out_file
992
+ else :
993
+ _ , name , ext = split_filename (self .inputs .in_filled )
994
+ return name + '_pretess' + str (self .inputs .label ) + ext
995
+
996
+
926
997
class MRIMarchingCubesInputSpec (FSTraitedSpec ):
927
998
"""
928
999
Uses Freesurfer's mri_mc to create surfaces by tessellating a given input volume
0 commit comments