@@ -1186,3 +1186,64 @@ def _list_outputs(self):
11861186 outputs = self .output_spec ().get ()
11871187 outputs ["out_file" ] = op .abspath (self .inputs .out_file )
11881188 return outputs
1189+
1190+ class MaskFilterInputSpec (CommandLineInputSpec ):
1191+ in_file = File (
1192+ exists = True ,
1193+ mandatory = True ,
1194+ argstr = "%s" ,
1195+ position = - 3 ,
1196+ desc = "Input mask" ,
1197+ )
1198+ filter = traits .Str (
1199+ mandatory = True ,
1200+ argstr = "%s" ,
1201+ position = - 2 ,
1202+ desc = "Filter to perform (e.g. dilate, erode)"
1203+ )
1204+ out_file = File (
1205+ name_source = ["input_image" ],
1206+ mandatory = True ,
1207+ argstr = "%s" ,
1208+ position = - 1
1209+ desc = "Output mask"
1210+ )
1211+ npass = traits .Int (
1212+ argstr = "-npass %d" ,
1213+ position = 1 ,
1214+ desc = "Number of passes"
1215+ )
1216+
1217+ class MaskFilterOutputSpec (TraitedSpec ):
1218+ out_file = File (exists = True , desc = "the filtered output mask" )
1219+
1220+ class MaskFilter (CommandLine ):
1221+ """
1222+ Perform filtering operations on 3D / 4D mask images.
1223+ Only supports dilate / erode filters at the moment.
1224+
1225+
1226+ Example
1227+ -------
1228+
1229+ >>> import nipype.interfaces.mrtrix3 as mrt
1230+ >>> mf = mrt.MaskFilter()
1231+ >>> mf.inputs.in_file = 'mask.mif'
1232+ >>> mf.inputs.filter = 'dilate'
1233+ >>> mf.inputs.npass = 2
1234+ >>> mf.out_file = 'mask_filtered.mif'
1235+ >>> mf.cmdline
1236+ 'maskfilter -npass 2 mask.mif dilate mask_filtered.mif'
1237+ >>> mf.run()
1238+ """
1239+
1240+ _cmd = "maskfilter"
1241+ input_spec = MaskFilterInputSpec
1242+ output_spec = MaskFilterOutputSpec
1243+
1244+ def _list_outputs (self ):
1245+ outputs = self .output_spec ().get ()
1246+ outputs = self .output_spec ().get ()
1247+ inputs = self .input_spec ().get ()
1248+ outputs ["output_image" ] = self ._gen_filename (inputs ["input_image" ], suffix = "_filtered" )
1249+ return outputs
0 commit comments