Skip to content

Commit

Permalink
Phase 2 - additional features et layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Jun 28, 2021
1 parent 21d715e commit baf60f6
Show file tree
Hide file tree
Showing 25 changed files with 1,762 additions and 630 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"globalReturn": false
}
},
"extends": ["eslint:recommended", "plugin:react/recommended", "google"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"google"
],
"rules": {
"max-len": ["error", {
"code": 80,
Expand All @@ -35,7 +39,9 @@
"require-jsdoc": "error",
"no-console": ["warn", {
"allow": ["info", "warn", "error"]
}]
}],
"react/jsx-curly-brace-presence": "warn",
"react/jsx-key": "warn"
},
"globals": {
"React": true,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"lint-staged": "^11.0.0",
"react-datepicker": "^4.1.1",
"react-switch": "^6.0.0",
"wait-on": "^5.3.0"
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions public/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ contextBridge.exposeInMainWorld('myAPI', {
const {dialog} = require('@electron/remote');
return dialog;
},
visitBIDS: () => {
const {shell} = require('electron');
shell.openExternal('https://bids.neuroimaging.io');
},
visitGitHub: () => {
const {shell} = require('electron');
shell.openExternal('https://github.com/aces/eeg2bids');
},
visitIssues: () => {
const {shell} = require('electron');
shell.openExternal('https://github.com/aces/eeg2bids/issues');
},
visitMNE: () => {
const {shell} = require('electron');
shell.openExternal('https://mne.tools/mne-bids/');
Expand Down
67 changes: 52 additions & 15 deletions python/eeg2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
from eventlet import tpool
import socketio
from python.libs import iEEG
from python.libs.Modifier import Modifier
from python.libs import BIDS

from python.libs.loris_api import LorisAPI
import csv

# Create socket listener.
sio = socketio.Server(async_mode='eventlet', cors_allowed_origins=[])
app = socketio.WSGIApp(sio)
loris_api = LorisAPI()

# EEG2BIDS Wizard version
appVersion = '1.0.0'
Expand Down Expand Up @@ -44,6 +47,22 @@ def tarfile_bids(sid, data):
sio.emit('response', send)


@sio.event
def get_loris_sites(sid):
sio.emit('loris_sites', loris_api.get_sites())

@sio.event
def get_loris_projects(sid):
sio.emit('loris_projects', loris_api.get_projects())

@sio.event
def get_loris_subprojects(sid, project):
sio.emit('loris_subprojects', loris_api.get_subprojects(project))

@sio.event
def get_loris_visits(sid, project):
sio.emit('loris_visits', loris_api.get_visits(project))

@sio.event
def ieeg_get_header(sid, data):
# data = { file_path: 'path to iEEG file' }
Expand All @@ -59,35 +78,53 @@ def ieeg_get_header(sid, data):
response = {
'error': 'Failed to retrieve EDF header information',
}
sio.emit('response', response)
sio.emit('edf_header', response)

@sio.event
def get_metadata(sid, data):
# data = { file_path: 'path to metadata file' }
print('metadata file:', data)

if not data['file_path']:
print('No file path found.')
response = {
'error': 'No file path found.',
}
else :
try:
with open(data['file_path']) as fd:
reader = csv.DictReader(fd, delimiter="\t", quotechar='"')
response = {
'metadata': {rows['Field']:rows['Value'] for rows in reader}
}
except IOError:
print("Could not read the metadata file.")
response = {
'error': 'No file path found.',
}

sio.emit('metadata', response)

def edf_to_bids_thread(data):
print('data is ')
print(data)
error_messages = []
if not data['file_path']:
error_messages.append('The file.edf to convert is missing.')
if not data['file_paths']:
error_messages.append('No .edf file(s) to convert.')
if not data['bids_directory']:
error_messages.append('The BIDS output directory is missing.')
if not data['site_id']:
error_messages.append('The LORIS SiteID is missing.')
if not data['project_id']:
error_messages.append('The LORIS ProjectID is missing.')
if not data['sub_project_id']:
error_messages.append('The LORIS SubProjectID is missing.')
if not data['visit_label']:
if not data['session']:
error_messages.append('The LORIS Visit Label is missing.')

if not error_messages:
time = iEEG.Time()
data['output_time'] = 'output-' + time.latest_output
iEEG.Converter(data) # EDF to BIDS format.

# store subject_id for iEEG.Modifier
# store subject_id for Modifier
data['subject_id'] = iEEG.Converter.m_info['subject_id']
data['appVersion'] = appVersion
iEEG.Modifier(data, sio) # Modifies data of BIDS format
Modifier(data) # Modifies data of BIDS format
response = {
'output_time': data['output_time']
}
Expand All @@ -100,9 +137,9 @@ def edf_to_bids_thread(data):

@sio.event
def edf_to_bids(sid, data):
# data = { file_path: '', bids_directory: '', read_only: false,
# data = { file_paths: [], bids_directory: '', read_only: false,
# events_tsv: '', line_freq: '', site_id: '', project_id: '',
# sub_project_id: '', visit_label: '', subject_id: ''}
# sub_project_id: '', session: '', subject_id: ''}
print('edf_to_bids: ', data)
response = eventlet.tpool.execute(edf_to_bids_thread, data)
print(response)
Expand Down
9 changes: 9 additions & 0 deletions python/libs/BIDS.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ def __init__(self, data):
validator = BIDSValidator()
for path, dirs, files in os.walk(start_path):
for filename in files:
if filename == '.bidsignore':
continue

if filename.endswith('_annotations.tsv'):
continue

if filename.endswith('_annotations.json'):
continue

temp = os.path.join(path, filename)
file_paths.append(temp[len(start_path):len(temp)])
result.append(validator.is_bids(temp[len(start_path):len(temp)]))
Expand Down
Loading

0 comments on commit baf60f6

Please sign in to comment.