Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
dungscout96 committed Jul 25, 2024
1 parent 9e1d8ce commit b55f163
Show file tree
Hide file tree
Showing 33 changed files with 460 additions and 1,101 deletions.
62 changes: 13 additions & 49 deletions code/plugins/reformat_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,7 @@
import shutil

# open a text file ending with .md and append a paragraph to it
def reformat_plugin(dirpath, plugin_name):
plugins_dir = '../../plugins'
index_file = os.path.join(plugins_dir, 'index.md')
shutil.copyfile(os.path.join(dirpath, 'README.md'), index_file)
with open(index_file) as f:
text = f.read()
append_text = '''---
layout: default
title: {plugin_name}
long_title: {plugin_name}
parent: Plugins
---
'''.format(plugin_name=plugin_name)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)

# open a text file ending with .md and append a paragraph to it
# Usage: python test.py <filename>.md
def append_to_file(filepath, filename, parent, output_file):
def reformat_wiki_pages(filepath, filename, parent, output_file):
with open(filepath) as f:
text = f.read()
append_text = '''---
Expand All @@ -42,53 +23,36 @@ def reformat_plugin_dir(plugin_input_dir, plugin_name, order, plugin_type='wiki'
plugin_output_dir = os.path.join('../../plugins', plugin_name)
if not os.path.exists(plugin_output_dir):
os.makedirs(plugin_output_dir)

# copy image directory from input to output dir
if os.path.exists(os.path.join(plugin_input_dir, 'images')):
shutil.copytree(os.path.join(plugin_input_dir, 'images'), os.path.join(plugin_output_dir, 'images'), dirs_exist_ok=True)

index_file = os.path.join(plugin_output_dir, 'index.md')
if plugin_type == 'wiki':
shutil.copyfile(os.path.join(plugin_input_dir, 'Home.md'), index_file)
with open(index_file) as f:
text = f.read()
append_text = '''---
shutil.copyfile(os.path.join(plugin_input_dir, 'README.md'), index_file)
with open(index_file) as f:
text = f.read()
append_text = '''---
layout: default
title: {plugin_name}
long_title: {plugin_name}
parent: Plugins
categories: plugins
has_children: true
nav_order: {order}
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
'''.format(plugin_name=plugin_name, order=order)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)

for root, dirs, files in os.walk(plugin_input_dir):
if plugin_type == 'wiki':
wiki_plugin_input_dir = plugin_input_dir + '.wiki'
for root, dirs, files in os.walk(wiki_plugin_input_dir):
for file in files:
if file.endswith('.md') and not file.startswith('index') and not file.startswith('Home'):
append_to_file(os.path.join(plugin_input_dir, file), file.strip('.md'), plugin_name, os.path.join(plugin_output_dir, file))
else:
shutil.copyfile(os.path.join(plugin_input_dir, 'README.md'), index_file)
with open(index_file) as f:
text = f.read()
append_text = '''---
layout: default
title: {plugin_name}
long_title: {plugin_name}
parent: Plugins
nav_order: {order}
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
'''.format(plugin_name=plugin_name, order=order)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)

reformat_wiki_pages(os.path.join(wiki_plugin_input_dir, file), file.strip('.md'), plugin_name, os.path.join(plugin_output_dir, file))
# main
def main():
if len(sys.argv) != 5:
Expand Down
31 changes: 21 additions & 10 deletions code/plugins/update_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ def update_repo(repo, order, plugin_type='readme'):
os.chdir(repo_path)
run_command('git pull')
else:
if plugin_type == "wiki":
run_command(f'git clone https://github.com/sccn/{repo}.wiki.git {repo_path}')
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')

if plugin_type == "wiki":
wiki_repo_path = f"{repo_path}.wiki"
if os.path.exists(wiki_repo_path):
os.chdir(wiki_repo_path)
run_command('git pull')
else:
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')
run_command(f'git clone https://github.com/sccn/{repo}.wiki.git {wiki_repo_path}')

