@@ -642,8 +642,17 @@ def download(self, directory, include_site=False,
642642 f"offending S3 keys are { s3_keys !s} "
643643 )
644644
645- files_by_session = self ._separate_sessions (files )
646- self ._files = files_by_session
645+ try :
646+ files_by_session = self ._separate_sessions (files )
647+ self ._files = files_by_session
648+ except NotImplementedError :
649+ self ._valid = False
650+ mod_logger .warning (
651+ f"Subject { self .subject_id } has inconsistent session numbers."
652+ f"Skipping download."
653+ )
654+ return
655+
647656 if not files_by_session .keys ():
648657 # There were no valid sessions
649658 self ._valid = False
@@ -730,11 +739,15 @@ def _determine_directions(self,
730739 # Confirm that each nifty file has a corresponding json file.
731740 required_json = set ([f .replace ('.nii.gz' , '.json' ) for f in epi_files ])
732741 if set (json_files ) != required_json :
733- raise ValueError (
734- 'There are nifty files without corresponding json files. We '
735- 'failed to find the following expected files: {files!s}'
736- '' .format (files = required_json - set (json_files ))
742+ self ._valid = False
743+ mod_logger .warning (
744+ f'Subject { self .subject_id } does not have json files '
745+ f'corresponding to its fmap NIFTI files. Failed to '
746+ f'find the following expected files: '
747+ f'{ required_json - set (json_files )} . Subject deemed '
748+ f'invalid.'
737749 )
750+ return input_files
738751
739752 def get_json (json_file ):
740753 if input_type == 'local' :
@@ -785,11 +798,14 @@ def get_json(json_file):
785798 elif 'dir-PA' in jfile :
786799 pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
787800 else :
788- raise ValueError (
789- 'The key {key:s} does not exist in file {jfile:s} and '
790- 'the directionality could not be inferred from the '
791- 'file name.' .format (key = json_key , jfile = jfile )
801+ self ._valid = False
802+ mod_logger .warning (
803+ f'Subject { self .subject_id } lacks the expected '
804+ f'{ json_key } key in file { jfile } and the '
805+ f'directionality could not be inferred from the '
806+ f'file name. Setting subject validity to False.'
792807 )
808+ return input_files
793809 else :
794810 mod_logger .warning (
795811 'The metadata in file {jfile:s} does not match the dir-PA '
@@ -802,7 +818,8 @@ def get_json(json_file):
802818 elif 'dir-PA' in jfile :
803819 pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
804820 else :
805- raise ValueError (
821+ self ._valid = False
822+ mod_logger .warning (
806823 'The metadata for key {key:s} in file {jfile:s} does '
807824 'not match the dir-PA or dir-AP values that you '
808825 'provided. {key:s} = {val:s}. And the directionality '
@@ -811,6 +828,7 @@ def get_json(json_file):
811828 jfile = jfile ,
812829 val = direction ,
813830 ))
831+ return input_files
814832
815833 files = copy .deepcopy (input_files )
816834 del files ['epi_nii' ]
0 commit comments