Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5bda559
Add iniital pass at expression interpreter
ubdbra001 Mar 10, 2026
ca15030
add bidsschematools[expressions] dependency
ubdbra001 Mar 11, 2026
aaba7c2
[DATALAD RUNCMD] uv lock
effigies Mar 13, 2026
f170208
chore: Add demo group for experimenting with jupyter
effigies Mar 13, 2026
bba15d8
[DATALAD RUNCMD] uv lock
effigies Mar 13, 2026
3bc13f5
chore: Pin older pyparsing
effigies Mar 13, 2026
520afc6
Merge remote-tracking branch 'upstream/main' into i48-add-espression-…
effigies Mar 13, 2026
cd741c5
feat: Draft evaluator that looks up names in a namespace
effigies Mar 16, 2026
89b177d
update new_evaluator to get working
ubdbra001 Mar 16, 2026
7874ccb
Remove unnecessary code
ubdbra001 Mar 16, 2026
90451d1
add lookup proxy class
ubdbra001 Mar 17, 2026
edf7709
update new_evaluator to incorporate lookup proxy class
ubdbra001 Mar 17, 2026
39d7085
formatting tweaks
ubdbra001 Mar 17, 2026
d64be26
add exists method to context
ubdbra001 Jun 24, 2026
e0325d4
remove exists_ stub from expression_language module
ubdbra001 Jun 24, 2026
2091488
rename evaluation function
ubdbra001 Jun 24, 2026
4710416
add high-level interpret function
ubdbra001 Jun 24, 2026
552b2b0
update exists to only return int
ubdbra001 Jun 24, 2026
4a1fb16
update exists to handle bids-uri option
ubdbra001 Jun 24, 2026
f86aba8
address comments
ubdbra001 Jun 24, 2026
ca7892b
Merge remote-tracking branch 'upstream/main' into i48-add-espression-…
effigies Jun 26, 2026
1564b11
fix: Switch internal quotes
effigies Jun 26, 2026
cbc3dea
sty: ruff format / check
effigies Jun 26, 2026
a8f87f0
add tests for exists method
ubdbra001 Jul 6, 2026
f5ed5cf
update exists to handle external bids-uris
ubdbra001 Jul 6, 2026
271b5e9
Merge remote-tracking branch 'upstream/main' into i48-add-espression-…
effigies Jul 6, 2026
8a51a5c
add tests for expression language
ubdbra001 Jul 6, 2026
9f4d2d7
update docstrings
ubdbra001 Jul 6, 2026
2aa437f
copilot suggestions
ubdbra001 Jul 6, 2026
b5e5852
make ruff happy
ubdbra001 Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ requires-python = ">=3.10"
dependencies = [
"acres >=0.5",
"attrs >=24.1",
"bidsschematools >=1.1",
"bidsschematools[expressions]>=1.1",
"nibabel>=5.3.0",
"orjson>=3.11.3",
"universal_pathlib >=0.2.1",
Expand Down Expand Up @@ -102,6 +102,10 @@ exclude = ".*"
# Ruff configured in ruff.toml

[dependency-groups]
demo = [
"jupyterlab>=4.5.5",
"jupytext>=1.19.1",
]
dev = [
"ipython>=8.37.0",
"ruff>=0.15.5",
Expand Down
50 changes: 50 additions & 0 deletions src/bids_validator/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,56 @@ def sidecar(self) -> Namespace | None:

return Namespace(sidecar)

def exists(self, arg: str | list[str] | None, rule: str | None = 'dataset') -> int:
"""Count of files in an array that exist in the dataset. String is array with length 1."""
if arg is None:
return 0

prefix = UPath()
fileTree = self.file.parent if rule == 'file' else self.dataset.tree

if rule == 'stimuli':
prefix /= 'stimuli'
elif rule == 'subject':
if 'sub' not in self.entities:
return 0
prefix /= f'sub-{self.entities["sub"]}'

if isinstance(arg, str):
arg = [arg]

if rule == 'bids-uri':
valid_uris = (uri for uri in arg if uri.startswith('bids:') and uri.count(':') == 2)
uri_parts = [uri.split(':') for uri in valid_uris]

# Find number of files in this dataset that exist
# Once split these can be processed using dataset rule
dataset_files = self.exists([part[2] for part in uri_parts if part[1] == ''])

outside_files = [[part[1], part[2]] for part in uri_parts if part[1] != '']

# Find number of files in other dataset that exist
if outside_files:
# Resolve dataset links relative to the dataset path
dataset_links = getattr(self.dataset.dataset_description, 'DatasetLinks', {})
links = {
key: (fileTree.path_obj / val).resolve() for key, val in dataset_links.items()
}

# For each uri with another dataset, generate the full path and sum the ones
# that exist
other_files = sum(
UPath(links[ds_name], relpath).exists()
for ds_name, relpath in outside_files
if ds_name in links
)
else:
other_files = 0

return dataset_files + other_files
else:
return sum((prefix / file) in fileTree for file in arg)


class Sessions:
"""Collections of sessions in subject."""
Expand Down
Loading
Loading