Skip to content

Commit 89c329a

Browse files
committed
use json mechanism
1 parent a2e48fd commit 89c329a

File tree

29 files changed

+225
-45
lines changed

29 files changed

+225
-45
lines changed

code/plugins/construct_plugin_json.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import json
2+
ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
3+
naming = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
4+
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica', 'LIMO']
5+
readme_plugins = list(set(ordering) - set(wiki_plugins))
6+
7+
plugin_json = []
8+
for plugin in ordering:
9+
ptype = 'wiki' if plugin in wiki_plugins else 'readme'
10+
link = f'https://github.com/sccn/{plugin}'
11+
plugin_json.append({'plugin': plugin,
12+
'name': naming[ordering.index(plugin)],
13+
'type': ptype,
14+
'link': link})
15+
16+
with open('plugins.json', 'w') as out:
17+
json.dump(plugin_json, out, indent=2)

code/plugins/plugins.json

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
[
2+
{
3+
"plugin": "ICLabel",
4+
"name": "ICLabel",
5+
"type": "readme",
6+
"link": "https://github.com/sccn/ICLabel"
7+
},
8+
{
9+
"plugin": "dipfit",
10+
"name": "dipfit",
11+
"type": "readme",
12+
"link": "https://github.com/sccn/dipfit"
13+
},
14+
{
15+
"plugin": "EEG-BIDS",
16+
"name": "EEG-BIDS",
17+
"type": "wiki",
18+
"link": "https://github.com/sccn/EEG-BIDS"
19+
},
20+
{
21+
"plugin": "roiconnect",
22+
"name": "roiconnect",
23+
"type": "readme",
24+
"link": "https://github.com/sccn/roiconnect"
25+
},
26+
{
27+
"plugin": "amica",
28+
"name": "amica",
29+
"type": "wiki",
30+
"link": "https://github.com/sccn/amica"
31+
},
32+
{
33+
"plugin": "cleanline",
34+
"name": "cleanline",
35+
"type": "readme",
36+
"link": "https://github.com/sccn/cleanline"
37+
},
38+
{
39+
"plugin": "clean_rawdata",
40+
"name": "clean_rawdata",
41+
"type": "wiki",
42+
"link": "https://github.com/sccn/clean_rawdata"
43+
},
44+
{
45+
"plugin": "SIFT",
46+
"name": "SIFT",
47+
"type": "wiki",
48+
"link": "https://github.com/sccn/SIFT"
49+
},
50+
{
51+
"plugin": "zapline-plus",
52+
"name": "zapline-plus",
53+
"type": "readme",
54+
"link": "https://github.com/sccn/zapline-plus"
55+
},
56+
{
57+
"plugin": "eegstats",
58+
"name": "eegstats",
59+
"type": "readme",
60+
"link": "https://github.com/sccn/eegstats"
61+
},
62+
{
63+
"plugin": "trimOutlier",
64+
"name": "trimOutlier",
65+
"type": "readme",
66+
"link": "https://github.com/sccn/trimOutlier"
67+
},
68+
{
69+
"plugin": "fMRIb",
70+
"name": "fMRIb",
71+
"type": "readme",
72+
"link": "https://github.com/sccn/fMRIb"
73+
},
74+
{
75+
"plugin": "imat",
76+
"name": "imat",
77+
"type": "readme",
78+
"link": "https://github.com/sccn/imat"
79+
},
80+
{
81+
"plugin": "nwbio",
82+
"name": "nwbio",
83+
"type": "readme",
84+
"link": "https://github.com/sccn/nwbio"
85+
},
86+
{
87+
"plugin": "NIMA",
88+
"name": "NIMA",
89+
"type": "readme",
90+
"link": "https://github.com/sccn/NIMA"
91+
},
92+
{
93+
"plugin": "PACT",
94+
"name": "PACT",
95+
"type": "readme",
96+
"link": "https://github.com/sccn/PACT"
97+
},
98+
{
99+
"plugin": "NFT",
100+
"name": "NFT",
101+
"type": "wiki",
102+
"link": "https://github.com/sccn/NFT"
103+
},
104+
{
105+
"plugin": "PACTools",
106+
"name": "PACTools",
107+
"type": "readme",
108+
"link": "https://github.com/sccn/PACTools"
109+
},
110+
{
111+
"plugin": "ARfitStudio",
112+
"name": "ARfitStudio",
113+
"type": "readme",
114+
"link": "https://github.com/sccn/ARfitStudio"
115+
},
116+
{
117+
"plugin": "PowPowCAT",
118+
"name": "PowPowCAT",
119+
"type": "readme",
120+
"link": "https://github.com/sccn/PowPowCAT"
121+
},
122+
{
123+
"plugin": "relica",
124+
"name": "relica",
125+
"type": "readme",
126+
"link": "https://github.com/sccn/relica"
127+
},
128+
{
129+
"plugin": "std_dipoleDensity",
130+
"name": "std_dipoleDensity",
131+
"type": "readme",
132+
"link": "https://github.com/sccn/std_dipoleDensity"
133+
},
134+
{
135+
"plugin": "viewprops",
136+
"name": "viewprops",
137+
"type": "readme",
138+
"link": "https://github.com/sccn/viewprops"
139+
},
140+
{
141+
"plugin": "firfilt",
142+
"name": "firfilt",
143+
"type": "readme",
144+
"link": "https://github.com/sccn/firfilt"
145+
},
146+
{
147+
"plugin": "groupSIFT",
148+
"name": "groupSIFT",
149+
"type": "readme",
150+
"link": "https://github.com/sccn/groupSIFT"
151+
},
152+
{
153+
"plugin": "get_chanlocs",
154+
"name": "get_chanlocs",
155+
"type": "wiki",
156+
"link": "https://github.com/sccn/get_chanlocs"
157+
},
158+
{
159+
"plugin": "nsgportal",
160+
"name": "nsgportal",
161+
"type": "wiki",
162+
"link": "https://github.com/sccn/nsgportal"
163+
}
164+
]

