@@ -585,6 +585,8 @@ def find_fmap_groups(fmap_dir):
585
585
def get_key_info_for_fmap_assignment (json_file , matching_parameter ):
586
586
"""
587
587
Gets key information needed to assign fmaps to other modalities.
588
+ (Note: It is the responsibility of the calling function to make sure
589
+ the arguments are OK)
588
590
589
591
Parameters:
590
592
----------
@@ -603,10 +605,6 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter):
603
605
raise FileNotFoundError (
604
606
errno .ENOENT , os .strerror (errno .ENOENT ), json_file
605
607
)
606
- if matching_parameter not in AllowedFmapParameterMatching :
607
- raise ValueError (
608
- "Fmap matching_parameter %s not allowed." % matching_parameter
609
- )
610
608
611
609
# loop through the possible criteria and extract the info needed
612
610
if matching_parameter == 'Shims' :
@@ -636,13 +634,18 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter):
636
634
# We want to force the matching, so just return some string
637
635
# regardless of the image
638
636
key_info = [KeyInfoForForce ]
637
+ else :
638
+ # fallback:
639
+ key_info = []
639
640
640
641
return key_info
641
642
642
643
643
644
def find_compatible_fmaps_for_run (json_file , fmap_groups , matching_parameters ):
644
645
"""
645
646
Finds compatible fmaps for a given run, for populate_intended_for.
647
+ (Note: It is the responsibility of the calling function to make sure
648
+ the arguments are OK)
646
649
647
650
Parameters:
648
651
----------
@@ -662,16 +665,9 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters):
662
665
key: prefix common to the group
663
666
value: list of all fmap paths in the group
664
667
"""
665
- if type (matching_parameters ) is not list :
666
- matching_parameters = [matching_parameters ]
667
-
668
668
lgr .debug ('Looking for fmaps for %s' , json_file )
669
669
json_info = {}
670
670
for param in matching_parameters :
671
- if param not in AllowedFmapParameterMatching :
672
- raise ValueError (
673
- "Fmap matching_parameter %s not allowed." % param
674
- )
675
671
json_info [param ] = get_key_info_for_fmap_assignment (json_file , param )
676
672
677
673
compatible_fmap_groups = {}
@@ -698,6 +694,8 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters):
698
694
def find_compatible_fmaps_for_session (path_to_bids_session , matching_parameters ):
699
695
"""
700
696
Finds compatible fmaps for all non-fmap runs in a session.
697
+ (Note: It is the responsibility of the calling function to make sure
698
+ the arguments are OK)
701
699
702
700
Parameters:
703
701
----------
@@ -712,15 +710,6 @@ def find_compatible_fmaps_for_session(path_to_bids_session, matching_parameters)
712
710
compatible_fmap : dict
713
711
Dict of compatible_fmaps_groups (values) for each non-fmap run (keys)
714
712
"""
715
- if not isinstance (matching_parameters , list ):
716
- assert isinstance (matching_parameters , str ), "matching_parameters must be a str or a list, got %s" % matching_parameters
717
- matching_parameters = [matching_parameters ]
718
- for param in matching_parameters :
719
- if param not in AllowedFmapParameterMatching :
720
- raise ValueError (
721
- "Fmap matching_parameter %s not allowed." % param
722
- )
723
-
724
713
lgr .debug ('Looking for fmaps for session: %s' , path_to_bids_session )
725
714
726
715
# Resolve path (eliminate '..')
@@ -753,6 +742,8 @@ def select_fmap_from_compatible_groups(json_file, compatible_fmap_groups, criter
753
742
"""
754
743
Selects the fmap that will be used to correct for distortions in json_file
755
744
from the compatible fmap_groups list, based on the given criterion
745
+ (Note: It is the responsibility of the calling function to make sure
746
+ the arguments are OK)
756
747
757
748
Parameters:
758
749
----------
@@ -768,11 +759,6 @@ def select_fmap_from_compatible_groups(json_file, compatible_fmap_groups, criter
768
759
selected_fmap_key : str or os.path
769
760
key from the compatible_fmap_groups for the selected fmap group
770
761
"""
771
- if criterion not in AllowedCriteriaForFmapAssignment :
772
- raise ValueError (
773
- "Fmap assignment criterion '%s' not allowed." % criterion
774
- )
775
-
776
762
if len (compatible_fmap_groups ) == 0 :
777
763
return None
778
764
# if compatible_fmap_groups has only one entry, that's it:
@@ -862,7 +848,8 @@ def populate_intended_for(path_to_bids_session, matching_parameters, criterion):
862
848
fmaps to use
863
849
"""
864
850
865
- if type (matching_parameters ) is not list :
851
+ if not isinstance (matching_parameters , list ):
852
+ assert isinstance (matching_parameters , str ), "matching_parameters must be a str or a list, got %s" % matching_parameters
866
853
matching_parameters = [matching_parameters ]
867
854
for param in matching_parameters :
868
855
if param not in AllowedFmapParameterMatching :
0 commit comments