Skip to content

Commit

Permalink
Automated commit -> added return statement to parser in jatosapi
Browse files Browse the repository at this point in the history
  • Loading branch information
miloswrath committed Oct 1, 2024
1 parent cd8dc06 commit 737da56
Show file tree
Hide file tree
Showing 37 changed files with 32 additions and 1,847 deletions.
9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-7001-191837.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-7018-191837.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-7019-191837.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-8000-191837.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-8002-191837.md

This file was deleted.

9 changes: 0 additions & 9 deletions _posts/2024-09-27-subject-8007-191837.md

This file was deleted.

145 changes: 0 additions & 145 deletions data/7001/processed/run-1/7001_NF_C.csv

This file was deleted.

145 changes: 0 additions & 145 deletions data/7001/raw/data.txt

This file was deleted.

Binary file removed data/7001/run-1/7001_NF_acc.png
Binary file not shown.
Binary file removed data/7001/run-1/7001_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/7001/run-1/qc_NF_C.log

This file was deleted.

145 changes: 0 additions & 145 deletions data/7018/processed/run-1/7018_NF_C.csv

This file was deleted.

161 changes: 0 additions & 161 deletions data/7018/raw/data.txt

This file was deleted.

Binary file removed data/7018/run-1/7018_NF_acc.png
Binary file not shown.
Binary file removed data/7018/run-1/7018_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/7018/run-1/qc_NF_C.log

This file was deleted.

145 changes: 0 additions & 145 deletions data/7019/processed/run-1/7019_NF_C.csv

This file was deleted.

145 changes: 0 additions & 145 deletions data/7019/raw/data.txt

This file was deleted.

Binary file removed data/7019/run-1/7019_NF_acc.png
Binary file not shown.
Binary file removed data/7019/run-1/7019_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/7019/run-1/qc_NF_C.log

This file was deleted.

145 changes: 0 additions & 145 deletions data/8000/processed/run-1/8000_NF_C.csv

This file was deleted.

145 changes: 0 additions & 145 deletions data/8000/raw/data.txt

This file was deleted.

Binary file removed data/8000/run-1/8000_NF_acc.png
Binary file not shown.
Binary file removed data/8000/run-1/8000_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/8000/run-1/qc_NF_C.log

This file was deleted.

145 changes: 0 additions & 145 deletions data/8002/processed/run-1/8002_NF_C.csv

This file was deleted.

145 changes: 0 additions & 145 deletions data/8002/raw/data.txt

This file was deleted.

Binary file removed data/8002/run-1/8002_NF_acc.png
Binary file not shown.
Binary file removed data/8002/run-1/8002_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/8002/run-1/qc_NF_C.log

This file was deleted.

145 changes: 0 additions & 145 deletions data/8007/processed/run-1/8007_NF_C.csv

This file was deleted.

145 changes: 0 additions & 145 deletions data/8007/raw/data.txt

This file was deleted.

Binary file removed data/8007/run-1/8007_NF_acc.png
Binary file not shown.
Binary file removed data/8007/run-1/8007_NF_rt.png
Binary file not shown.
1 change: 0 additions & 1 deletion data/8007/run-1/qc_NF_C.log

This file was deleted.

63 changes: 32 additions & 31 deletions jatosAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_met(tease):

# Get the current timestamp
current_time = datetime.now().timestamp() * 1000 # Convert to milliseconds
one_day_ago = current_time - (24 * 60 * 60 * 1000) # 24 hours ago in milliseconds
one_day_ago = current_time - 35 * (24 * 60 * 60 * 1000) # 24 hours ago in milliseconds

# Initialize an empty list to store study result IDs
study_result_ids = []
Expand Down Expand Up @@ -145,53 +145,54 @@ def get_data(study_result_ids, tease):

return txt_files

def convert_beh():

def get_next_run_dir(sub):
base_dir = f'./data/{sub}/processed'
i = 1
while os.path.exists(os.path.join(base_dir, f'run-{i}')):
i += 1
return os.path.join(base_dir, f'run-{i}')

txt = []
def convert_beh():
txt_files = []
for root, dirs, files in os.walk('./data/raw'):
for file in files:
if file.endswith(".txt"):
txt.append(os.path.join(root, file))
print(txt)
txt_files.append(os.path.join(root, file))
print(f"Found text files: {txt_files}")

count = 0
dic = {}
for b in txt:
count += 1
for idx, b in enumerate(txt_files, start=1):
tweets = []
with open(b, 'r') as file:
for line in file:
tweets.append(json.loads(line))
dic[count]= pd.json_normalize(tweets,'data')
dic[idx] = pd.json_normalize(tweets, 'data')

print(dic)
print("Data dictionaries created.")

all_paths = []
for i in dic:
df = dic[i]
for sub in np.unique(df['subject_id']):
print(f"Processing subject: {sub}")
# Filter data for this subject
sub_df = df[df['subject_id'] == sub]

# Get next run directory
run_dir = get_next_run_dir(sub)
os.makedirs(run_dir, exist_ok=True)

paths = []
print(dic)
for i in range(len(dic)):
i += 1
for sub in np.unique(dic[i]['subject_id']):
print(sub)
if os.path.exists(f'./data/{sub}/processed/run-1'):
paths.append((f'./data/{sub}/processed/run-2'+"/{0}_{1}_{2}"+".csv").format(sub,dic[i]['task'][0],dic[i]['task_vers'][0]))
elif os.path.exists(f'./data/{sub}/processed/run-2'):
paths.append((f'./data/{sub}/processed/run-1'+"/{0}_{1}_{2}"+".csv").format(sub,dic[i]['task'][0],dic[i]['task_vers'][0]))
else:
paths.append((f'./data/{sub}/processed/run-1'+"/{0}_{1}_{2}"+".csv").format(sub,dic[i]['task'][0],dic[i]['task_vers'][0]))



for path in paths:
os.makedirs(os.path.dirname(path), exist_ok=True)
dic[i].to_csv(path, index=False)
print(f"saved {path}")
# Build the CSV file path
csv_filename = f"{sub}_{sub_df['task'].iloc[0]}_{sub_df['task_vers'].iloc[0]}.csv"
csv_path = os.path.join(run_dir, csv_filename)

# Save CSV
sub_df.to_csv(csv_path, index=False)
print(f"Saved {csv_path}")

all_paths.append(csv_path)

return paths
return all_paths

def move_txt(txt_files):
dic = {}
Expand Down

0 comments on commit 737da56

Please sign in to comment.