os.chdir(current_dir)
script = 'reformat_plugin.py'
Expand All @@ -31,20 +36,26 @@ def update_repo(repo, order, plugin_type='readme'):
# if 'github' not in current directory, create it
if not os.path.exists('github'):
os.makedirs('github')
if len(sys.argv) == 0:
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
readme_plugins = ['ARfitStudio', 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
if len(sys.argv) == 1:
order = 1
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
for plugin in wiki_plugins:
update_repo(plugin, order, 'wiki')
order += 1
readme_plugins = ['ARfitStudio', 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
for plugin in readme_plugins:
update_repo(plugin, order, "readme")
order += 1
elif len(sys.argv) == 3:
elif len(sys.argv) == 2:
plugin_name = sys.argv[1]
plugin_type = sys.argv[2]
update_repo(plugin_name, 1, plugin_type)
if plugin_name not in wiki_plugins and plugin_name not in readme_plugins:
print(f"Plugin {plugin_name} not found.")
sys.exit(1)

plugin_type = 'wiki' if plugin_name in wiki_plugins else 'readme'
plugin_order = wiki_plugins.index(plugin_name) + 1 if plugin_type == 'wiki' else len(wiki_plugins) + readme_plugins.index(plugin_name) + 1

update_repo(plugin_name, plugin_order, plugin_type)
else:
print('Usage: python update_plugins.py <plugin_name> <plugin_type>')
print('Usage: python update_plugins.py <plugin_name>')
sys.exit(1)
12 changes: 12 additions & 0 deletions code/plugins/update_plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

DIRECTORY="/path/to/directory"

if [ -d "$DIRECTORY" ]; then
# Directory exists, pull changes
cd "$DIRECTORY"
git pull
else
# Directory doesn't exist, clone from GitHub
git clone https://github.com/username/repository.git "$DIRECTORY"
fi
1 change: 1 addition & 0 deletions plugins/ARfitStudio/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: default
title: ARfitStudio
long_title: ARfitStudio
parent: Plugins
has_children: true
nav_order: 7
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ARfitStudio).
Expand Down
1 change: 1 addition & 0 deletions plugins/EEG-BIDS/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: default
title: EEG-BIDS
long_title: EEG-BIDS
parent: Plugins
has_children: true
nav_order: 9
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/EEG-BIDS).
Expand Down
1 change: 1 addition & 0 deletions plugins/ICLabel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: default
title: ICLabel
long_title: ICLabel
parent: Plugins
has_children: true
nav_order: 13
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ICLabel).
Expand Down
120 changes: 16 additions & 104 deletions plugins/NFT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,31 @@ layout: default
title: NFT
long_title: NFT
parent: Plugins
categories: plugins
has_children: true
nav_order: 3
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NFT).

### Open Source Matlab Toolbox for Neuroelectromagnetic Forward Head Modeling
Pre-compiled binaries for the following 3rd party programs are distributed
within the NFT toolbox for convinience of the users. The binaries are compiled
for 32 and 64 bit Linux distributions.

![right](NFTsmall.jpg "wikilink")
All of these programs have opensource licenses and provide full source-code.
Please visit home-pages of individual programs for more information on usage,
source-code and license information.

### What is NFT?
ASC: Adaptive skeleton climbing
homepage: http://www.cse.cuhk.edu.hk/~ttwong/papers/asc/asc.html

Neuroelectromagnetic Forward Modeling Toolbox (NFT) is a MATLAB toolbox
for generating realistic head models from available data (MRI and/or
electrode locations) and for computing numerical solutions for solving
the forward problem of electromagnetic source imaging (Zeynep Akalin
Acar & S. Makeig, 2010). NFT includes tools for segmenting scalp, skull,
cerebrospinal fluid (CSF) and brain tissues from T1-weighted magnetic
resonance (MR) images. The Boundary Element Method (BEM) is used for the
numerical solution of the forward problem. After extracting the
segmented tissue volumes, surface BEM meshes may be generated. When a
subject MR image is not available, a template head model may be warped
to 3-D measured electrode locations to obtain an individualized BEM head
model. Toolbox functions can be called from either a graphic user
interface (gui) compatible with EEGLAB (sccn.ucsd.edu/eeglab), or from
the MATLAB command line. Function help messages and a user tutorial are
included. The toolbox is freely available for noncommercial use and open
source development under the GNU Public License.
QSLIM: Quadric-based surface simplification
homepage: http://mgarland.org/software/qslim.html

