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