Skip to content

Commit 4c5729b

Browse files
committed
made changes to orchestrate and match for handling conditional cases better
1 parent 03739f9 commit 4c5729b

File tree

5 files changed

+196
-18
lines changed

5 files changed

+196
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ This repo contains a minimal amount of hard-coding to allow for reproducibility
1313
- [x] Add .csvs to BIDS not sourcedata
1414
- [x] GGIR is formatted as GGIR-#.# with no more version numbers after the second. Full version number should be put into the readme
1515
- [x] Finish adding all required code to move to linux
16-
- [ ] move to linux?
17-
16+
- [x] move to linux?
17+
- [ ] Test on linux and prepare prelims

code/src/cron-act.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
#connect to LSS/RDSS
66

7-
sudo mount -t cifs "//itf-rs-store24.hpc.uiowa.edu/vosslabhpc" /home/vosslab-svc/tmp/vosslabhpc -o uid=vosslab-svc,username=vosslab-svc,vers=3.0
87

98

10-
sudo mount -t cifs //rdss.iowa.uiowa.edu/rdss_mwvoss/VossLab /mnt/nfs/rdss/rdss_vosslab -o user=vosslab-svc,uid=2418317,gid=900001021
119

1210

1311
cd /path/to/code
@@ -17,7 +15,6 @@ source /path/to/venv/bin/activate
1715

1816
python3 src/match.py --indir /Volumes/VossLab/Repositories/Accelerometer_Data --txt ./code/resources/files.txt --token DE4E2DB72778DACA9B8848574107D2F5
1917

20-
place
2118

2219
#deconnect from RDSS and LSS
2320
#deactivate the virtual environment

code/src/match.py

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
INT_DIR = '/Volumes/vosslabhpc/Projects/BOOST/InterventionStudy/3-experiment/data/bids'
1010
OBS_DIR = '/Volumes/vosslabhpc/Projects/BOOST/ObservationalStudy/3-experiment/data/'
11-
1211

1312
def parse_args():
1413
argparser = argparse.ArgumentParser(description='Match files to REDCap')
@@ -29,7 +28,6 @@ def save_files(dir, txt):
2928
f.close()
3029
return txt
3130

32-
3331
def get_files(dir):
3432
data = os.listdir(dir)
3533
return data
@@ -39,7 +37,6 @@ def compare(files, txt):
3937
with open(txt, 'r') as f:
4038
data = f.read().splitlines()
4139
f.close()
42-
4340
for file in files:
4441
if file not in data:
4542
need.append(file)
@@ -72,26 +69,54 @@ def get_list(token):
7269
df = pd.read_csv(StringIO(r.text))
7370
return df
7471

72+
7573
def compare_ids(files, list):
74+
"""
75+
Compare IDs between two DataFrames and log matched and unmatched entries.
76+
Args:
77+
files (pd.DataFrame): DataFrame containing 'labid' and 'file' columns.
78+
list (pd.DataFrame): DataFrame containing 'lab_id' and 'boost_id' columns.
79+
Returns:
80+
pd.DataFrame: Matched rows with columns 'lab_id', 'raw_file', and 'subject_id'.
81+
"""
7682
# Ensure both columns are of the same type before merging
7783
files['labid'] = files['labid'].astype(str)
7884
list['lab_id'] = list['lab_id'].astype(str)
79-
8085
# Merge files and list dataframes with validation
8186
matched = pd.merge(
82-
files,
83-
list,
84-
left_on='labid',
85-
right_on='lab_id',
86-
how='inner',
87+
files,
88+
list,
89+
left_on='labid',
90+
right_on='lab_id',
91+
how='inner',
8792
validate='many_to_one'
8893
)
8994

9095
# Rename columns to match the desired output
9196
matched = matched[['lab_id', 'file', 'boost_id']].rename(columns={'file': 'raw_file', 'boost_id': 'subject_id'})
9297

93-
# Print matched lab_ids
94-
print('Matched lab_ids:', matched['lab_id'].unique())
98+
# Identify unmatched files and subs
99+
unmatched_files = files[~files['labid'].isin(matched['lab_id'])]
100+
unmatched_subs = list[~list['lab_id'].isin(matched['lab_id'])]
101+
102+
# Log matched IDs
103+
print("Matched IDs:")
104+
print(f"- Total Matched: {len(matched)}")
105+
print(f"- Matched Lab IDs: {', '.join(matched['lab_id'].unique())}")
106+
107+
# Log unmatched files
108+
if not unmatched_files.empty:
109+
print("Unmatched Files:")
110+
print(unmatched_files[['labid', 'file']].to_string(index=False))
111+
else:
112+
print("No unmatched files found.")
113+
114+
# Log unmatched subs
115+
if not unmatched_subs.empty:
116+
print("Unmatched Subs:")
117+
print(unmatched_subs[['lab_id', 'boost_id']].to_string(index=False))
118+
else:
119+
print("No unmatched subs found.")
95120

96121
return matched
97122

@@ -140,7 +165,7 @@ def evaluate_run(matched):
140165
import re
141166

142167
def save_n_rename_files(matched, dir):
143-
outputs = []
168+
outputs = []
144169
for index, row in matched.iterrows():
145170
# Use regex to extract the year from the file name
146171
match = re.search(r'\((\d{4})-\d{2}-\d{2}\)', row['raw_file'])
@@ -149,7 +174,7 @@ def save_n_rename_files(matched, dir):
149174
outdir = OBS_DIR
150175
else:
151176
outdir = INT_DIR
152-
177+
153178
if match:
154179
year = int(match.group(1))
155180
else:

docs/.gitkeeper

Whitespace-only changes.