### Why NFT?
BEM_MATRIX: The METU-FP Toolkit
homepage: http://www.eee.metu.edu.tr/metu-fp/

The NFT is released under an open source license, allowing researchers
to contribute and improve on the work for the benefit of the
neuroscience community. By bringing together advanced head modeling and
forward problem solution methods and implementations within an easy to
use toolbox, the NFT complements EEGLAB, an open source toolkit under
active development. Combined, NFT and EEGLAB form a freely available EEG
(and in future, MEG) source imaging solution.
PROCMESH: Mesh correction and processing. No web page yet. Please contact NFT developers for source code.

The toolbox implements the major aspects of realistic head modeling and
forward problem solution from available subject information:
MATITK: Matlab and ITK
homepage: http://www.sfu.ca/~vwchu/matitk.html

1. Segmentation of T1-weighted MR images: The preferred method of
generating a realistic head model is to use a 3-D whole-head
structural MR image of the subject's head. The toolbox can generate
a segmentation of scalp, skull, CSF and brain tissues from a
T1-weighted image.

2. High-quality BEM meshes: The accuracy of the BEM solution depends on
the quality of the underlying mesh that models tissue
conductance-change boundaries. To avoid numerical instabilities, the
mesh must be topologically correct with no self-intersections. It
should represent the surface using high-quality elements while
keeping the number of elements as small as possible. The NFT can
create high-quality linear surface BEM meshes from the head
segmentation.

3. Warping a template head model: When a whole-head structural MR image
of the subject is not available, a semi-realistic head model can be
generated by warping a standard template BEM mesh to the digitized
electrode coordinates (instead of vice versa).

4. Registration of electrode positions with the BEM mesh: The digitized
electrode locations and the BEM mesh must be aligned to compute
accurate forward problem solutions and lead field matrices.

5. Accurate high-performance forward problem solution: The NFT uses a
high-performance BEM implementation from the open source METU-FP
Toolkit for bioelectromagnetic field computations.

### Required Resources

Matlab 7.0 or later running under any operating system (Linux, Windows).
A large amount of RAM is useful - at least 2 GB (4-8 GB recommended for
forward problem solution of realistic head models). The Matlab Image
Processing toolbox is also recommended.

### NFT Reference Paper

Zeynep Akalin Acar & Scott Makeig, [Neuroelectromagnetic Forward Head
Modeling
Toolbox](http://sccn.ucsd.edu/%7Escott/pdf/Zeynep_NFT_Toolbox10.pdf).
<em>Journal of Neuroscience Methods</em>, 2010

Download
--------

To download the NFT, go to the [NFT download
page](http://sccn.ucsd.edu/nft/).

NFT User's Manual
-----------------

- [Chapter 01: Getting Started with NFT](Chapter_01_Getting_Started_with_NFT "wikilink")
- [Chapter 02: Head Modeling from MR Images](Chapter_02_Head_Modeling_from_MR_Images "wikilink")
- [Chapter 03: Forward Model Generation](Chapter_03_Forward_Model_Generation "wikilink")
- [Chapter 04: NFT Examples](Chapter_04_NFT_Examples "wikilink")
- [Chapter 05: NFT Commands and Functions](Chapter_05_NFT_Commands_and_Functions "wikilink")
- [Appendix A: BEM Mesh Format](NFT_Appendix_A)
- [Appendix B: Function Reference](NFT_Appendix_B)
- [Appendix C: Effect of brain-to-skull conductivity ratio estimate](NFT_Appendix_C)


- [Click here to download the NFT User Manual as a PDF book](NFT_Tutorial.pdf)

<div align=right>

Creation and documentation by:

Zeynep Akalin Acar

Project Scientist

[email protected]

</div>
Note: The MATITK shared libraries are installed in the 'mfiles' directory.
1 change: 1 addition & 0 deletions plugins/NIMA/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: default
title: NIMA
long_title: NIMA
parent: Plugins
has_children: true
nav_order: 26
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NIMA).
Expand Down
Loading

0 comments on commit b55f163

Please sign in to comment.