Skip to content

Commit 27d929a

Browse files
Copilotakhanf
andauthored
Address code review: move imports to top of Snakefile, rename private function
Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/5c9691e9-6355-4c0d-85e1-aa07f5c127e3 Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
1 parent 28f6bca commit 27d929a

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

spimquant/workflow/Snakefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
2+
from itertools import combinations as _combinations, product as _product
23

4+
import pandas as _pd
35
from zarrnii import ZarrNii
46
from snakemake.utils import format
57
from snakebids import bids, generate_inputs, get_wildcard_constraints, set_bids_spec
@@ -143,9 +145,6 @@ for seg in config["crop_atlas_segs"]:
143145
crop_atlas_segs.append(seg)
144146
# Validate that model/pairwise arguments are provided when using group analysis level
145147
# and generate pairwise contrast labels from participants.tsv at planning time
146-
from itertools import combinations as _combinations, product as _product
147-
import pandas as _pd
148-
149148
pairwise_contrast_labels = []
150149
pairwise_contrast_info = {} # label -> dict with factor, levelA, levelB, strata
151150

spimquant/workflow/scripts/perform_group_stats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def load_segstats_with_metadata(segstats_paths, participants_df):
6464
return combined.merge(participants_df, on="participant_id", how="left")
6565

6666

67-
def _build_prediction_row(region_data, pairwise_factor, level, strata):
67+
def build_prediction_row(region_data, pairwise_factor, level, strata):
6868
"""Build a one-row DataFrame for marginal mean prediction.
6969
7070
Continuous variables are held at their mean; categorical variables are
@@ -168,8 +168,8 @@ def compute_contrast_for_metric(
168168
fitted = smf.ols(actual_formula, data=region_data).fit()
169169

170170
# Build prediction rows for each level at the desired strata.
171-
pred_df_a = _build_prediction_row(region_data, pairwise_factor, level_a, strata)
172-
pred_df_b = _build_prediction_row(region_data, pairwise_factor, level_b, strata)
171+
pred_df_a = build_prediction_row(region_data, pairwise_factor, level_a, strata)
172+
pred_df_b = build_prediction_row(region_data, pairwise_factor, level_b, strata)
173173

174174
# Use patsy with the model's design_info for consistent dummy encoding.
175175
design_info = fitted.model.data.design_info

0 commit comments

Comments
 (0)