@@ -641,8 +641,17 @@ def download(self, directory, include_site=False,
641
641
f"offending S3 keys are { s3_keys !s} "
642
642
)
643
643
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
+
646
655
if not files_by_session .keys ():
647
656
# There were no valid sessions
648
657
self ._valid = False
@@ -729,11 +738,15 @@ def _determine_directions(self,
729
738
# Confirm that each nifty file has a corresponding json file.
730
739
required_json = set ([f .replace ('.nii.gz' , '.json' ) for f in epi_files ])
731
740
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.'
736
748
)
749
+ return input_files
737
750
738
751
def get_json (json_file ):
739
752
if input_type == 'local' :
@@ -784,11 +797,14 @@ def get_json(json_file):
784
797
elif 'dir-PA' in jfile :
785
798
pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
786
799
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.'
791
806
)
807
+ return input_files
792
808
else :
793
809
mod_logger .warning (
794
810
'The metadata in file {jfile:s} does not match the dir-PA '
@@ -801,7 +817,8 @@ def get_json(json_file):
801
817
elif 'dir-PA' in jfile :
802
818
pa_files .append (jfile .replace ('.json' , '.nii.gz' ))
803
819
else :
804
- raise ValueError (
820
+ self ._valid = False
821
+ mod_logger .warning (
805
822
'The metadata for key {key:s} in file {jfile:s} does '
806
823
'not match the dir-PA or dir-AP values that you '
807
824
'provided. {key:s} = {val:s}. And the directionality '
@@ -810,6 +827,7 @@ def get_json(json_file):
810
827
jfile = jfile ,
811
828
val = direction ,
812
829
))
830
+ return input_files
813
831
814
832
files = copy .deepcopy (input_files )
815
833
del files ['epi_nii' ]
0 commit comments