fsl.utils.bids
¶
This module provides a few functions for working with BIDS data sets.
The |
|
Returns |
|
Returns |
|
Returns |
|
Load all of the metadata associated with |
All of the other functions in this module should not be considered part of the public API.
Note
The pybids library is a more suitable choice if you are after a more robust and featured interface for working with BIDS datasets.
-
class
fsl.utils.bids.
BIDSFile
(filename)[source]¶ Bases:
object
The
BIDSFile
class parses and stores the entities and suffix contained in a BIDS file. See theparseFilename()
function.The
match()
method can be used to compare twoBIDSFile
instances.The following attributes are available on a
BIDSFile
instance:filename
: Absolute path to the fileentities
: Dict ofkey : value
pairs, the entities that are present in the file name (e.g.{'sub' : '01}
)suffix
: File suffix (e.g.T1w
,bold
, etc.)
-
match
(other, suffix=True)[source]¶ Compare this
BIDSFile
toother
.- Parameters
other –
BIDSFile
to comparesuffix – Defaults to
True
. IfFalse
, the comparison is made solely on the entity values.
- Returns
True
ifself.suffix == other.suffix
(unlesssuffix
isFalse
) and if all of the entities inother
are present inself
,False
otherwise.
-
__dict__
= mappingproxy({'__module__': 'fsl.utils.bids', '__doc__': "The ``BIDSFile`` class parses and stores the entities and suffix contained\n in a BIDS file. See the :func:`parseFilename` function.\n\n The :meth:`match` method can be used to compare two ``BIDSFile`` instances.\n\n The following attributes are available on a ``BIDSFile`` instance:\n\n - ``filename``: Absolute path to the file\n - ``entities``: Dict of ``key : value`` pairs, the entities that are\n present in the file name (e.g. ``{'sub' : '01}``)\n - ``suffix``: File suffix (e.g. ``T1w``, ``bold``, etc.)\n ", '__init__': <function BIDSFile.__init__>, '__str__': <function BIDSFile.__str__>, '__repr__': <function BIDSFile.__repr__>, 'match': <function BIDSFile.match>, '__dict__': <attribute '__dict__' of 'BIDSFile' objects>, '__weakref__': <attribute '__weakref__' of 'BIDSFile' objects>})¶
-
__module__
= 'fsl.utils.bids'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
fsl.utils.bids.
parseFilename
(filename)[source]¶ Parses a BIDS-like file name. The file name must consist of zero or more “entities” (alpha-numeric
name-value
pairs), a “suffix”, all separated by underscores, and a regular file extension. For example, the following file:sub-01_ses-01_task-stim_bold.nii.gz
has suffix
bold
, entitiessub=01
,ses=01
andtask=stim
, and extension.nii.gz
.Note
This function assumes that no period (
.
) characters occur in the body of a BIDS filename.- Returns
A tuple containing: - A dict containing the entities - The suffix
-
fsl.utils.bids.
isBIDSDir
(dirname)[source]¶ Returns
True
ifdirname
is the root directory of a BIDS dataset.
-
fsl.utils.bids.
inBIDSDir
(filename)[source]¶ Returns
True
iffilename
looks like it is within a BIDS dataset directory,False
otherwise.
-
fsl.utils.bids.
isBIDSFile
(filename, strict=True)[source]¶ Returns
True
iffilename
looks like a BIDS image or JSON file.- Parameters
filename – Name of file to check
strict – If
True
(the default), the file must be within a BIDS dataset directory, as defined byinBIDSDir()
.