Skip to content

Commit 15804d1

Browse files
committed
Use bids entities for filters
1 parent fb22681 commit 15804d1

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/rbc/bids/longitudinal/template.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import polars as pl
99

10-
from rbc.bids import Suffix, bids_safe_label
10+
from rbc.bids import Datatype, Suffix, bids_safe_label
1111

1212
if TYPE_CHECKING:
1313
from rbc.bids import Bids
@@ -47,9 +47,9 @@ def discover_template_inputs(
4747
"""
4848
filtered = df.filter(
4949
pl.col("ses") != "longitudinal",
50-
pl.col("datatype") == "anat",
50+
pl.col("datatype") == Datatype.ANAT,
5151
pl.col("desc") == "brain",
52-
pl.col("suffix") == "T1w",
52+
pl.col("suffix") == Suffix.T1W,
5353
# Native-space brains only; the MNI-registered desc-brain T1w that
5454
# cross-sectional anat also writes would otherwise be picked up as
5555
# a second input per session, producing duplicate LTA filenames in

src/rbc/bids/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import polars as pl
1212

13-
from rbc.bids import extract_entities
13+
from rbc.bids import Datatype, extract_entities
1414

1515
if TYPE_CHECKING:
1616
from collections.abc import Iterator, Sequence
@@ -50,8 +50,8 @@ def load_session(df: pl.DataFrame, subject: str, session: str | None) -> Session
5050
base: list[pl.Expr] = [pl.col("sub") == subject]
5151
if session is not None:
5252
base.append(pl.col("ses") == session)
53-
anat_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == "anat"]))
54-
func_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == "func"]))
53+
anat_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == Datatype.ANAT]))
54+
func_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == Datatype.FUNC]))
5555

5656
return SessionTables(anat=anat_df, func=func_df if not func_df.is_empty() else None)
5757

src/rbc/orchestration/longitudinal/qc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ def run(
144144
anat_q = pipe_ctx.bids(datatype=Datatype.ANAT)
145145
anat_long_q = anat_q.derive(space="longitudinal")
146146
anat_long_df = full_df.filter(
147-
pl.col("datatype") == "anat",
147+
pl.col("datatype") == Datatype.ANAT,
148148
pl.col("space") == "longitudinal",
149149
)
150150

151151
func_long_df = full_df.filter(
152-
pl.col("datatype") == "func",
152+
pl.col("datatype") == Datatype.FUNC,
153153
pl.col("space") == "longitudinal",
154154
)
155155

src/rbc/orchestration/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import polars as pl
1010
from tqdm import tqdm
1111

12-
from rbc.bids import SUB_SES_QUERY, Datatype, TemplateSpace, load_table
12+
from rbc.bids import SUB_SES_QUERY, Datatype, Suffix, TemplateSpace, load_table
1313
from rbc.bids.metrics import export_metrics, resolve_metrics
1414
from rbc.bids.session import discover_derivative_runs
1515
from rbc.context import RunContext
@@ -109,8 +109,8 @@ def run(
109109

110110
df = filters.apply(
111111
full_df,
112-
pl.col("datatype") == "func",
113-
pl.col("suffix") == "bold",
112+
pl.col("datatype") == Datatype.FUNC,
113+
pl.col("suffix") == Suffix.BOLD,
114114
pl.col("desc") == "preproc",
115115
pl.col("space") == TemplateSpace.MNI152NLIN6ASYM,
116116
)

src/rbc/orchestration/qc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import polars as pl
99
from tqdm import tqdm
1010

11-
from rbc.bids import SUB_SES_QUERY, Datatype, TemplateSpace, load_table
11+
from rbc.bids import SUB_SES_QUERY, Datatype, Suffix, TemplateSpace, load_table
1212
from rbc.bids.qc import export_qc, resolve_qc
1313
from rbc.bids.session import discover_derivative_runs
1414
from rbc.context import RunContext
@@ -53,8 +53,8 @@ def run(
5353

5454
df = filters.apply(
5555
full_df,
56-
pl.col("datatype") == "func",
57-
pl.col("suffix") == "bold",
56+
pl.col("datatype") == Datatype.FUNC,
57+
pl.col("suffix") == Suffix.BOLD,
5858
pl.col("desc") == "preproc",
5959
pl.col("space") == TemplateSpace.MNI152NLIN6ASYM,
6060
)

0 commit comments

Comments
 (0)