-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_json.py
executable file
·50 lines (40 loc) · 1.07 KB
/
create_json.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 13 01:54:36 2020
@author: adrian
"""
import os
import sys
# import numpy as np
import json
#folder=os.getcwd()
folder=sys.argv[1];
subfolders = [ f.path for f in os.scandir(folder) if f.is_dir() ]
#Order folders numerically
F=[f.split('_')[-1] for f in subfolders];
NF=F;
NF = [int(x) for x in NF]
NF.sort();
NF = [str(x) for x in NF]
ind=[];
for f in NF:
ind.append(int(F.index(f)))
mylist = [subfolders[i] for i in ind]
run_consensus=[];
for tetrode in mylist:
os.chdir(tetrode)
subfolders_tetrode = [ f.name for f in os.scandir(tetrode) if f.is_dir() ]
if 'phy_AGR' in subfolders_tetrode:
run_consensus.append(1);
else :
run_consensus.append(0);
os.chdir("..")
# run_consensus=np.array(run_consensus);
# np.save('run_consensus', run_consensus)
#Save file
with open("run_consensus.json", 'w') as f:
# indent=2 is not needed but makes the file
# human-readable for more complicated data
json.dump(run_consensus, f, indent=2)
print('Json file created!')