Filter anat suffix during load#255
Conversation
|
You could also use Datatype.ANAT |
|
also does this close #250 ? |
| def load_session(df: pl.DataFrame, subject: str, session: str | None) -> SessionTables: | ||
| """Filter for anatomical and functional data for a single subject/session. | ||
|
|
||
| Args: | ||
| df: Full bids2table dataframe. | ||
| subject: Subject label without 'sub-' prefix (e.g. ``'01'``) | ||
| session: Session label without 'ses-' prefix (e.g. ``'02'``) | ||
|
|
||
| Returns: | ||
| A :class:`SessionTables` containing separate anatomical and functional | ||
| dataframes. | ||
| """ | ||
| base: list[pl.Expr] = [pl.col("sub") == subject] | ||
| if session is not None: | ||
| base.append(pl.col("ses") == session) | ||
| anat_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == "anat"])) | ||
| func_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == "func"])) | ||
| anat_df = df.filter( | ||
| pl.all_horizontal( | ||
| [*base, pl.col("datatype") == Datatype.ANAT, pl.col("suffix") == Suffix.T1W] | ||
| ) | ||
| ) | ||
| func_df = df.filter(pl.all_horizontal([*base, pl.col("datatype") == Datatype.FUNC])) | ||
|
|
||
| return SessionTables(anat=anat_df, func=func_df if not func_df.is_empty() else None) |
There was a problem hiding this comment.
downstream we have a bunch of redundant filters after this already filters for t1w
- src/rbc/bids/anatomical.py:44
- src/rbc/orchestration/longitudinal.py:160
I wonder if this is sound...
Also closes off everything to T1w - should suffix be a param so t2w + flair is possible in the future?
There was a problem hiding this comment.
I would probably remove the downstream filters. If we decide to support other contrasts in the future then yeah i would make it a parameter.
There was a problem hiding this comment.
Removed the redundant filters downstream (waiting for e2e tests). I've left out adding suffix as a param for now. Probably want to consider how we want to include this since we may want diff params for anat vs func.
43c0795 to
2eac273
Compare
This is causing the non T1w suffix rows to be filtered out, which is needed downstream.
|
PR is no longer relevant...can reopen if we need to revisit |
The filtering for T1w images was a patch fix to get the workflow working, but was repeated across all workflows.
This replaces the 3 separate calls into the initial loading of the session once (where the filter can be updated later on if we want to support anatomical contrasts). Also makes use of the schema generated suffix instead of matching a string.