@@ -252,6 +252,16 @@ def list_all_subjects(self):
252252 """
253253 raise NotImplementedError
254254
255+ def filter_keys (self , subject ):
256+ """Study-specific S3 key filtering
257+
258+ Parameters
259+ ----------
260+ subject : dmriprep.data.Subject
261+ subject instance
262+ """
263+ raise NotImplementedError
264+
255265 def postprocess (self , subject ):
256266 """Study-specific postprocessing steps
257267
@@ -363,6 +373,34 @@ def get_subs_from_tsv_key(s3_key):
363373
364374 return all_subjects
365375
376+ def filter_keys (self , subject ):
377+ """Filter S3 keys based on HBN specific vagaries
378+
379+ HBN Site-CBIC has multiple anatomy folders due to
380+ motion correction software at the scanner level.
381+ If subject.site == "Site-CBIC" then choose only the
382+ anatomy files in the T1W_VNavNorm files
383+
384+ Parameters
385+ ----------
386+ subject : dmriprep.data.Subject
387+ subject instance
388+ """
389+ if subject .site == "Site-CBIC" :
390+ t1w_keys = subject .s3_keys ['t1w' ]
391+ freesurfer_keys = subject .s3_keys ['freesurfer' ]
392+ correct_dir = "T1w_VNavNorm"
393+
394+ subject ._s3_keys ['t1w' ] = list (filter (
395+ lambda x : correct_dir in x ,
396+ t1w_keys
397+ ))
398+
399+ subject ._s3_keys ['freesurfer' ] = list (filter (
400+ lambda x : correct_dir in x ,
401+ freesurfer_keys
402+ ))
403+
366404 def postprocess (self , subject ):
367405 """Move the T1 file back into the freesurfer directory.
368406
@@ -417,6 +455,7 @@ def __init__(self, subject_id, study, site=None):
417455 self ._valid = False
418456 self ._organize_s3_keys ()
419457 if self .valid :
458+ self .study .filter_keys (self )
420459 self ._s3_keys = self ._determine_directions (self ._s3_keys )
421460 self ._files = None
422461
0 commit comments