@@ -195,6 +195,13 @@ def _bids_filter(value, parser):
195195 help = 'A space delimited list of session identifiers or a single '
196196 'identifier (the ses- prefix can be removed)' ,
197197 )
198+ g_bids .add_argument (
199+ '--tracer-label' ,
200+ nargs = '+' ,
201+ type = lambda label : label .removeprefix ('trc-' ),
202+ help = 'A space delimited list of tracer identifiers or a single '
203+ 'identifier (the trc- prefix can be removed)' ,
204+ )
198205 # Re-enable when option is actually implemented
199206 # g_bids.add_argument('-r', '--run-id', action='store', default='single_run',
200207 # help='Select a specific run to be processed')
@@ -776,6 +783,13 @@ def parse_args(args=None, namespace=None):
776783 'session' : config .execution .session_label ,
777784 }
778785
786+ if config .execution .tracer_label :
787+ config .execution .bids_filters = config .execution .bids_filters or {}
788+ config .execution .bids_filters ['pet' ] = {
789+ ** config .execution .bids_filters .get ('pet' , {}),
790+ 'tracer' : config .execution .tracer_label ,
791+ }
792+
779793 pvc_vals = (opts .pvc_tool , opts .pvc_method , opts .pvc_psf )
780794 if any (val is not None for val in pvc_vals ) and not all (val is not None for val in pvc_vals ):
781795 parser .error ('Options --pvc-tool, --pvc-method and --pvc-psf must be used together.' )
@@ -946,5 +960,25 @@ def parse_args(args=None, namespace=None):
946960 f'{ ", " .join (sorted (missing_sessions ))} .'
947961 )
948962
963+ if config .execution .tracer_label :
964+ tracer_filters = (
965+ config .execution .bids_filters .get ('pet' , {}) if config .execution .bids_filters else {}
966+ )
967+ tracer_filters = {key : value for key , value in tracer_filters .items () if key != 'tracer' }
968+ available_tracers = set (
969+ config .execution .layout .get (
970+ target = 'tracer' ,
971+ return_type = 'id' ,
972+ subject = list (participant_label ) or None ,
973+ ** tracer_filters ,
974+ )
975+ )
976+ missing_tracers = set (config .execution .tracer_label ) - available_tracers
977+ if missing_tracers :
978+ parser .error (
979+ 'One or more tracer labels were not found in the BIDS directory: '
980+ f'{ ", " .join (sorted (missing_tracers ))} .'
981+ )
982+
949983 config .execution .participant_label = sorted (participant_label )
950984 config .workflow .skull_strip_template = config .workflow .skull_strip_template [0 ]
0 commit comments