@@ -641,8 +641,17 @@ def download(self, directory, include_site=False,
641641 f"offending S3 keys are { s3_keys !s} "
642642 )
643643
644- files_by_session = self ._separate_sessions (files )
645- self ._files = files_by_session
644+ try :
645+ files_by_session = self ._separate_sessions (files )
646+ self ._files = files_by_session
647+ except NotImplementedError :
648+ self ._valid = False
649+ mod_logger .warning (
650+ f"Subject { self .subject_id } has inconsistent session numbers."
651+ f"Skipping download."
652+ )
653+ return
654+
646655 if not files_by_session .keys ():
647656 # There were no valid sessions
648657 self ._valid = False
@@ -729,11 +738,15 @@ def _determine_directions(self,
729738 # Confirm that each nifty file has a corresponding json file.
730739 required_json = set ([f .replace ('.nii.gz' , '.json' ) for f in epi_files ])
731740 if set (json_files ) != required_json :
732- raise ValueError (
733- 'There are nifty files without corresponding json files. We '
734- 'failed to find the following expected files: {files!s}'
735- '' .format (files = required_json - set (json_files ))
741+ self ._valid = False
742+ mod_logger .warning (
743+ f'Subject { self .subject_id } does not have json files '
744+ f'corresponding to its fmap NIFTI files. Failed to '
745+ f'find the following expected files: '
746+ f'{ required_json - set (json_files )} . Subject deemed '
747+ f'invalid.'
736748 )
749+ return input_files
737750
738751 def get_json (json_file ):
739752 if input_type == 'local' :
@@ -784,11 +797,14 @@ def get_json(json_file):
784797 elif 'dir-PA' in jfile :
785798 pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
786799 else :
787- raise ValueError (
788- 'The key {key:s} does not exist in file {jfile:s} and '
789- 'the directionality could not be inferred from the '
790- 'file name.' .format (key = json_key , jfile = jfile )
800+ self ._valid = False
801+ mod_logger .warning (
802+ f'Subject { self .subject_id } lacks the expected '
803+ f'{ json_key } key in file { jfile } and the '
804+ f'directionality could not be inferred from the '
805+ f'file name. Setting subject validity to False.'
791806 )
807+ return input_files
792808 else :
793809 mod_logger .warning (
794810 'The metadata in file {jfile:s} does not match the dir-PA '
@@ -801,7 +817,8 @@ def get_json(json_file):
801817 elif 'dir-PA' in jfile :
802818 pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
803819 else :
804- raise ValueError (
820+ self ._valid = False
821+ mod_logger .warning (
805822 'The metadata for key {key:s} in file {jfile:s} does '
806823 'not match the dir-PA or dir-AP values that you '
807824 'provided. {key:s} = {val:s}. And the directionality '
@@ -810,6 +827,7 @@ def get_json(json_file):
810827 jfile = jfile ,
811828 val = direction ,
812829 ))
830+ return input_files
813831
814832 files = copy .deepcopy (input_files )
815833 del files ['epi_nii' ]
0 commit comments