@@ -2755,6 +2755,8 @@ class BIDSDataGrabberInputSpec(DynamicTraitedSpec):
27552755 desc = 'Generate exception if list is empty '
27562756 'for a given field' )
27572757 return_type = traits .Enum ('file' , 'namedtuple' , usedefault = True )
2758+ strict = traits .Bool (desc = 'Return only BIDS "proper" files (e.g., '
2759+ 'ignore derivatives/, sourcedata/, etc.)' )
27582760
27592761
27602762class BIDSDataGrabber (IOBase ):
@@ -2801,8 +2803,10 @@ def __init__(self, infields=None, **kwargs):
28012803 super (BIDSDataGrabber , self ).__init__ (** kwargs )
28022804
28032805 if not isdefined (self .inputs .output_query ):
2804- self .inputs .output_query = {"func" : {"modality" : "func" },
2805- "anat" : {"modality" : "anat" }}
2806+ self .inputs .output_query = {
2807+ "func" : {"modality" : "func" , 'extensions' : ['nii' , '.nii.gz' ]},
2808+ "anat" : {"modality" : "anat" , 'extensions' : ['nii' , '.nii.gz' ]},
2809+ }
28062810
28072811 # If infields is empty, use all BIDS entities
28082812 if infields is None and have_pybids :
@@ -2828,7 +2832,10 @@ def _run_interface(self, runtime):
28282832 return runtime
28292833
28302834 def _list_outputs (self ):
2831- layout = gb .BIDSLayout (self .inputs .base_dir )
2835+ exclude = None
2836+ if self .inputs .strict :
2837+ exclude = ['derivatives/' , 'code/' , 'sourcedata/' ]
2838+ layout = gb .BIDSLayout (self .inputs .base_dir , exclude = exclude )
28322839
28332840 # If infield is not given nm input value, silently ignore
28342841 filters = {}
0 commit comments