I found documentation on how to save a BIDS layout to a sql database, but not clear how should I load one through pyBIDS.
Does anyone know how? Or am I missing some important page in the doc.
Hi Hao Ting,
You can do two things:
Either use the load
function:
from bids.layout import BIDSLayout
layout = BIDSLayout.load(path_to_folder)
def entities(self): """Get the entities.""" return self.get_entities() @property def files(self): """Get the files.""" return self.get_files() @classmethod def load(cls, database_path): """ Load index from database path. Initialization parameters are set to those found in database_path JSON sidecar. Parameters ---------- database_path : str, Path The path to the desired database folder. If a relative path is passed, it is assumed to be relative to the BIDSLayout root directory. """
or pass a database_path
to the BIDSLayout
class when you instantiate it:
sources : :obj:`bids.layout.BIDSLayout` or list or None, optional Optional BIDSLayout(s) from which the current BIDSLayout is derived. config_filename : str Optional name of filename within directories that contains configuration information. regex_search : bool Whether to require exact matching (True) or regex search (False, default) when comparing the query string to each entity in .get() calls. This sets a default for the instance, but can be overridden in individual .get() requests. database_path : str Optional path to directory containing SQLite database file index for this BIDS dataset. If a value is passed and the folder already exists, indexing is skipped. By default (i.e., if None), an in-memory SQLite database is used, and the index will not persist unless .save() is explicitly called. reset_database : bool If True, any existing directory specified in the database_path argument is deleted, and the BIDS dataset provided in the root argument is reindexed. If False, indexing will be skipped and the existing database file will be used. Ignored if
Let me know if that makes sense, and if you think the docs need some amendment, I would highly appreciate some suggestions or a PR
Thanks! I will have a look. The doc was a bit difficult to navigate. I will have a think and perhaps open a discussion on pybids repo.
1 Like