@@ -417,8 +417,8 @@ def get_entities(self, scope='all', metadata=None):
417
417
418
418
Args:
419
419
scope (str): The scope of the search space. Indicates which
420
- BIDSLayouts' entities to extract. See BIDSLayout docstring
421
- for valid values.
420
+ BIDSLayouts' entities to extract. See BIDSLayout.get()
421
+ docstring for valid values.
422
422
metadata (bool, None): By default (None), all available entities
423
423
are returned. If True, only entities found in metadata files
424
424
(and not defined for filenames) are returned. If False, only
@@ -444,8 +444,8 @@ def get_files(self, scope='all'):
444
444
445
445
Args:
446
446
scope (str): The scope of the search space. Indicates which
447
- BIDSLayouts' entities to extract. See BIDSLayout docstring
448
- for valid values.
447
+ BIDSLayouts' entities to extract. See BIDSLayout.get()
448
+ docstring for valid values.
449
449
450
450
Returns: A dict, where keys are file paths and values are BIDSFile
451
451
instances.
@@ -469,8 +469,8 @@ def parse_file_entities(self, filename, scope='all', entities=None,
469
469
Args:
470
470
filename (str): The filename to parse for entity values
471
471
scope (str, list): The scope of the search space. Indicates which
472
- BIDSLayouts' entities to extract. See BIDSLayout docstring
473
- for valid values. By default, extracts all entities.
472
+ BIDSLayouts' entities to extract. See BIDSLayout.get()
473
+ docstring for valid values. By default, extracts all entities.
474
474
entities (list): An optional list of Entity instances to use in
475
475
extraction. If passed, the scope and config arguments are
476
476
ignored, and only the Entities in this list are used.
@@ -763,7 +763,7 @@ def get_file(self, filename, scope='all'):
763
763
an absolute path, or relative to the root of this BIDSLayout.
764
764
scope (str, list): Scope of the search space. If passed, only
765
765
BIDSLayouts that match the specified scope will be
766
- searched. See BIDSLayout docstring for valid values.
766
+ searched. See BIDSLayout.get() docstring for valid values.
767
767
768
768
Returns: A BIDSFile, or None if no match was found.
769
769
'''
@@ -877,6 +877,27 @@ def get_metadata(self, path, include_entities=False, scope='all'):
877
877
878
878
return {}
879
879
880
+ def get_dataset_description (self , scope = 'self' , all_ = False ):
881
+ ''' Return contents of dataset_description.json.
882
+
883
+ Args:
884
+ scope (str): The scope of the search space. Only descriptions of
885
+ BIDSLayouts that match the specified scope will be returned.
886
+ See BIDSLayout.get() docstring for valid values. Defaults to
887
+ 'self'--i.e., returns the dataset_description.json file for
888
+ only the directly-called BIDSLayout.
889
+ all_ (bool): If True, returns a list containing descriptions for
890
+ all matching layouts. If False (default), returns for only the
891
+ first matching layout.
892
+
893
+ Returns: a dictionary or list of dictionaries (depending on all_).
894
+ '''
895
+ layouts = self ._get_layouts_in_scope (scope )
896
+ if not all_ :
897
+ return layouts [0 ].get_file ('dataset_description.json' ).get_dict ()
898
+ return [l .get_file ('dataset_description.json' ).get_dict ()
899
+ for l in layouts ]
900
+
880
901
def get_nearest (self , path , return_type = 'filename' , strict = True ,
881
902
all_ = False , ignore_strict_entities = 'extension' ,
882
903
full_search = False , ** filters ):
0 commit comments