requirements.txt

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
anyio==4.6.2.post1
2+
appnope==0.1.4
3+
argon2-cffi==23.1.0
4+
argon2-cffi-bindings==21.2.0
5+
arrow==1.3.0
6+
astroid==3.3.5
7+
asttokens==2.4.1
8+
async-lru==2.0.4
9+
attrs==24.2.0
10+
autopep8==2.0.4
11+
babel==2.16.0
12+
beautifulsoup4==4.12.3
13+
black==24.10.0
14+
bleach==6.2.0
15+
certifi==2024.8.30
16+
cffi==1.17.1
17+
charset-normalizer==3.4.0
18+
click==8.1.7
19+
comm==0.2.2
20+
contourpy==1.3.1
21+
cycler==0.12.1
22+
debugpy==1.8.8
23+
decorator==5.1.1
24+
defusedxml==0.7.1
25+
dill==0.3.9
26+
docstring-to-markdown==0.15
27+
executing==2.1.0
28+
fastjsonschema==2.20.0
29+
flake8==7.1.1
30+
fonttools==4.55.0
31+
fqdn==1.5.1
32+
greenlet==3.1.1
33+
h11==0.14.0
34+
httpcore==1.0.7
35+
httpx==0.27.2
36+
idna==3.10
37+
ipykernel==6.29.5
38+
ipython==8.29.0
39+
ipywidgets==8.1.5
40+
isoduration==20.11.0
41+
isort==5.13.2
42+
jedi==0.19.2
43+
Jinja2==3.1.4
44+
joblib==1.4.2
45+
json5==0.9.28
46+
jsonpointer==3.0.0
47+
jsonschema==4.23.0
48+
jsonschema-specifications==2024.10.1
49+
jupyter==1.1.1
50+
jupyter-console==6.6.3
51+
jupyter-events==0.10.0
52+
jupyter-lsp==2.2.5
53+
jupyter_client==8.6.3
54+
jupyter_core==5.7.2
55+
jupyter_server==2.14.2
56+
jupyter_server_terminals==0.5.3
57+
jupyterlab==4.2.6
58+
jupyterlab_pygments==0.3.0
59+
jupyterlab_server==2.27.3
60+
jupyterlab_widgets==3.0.13
61+
jupytext==1.16.4
62+
kiwisolver==1.4.7
63+
lxml==5.3.0
64+
markdown-it-py==3.0.0
65+
MarkupSafe==3.0.2
66+
matplotlib==3.9.2
67+
matplotlib-inline==0.1.7
68+
mccabe==0.7.0
69+
mdit-py-plugins==0.4.2
70+
mdurl==0.1.2
71+
mistune==3.0.2
72+
msgpack==1.1.0
73+
mypy==1.13.0
74+
mypy-extensions==1.0.0
75+
nbclient==0.10.0
76+
nbconvert==7.16.4
77+
nbformat==5.10.4
78+
nest-asyncio==1.6.0
79+
nibabel==5.3.2
80+
nilearn==0.10.4
81+
nodeenv==1.9.1
82+
notebook==7.2.2
83+
notebook_shim==0.2.4
84+
numpy==2.1.3
85+
overrides==7.7.0
86+
packaging==24.2
87+
pandas==2.2.3
88+
pandocfilters==1.5.1
89+
parso==0.8.4
90+
pathspec==0.12.1
91+
pexpect==4.9.0
92+
pillow==11.0.0
93+
platformdirs==4.3.6
94+
pluggy==1.5.0
95+
prometheus_client==0.21.0
96+
prompt_toolkit==3.0.48
97+
psutil==6.1.0
98+
ptyprocess==0.7.0
99+
pure_eval==0.2.3
100+
pyarrow==18.0.0
101+
pycodestyle==2.12.1
102+
pycparser==2.22
103+
pydocstyle==6.3.0
104+
pyflakes==3.2.0
105+
Pygments==2.18.0
106+
pylance==0.19.2
107+
pylint==3.3.1
108+
pylsp-mypy==0.6.9
109+
pynvim==0.5.2
110+
pyparsing==3.2.0
111+
pyright==1.1.389
112+
python-dateutil==2.9.0.post0
113+
python-json-logger==2.0.7
114+
python-lsp-black==2.0.0
115+
python-lsp-isort==0.2.0
116+
python-lsp-jsonrpc==1.1.2
117+
python-lsp-server==1.12.0
118+
pytoolconfig==1.3.1
119+
pytz==2024.2
120+
PyYAML==6.0.2
121+
pyzmq==26.2.0
122+
referencing==0.35.1
123+
requests==2.32.3
124+
rfc3339-validator==0.1.4
125+
rfc3986-validator==0.1.1
126+
rope==1.13.0
127+
rpds-py==0.21.0
128+
scikit-learn==1.5.2
129+
scipy==1.14.1
130+
seaborn==0.13.2
131+
Send2Trash==1.8.3
132+
setuptools==75.5.0
133+
six==1.16.0
134+
sniffio==1.3.1
135+
snowballstemmer==2.2.0
136+
soupsieve==2.6
137+
stack-data==0.6.3
138+
terminado==0.18.1
139+
threadpoolctl==3.5.0
140+
tinycss2==1.4.0
141+
tomlkit==0.13.2
142+
tornado==6.4.1
143+
traitlets==5.14.3
144+
types-python-dateutil==2.9.0.20241003
145+
typing_extensions==4.12.2
146+
tzdata==2024.2
147+
ujson==5.10.0
148+
uri-template==1.3.0
149+
urllib3==2.2.3
150+
wcwidth==0.2.13
151+
webcolors==24.11.1
152+
webencodings==0.5.1
153+
websocket-client==1.8.0
154+
whatthepatch==1.0.7
155+
widgetsnbextension==4.0.13
156+
yapf==0.43.0

0 commit comments

Comments
 (0)