Skip to content

Commit 825a899

Browse files
committed
account for neu vnb/nnb data
1 parent 3d77114 commit 825a899

File tree

4 files changed

+70
-82
lines changed

4 files changed

+70
-82
lines changed

dsmc.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@
3939
SESSION_PATTERN = re.compile(r"_ses-(?P<session>[^_]+)")
4040

4141

42+
def normalize_session_label(session: str) -> str:
43+
"""Strip common prefixes so labels are comparable (e.g., ses-1 -> 1)."""
44+
session = session.strip()
45+
return session[4:] if session.startswith("ses-") else session
46+
47+
48+
def load_offloaded_pairs(path: Path) -> Set[Tuple[str, str, str]]:
49+
"""
50+
Read offloaded task records.
51+
52+
Returns a set of (task, subject, session) tuples using normalized session labels.
53+
"""
54+
pairs: Set[Tuple[str, str, str]] = set()
55+
if not path.exists():
56+
return pairs
57+
58+
with path.open(newline="") as f:
59+
reader = csv.DictReader(f)
60+
for row in reader:
61+
task = row.get("task", "").strip().upper()
62+
subject = row.get("sub", "").strip()
63+
session = normalize_session_label(row.get("session", ""))
64+
if task and subject and session:
65+
pairs.add((task, subject, session))
66+
return pairs
67+
68+
4269
def parse_args() -> argparse.Namespace:
4370
parser = argparse.ArgumentParser(
4471
description="Count complete subjects per session and list missing tasks."
@@ -109,7 +136,10 @@ def collect_subject_sessions(subject_dir: Path) -> Dict[str, Set[str]]:
109136

110137

111138
def gather_dataset_stats(
112-
dataset_root: Path, dataset_label: str, expected_tasks: Set[str]
139+
dataset_root: Path,
140+
dataset_label: str,
141+
expected_tasks: Set[str],
142+
offloaded_pairs: Set[Tuple[str, str, str]],
113143
) -> Tuple[Dict[str, int], List[Tuple[str, str, str, str]], Set[str]]:
114144
"""
115145
Compute completeness counts and missing task rows for one dataset.
@@ -128,6 +158,22 @@ def gather_dataset_stats(
128158
for session, tasks_present in session_tasks.items():
129159
sessions_seen.add(session)
130160
missing = expected_tasks - tasks_present
161+
162+
# Exempt VNB/NNB sessions that were run offline (recorded in offloaded.csv).
163+
missing = {
164+
task
165+
for task in missing
166+
if not (
167+
task.upper() in {"VNB", "NNB"}
168+
and (
169+
task.upper(),
170+
subject_dir.name,
171+
normalize_session_label(session),
172+
)
173+
in offloaded_pairs
174+
)
175+
}
176+
131177
if not missing:
132178
complete_counts[session] += 1
133179
else:
@@ -170,6 +216,10 @@ def main() -> None:
170216
output_dir: Path = args.output_dir
171217
output_dir.mkdir(parents=True, exist_ok=True)
172218

219+
offloaded_pairs = load_offloaded_pairs(
220+
Path(__file__).resolve().parent / "offloaded.csv"
221+
)
222+
173223
# If no explicit tasks were provided, include any additional tasks found on disk.
174224
if not args.tasks:
175225
expected_tasks = discover_tasks(data_root) or DEFAULT_TASKS
@@ -183,7 +233,7 @@ def main() -> None:
183233
continue
184234

185235
counts, missing, sessions_seen = gather_dataset_stats(
186-
dataset_path, dataset_label, expected_tasks
236+
dataset_path, dataset_label, expected_tasks, offloaded_pairs
187237
)
188238

189239
for session in sorted(sessions_seen, key=session_sort_key):

meta/dsmc_complete_counts.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ dataset,session,complete_subjects
22
int,ses-1,68
33
int,ses-2,46
44
int,ses-3,24
5-
int,ses-33,0
65
obs,ses-1,214

meta/dsmc_missing_tasks.csv

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,22 @@
11
dataset,site,subject,session,missing_task
2-
int,NE,0,ses-33,DSST
3-
int,NE,0,ses-33,DWL
4-
int,NE,0,ses-33,FN
5-
int,NE,0,ses-33,LC
6-
int,NE,0,ses-33,NF
7-
int,NE,0,ses-33,PC
8-
int,NE,0,ses-33,SM
9-
int,NE,0,ses-33,VNB
10-
int,NE,0,ses-1,ATS
11-
int,NE,0,ses-1,DSST
12-
int,NE,0,ses-1,FN
13-
int,NE,0,ses-1,LC
14-
int,NE,0,ses-1,NF
15-
int,NE,0,ses-1,NNB
16-
int,NE,0,ses-1,NTS
17-
int,NE,0,ses-1,SM
18-
int,NE,0,ses-1,VNB
19-
int,NE,00,ses-33,AF
20-
int,NE,00,ses-33,ATS
21-
int,NE,00,ses-33,DSST
22-
int,NE,00,ses-33,DWL
23-
int,NE,00,ses-33,FN
24-
int,NE,00,ses-33,LC
25-
int,NE,00,ses-33,NNB
26-
int,NE,00,ses-33,NTS
27-
int,NE,00,ses-33,PC
28-
int,NE,00,ses-33,SM
29-
int,NE,00,ses-33,VNB
30-
int,NE,00,ses-33,WL
31-
int,NE,00,ses-1,AF
32-
int,NE,00,ses-1,ATS
33-
int,NE,00,ses-1,DSST
34-
int,NE,00,ses-1,DWL
35-
int,NE,00,ses-1,FN
36-
int,NE,00,ses-1,LC
37-
int,NE,00,ses-1,NNB
38-
int,NE,00,ses-1,NTS
39-
int,NE,00,ses-1,PC
40-
int,NE,00,ses-1,SM
41-
int,NE,00,ses-1,VNB
42-
int,NE,00,ses-1,WL
43-
int,NE,1,ses-1,AF
44-
int,NE,1,ses-1,ATS
45-
int,NE,1,ses-1,DSST
46-
int,NE,1,ses-1,FN
47-
int,NE,1,ses-1,LC
48-
int,NE,1,ses-1,NF
49-
int,NE,1,ses-1,NNB
50-
int,NE,1,ses-1,NTS
51-
int,NE,1,ses-1,SM
52-
int,NE,1,ses-1,VNB
53-
int,NE,1,ses-1,WL
54-
int,NE,1111,ses-1,AF
55-
int,NE,1111,ses-1,ATS
56-
int,NE,1111,ses-1,DSST
57-
int,NE,1111,ses-1,DWL
58-
int,NE,1111,ses-1,FN
59-
int,NE,1111,ses-1,NNB
60-
int,NE,1111,ses-1,NTS
61-
int,NE,1111,ses-1,PC
62-
int,NE,1111,ses-1,SM
63-
int,NE,1111,ses-1,VNB
64-
int,NE,9005,ses-3,VNB
652
int,NE,9007,ses-1,WL
663
int,NE,9008,ses-1,SM
674
int,NE,9009,ses-2,DSST
685
int,NE,9009,ses-2,VNB
696
int,NE,9010,ses-3,NF
707
int,NE,9010,ses-3,NTS
71-
int,NE,9013,ses-3,NNB
72-
int,NE,9013,ses-2,VNB
73-
int,NE,9015,ses-2,VNB
748
int,NE,9017,ses-3,LC
759
int,NE,9017,ses-3,VNB
76-
int,NE,9019,ses-3,VNB
7710
int,NE,9020,ses-1,NF
7811
int,NE,9021,ses-2,VNB
79-
int,NE,9021,ses-1,VNB
80-
int,NE,9023,ses-1,VNB
81-
int,NE,9024,ses-1,VNB
82-
int,NE,9028,ses-2,NNB
8312
int,NE,9028,ses-2,VNB
8413
int,NE,9028,ses-1,VNB
8514
int,NE,9029,ses-1,NNB
8615
int,NE,9029,ses-1,VNB
8716
int,NE,9031,ses-2,VNB
8817
int,NE,9033,ses-1,DWL
89-
int,NE,9033,ses-1,NNB
9018
int,NE,9033,ses-1,NTS
91-
int,NE,9033,ses-1,VNB
92-
int,NE,9034,ses-1,VNB
93-
int,NE,9035,ses-1,NNB
94-
int,NE,9035,ses-1,VNB
95-
int,NE,9038,ses-1,VNB
9619
int,NE,9045,ses-1,DSST
97-
int,NE,9999,ses-1,AF
98-
int,NE,9999,ses-1,SM
9920
int,UI,8004,ses-3,AF
10021
int,UI,8005,ses-2,NNB
10122
int,UI,8005,ses-2,NTS

offloaded.csv

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
task,sub,counterbalance,session
2+
VNB,9013,C,ses-2
3+
VNB,9021,B,ses-1
4+
VNB,9023,C,ses-1
5+
VNB,9024,C,ses-1
6+
VNB,9005,B,ses-3
7+
VNB,9015,C,ses-2
8+
VNB,9034,C,ses-1
9+
VNB,9033,B,ses-1
10+
VNB,9019,C,ses-3
11+
VNB,9038,C,ses-1
12+
VNB,9035,C,ses-1
13+
VNB,9031,B,ses-3
14+
NNB,9013,B,ses-3
15+
NNB,9033,B,ses-1
16+
NNB,9035,C,ses-1
17+
NNB,9028,B,ses-2
18+

0 commit comments

Comments
 (0)