code/plugins/reformat_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def reformat_wiki_pages(filepath, filename, parent, output_file, wiki_input_dir=
1212
grand_parent: Plugins
1313
'''.format(filename=filename, parent=parent)
1414

15-
if parent == "nsgportal":
15+
if parent in ["nsgportal", "LIMO"]:
1616
pages = []
1717
# load _Sidebar.md and extract all links from markdown file
1818
with open(os.path.join(wiki_input_dir, '_Sidebar.md')) as f:
1919
lines = f.readlines()
2020
for line in lines:
21-
if line.startswith('*'):
21+
if '(' in line:
2222
# extract text between square brackets
2323
page = line[line.find('(')+1:line.find(')')]
2424
pages.append(page)

code/plugins/update_plugins.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import os
22
import subprocess
33
import sys
4+
import json
45

56
def run_command(command):
67
result = subprocess.run(command, shell=True, capture_output=False, text=True)
78
if result.returncode != 0:
89
print(f"Command failed: {command}\nError: {result.stderr}")
910
return result
1011

11-
def update_repo(repo, order, plugin_type='readme'):
12+
def update_repo(repo, order, plugin_type='readme', plugin_link="https://github.com/sccn"):
1213
print(f"Updating {repo}...")
1314
current_dir = os.getcwd()
1415
repo_path = os.path.join(current_dir, 'github', repo)
@@ -17,15 +18,15 @@ def update_repo(repo, order, plugin_type='readme'):
1718
os.chdir(repo_path)
1819
run_command('git pull')
1920
else:
20-
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')
21+
run_command(f'git clone {plugin_link}.git {repo_path}')
2122

2223
if plugin_type == "wiki":
2324
wiki_repo_path = f"{repo_path}.wiki"
2425
if os.path.exists(wiki_repo_path):
2526
os.chdir(wiki_repo_path)
2627
run_command('git pull')
2728
else:
28-
run_command(f'git clone https://github.com/sccn/{repo}.wiki.git {wiki_repo_path}')
29+
run_command(f'git clone {plugin_link}.wiki.git {wiki_repo_path}')
2930

3031
os.chdir(current_dir)
3132
script = 'reformat_plugin.py'
@@ -36,28 +37,26 @@ def update_repo(repo, order, plugin_type='readme'):
3637
# if 'github' not in current directory, create it
3738
if not os.path.exists('github'):
3839
os.makedirs('github')
39-
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica']
40-
readme_plugins = ['ARfitStudio', 'roiconnect', 'trimOutlier', 'PACT', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
41-
ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
40+
41+
if not os.path.exists('plugins.json'):
42+
print('Error: plugins.json not found.')
43+
sys.exit(1)
44+
plugin_info = json.load(open('plugins.json'))
45+
plugins = [plugin['plugin'] for plugin in plugin_info]
46+
# wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica', 'LIMO']
47+
# readme_plugins = ['ARfitStudio', 'roiconnect', 'trimOutlier', 'PACT', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
48+
# ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
4249

4350
if len(sys.argv) == 1:
44-
order = 1
45-
for plugin in wiki_plugins:
46-
update_repo(plugin, order, 'wiki')
47-
order += 1
48-
for plugin in readme_plugins:
49-
update_repo(plugin, order, "readme")
50-
order += 1
51+
for plugin in plugin_info:
52+
update_repo(plugin['plugin'], plugins.index(plugin['plugin']), plugin['type'], plugin['link'])
5153
elif len(sys.argv) == 2:
5254
plugin_name = sys.argv[1]
53-
if plugin_name not in wiki_plugins and plugin_name not in readme_plugins:
55+
if plugin_name not in plugins:
5456
print(f"Plugin {plugin_name} not found.")
5557
sys.exit(1)
56-
57-
plugin_type = 'wiki' if plugin_name in wiki_plugins else 'readme'
58-
plugin_order = ordering.index(plugin_name) + 1
59-
60-
update_repo(plugin_name, plugin_order, plugin_type)
58+
plugin = plugin_info[plugins.index(plugin_name)]
59+
update_repo(plugin['plugin'], plugins.index(plugin['plugin']), plugin['type'], plugin['link'])
6160
else:
6261
print('Usage: python update_plugins.py <plugin_name>')
6362
sys.exit(1)

code/plugins/update_plugins.sh

100644100755
File mode changed.

plugins/ARfitStudio/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: ARfitStudio
44
long_title: ARfitStudio
55
parent: Plugins
66
has_children: true
7-
nav_order: 8
7+
nav_order: 18
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ARfitStudio).
1010

plugins/EEG-BIDS/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: EEG-BIDS
44
long_title: EEG-BIDS
55
parent: Plugins
66
has_children: true
7-
nav_order: 4
7+
nav_order: 2
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/EEG-BIDS).
1010

plugins/ICLabel/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: ICLabel
44
long_title: ICLabel
55
parent: Plugins
66
has_children: true
7-
nav_order: 14
7+
nav_order: 0
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ICLabel).
1010

plugins/NFT/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: NFT
44
long_title: NFT
55
parent: Plugins
66
has_children: true
7-
nav_order: 3
7+
nav_order: 16
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NFT).
1010

plugins/NIMA/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: NIMA
44
long_title: NIMA
55
parent: Plugins
66
has_children: true
7-
nav_order: 26
7+
nav_order: 14
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NIMA).
1010

plugins/PACT/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: PACT
44
long_title: PACT
55
parent: Plugins
66
has_children: true
7-
nav_order: 11
7+
nav_order: 15
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PACT).
1010

plugins/PACTools/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: PACTools
44
long_title: PACTools
55
parent: Plugins
66
has_children: true
7-
nav_order: 18
7+
nav_order: 17
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PACTools).
1010

plugins/PowPowCAT/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: PowPowCAT
44
long_title: PowPowCAT
55
parent: Plugins
66
has_children: true
7-
nav_order: 17
7+
nav_order: 19
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PowPowCAT).
1010

plugins/SIFT/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: SIFT
44
long_title: SIFT
55
parent: Plugins
66
has_children: true
7-
nav_order: 1
7+
nav_order: 7
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/SIFT).
1010

plugins/amica/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: amica
44
long_title: amica
55
parent: Plugins
66
has_children: true
7-
nav_order: 7
7+
nav_order: 4
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/amica).
1010

plugins/cleanline/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: cleanline
44
long_title: cleanline
55
parent: Plugins
66
has_children: true
7-
nav_order: 25
7+
nav_order: 5
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/cleanline).
1010

plugins/dipfit/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: dipfit
44
long_title: dipfit
55
parent: Plugins
66
has_children: true
7-
nav_order: 15
7+
nav_order: 1
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/dipfit).
1010

plugins/eegstats/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: eegstats
44
long_title: eegstats
55
parent: Plugins
66
has_children: true
7-
nav_order: 16
7+
nav_order: 9
88
---
99
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/eegstats).
1010

0 commit comments

Comments
 (0)