-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #992 from neuropsychology/dev
0.2.10
- Loading branch information
Showing
52 changed files
with
933 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Codebook | ||
======== | ||
|
||
Here you can download the complete codebook which details the variables that you can compute using the NeuroKit package. | ||
|
||
.. raw:: html | ||
|
||
<div style="text-align: center;"> | ||
<a href="_static/neurokit_codebook.csv" download="neurokit_codebook.csv"> | ||
<button style="background-color: #4CAF50; color: white; padding: 10px 20px; margin: 10px; border: none; cursor: pointer; width: 50%;">Download Codebook</button> | ||
</a> | ||
</div> | ||
|
||
This codebook contains detailed descriptions of all variables, their descriptions, and additional metadata. | ||
|
||
|
||
Codebook Table | ||
============== | ||
|
||
.. raw:: html | ||
|
||
<style> | ||
#csvDataTable { | ||
width: 100%; | ||
border-collapse: collapse; | ||
.. background-color: #f8f8f8; | ||
color: white; | ||
} | ||
#csvDataTable th, #csvDataTable td { | ||
padding: 8px 12px; | ||
border: 1px solid #ccc; | ||
text-align: left; | ||
} | ||
</style> | ||
|
||
<div id="csv-table"> | ||
<table id="csvDataTable"> | ||
</table> | ||
</div> | ||
|
||
<script> | ||
function parseCSVLine(text) { | ||
const cols = []; | ||
let col = ''; | ||
let insideQuotes = false; | ||
for (let i = 0; i < text.length; i++) { | ||
const char = text[i]; | ||
if (insideQuotes && char === '"' && text[i + 1] == '"') { | ||
i++; | ||
col += char; | ||
continue; | ||
} | ||
if (char === '"' && text[i - 1] !== '\\') { | ||
insideQuotes = !insideQuotes; | ||
continue; | ||
} | ||
if (char === ',' && !insideQuotes) { | ||
cols.push(col); | ||
col = ''; | ||
} else { | ||
col += char; | ||
} | ||
} | ||
cols.push(col); | ||
return cols.map(field => field.replace(/""/g, '"')); // Replace escaped quotes | ||
} | ||
document.addEventListener("DOMContentLoaded", function() { | ||
fetch('_static/neurokit_codebook.csv') | ||
.then(response => response.text()) | ||
.then(csv => { | ||
let lines = csv.trim().split('\n'); | ||
let html = '<tr><th>' + parseCSVLine(lines[0]).join('</th><th>') + '</th></tr>'; | ||
for (let i = 1; i < lines.length; i++) { | ||
html += '<tr><td>' + parseCSVLine(lines[i]).join('</td><td>') + '</td></tr>'; | ||
} | ||
document.getElementById('csvDataTable').innerHTML = html; | ||
}) | ||
.catch(error => console.error('Error loading the CSV file:', error)); | ||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import csv | ||
import os | ||
from docutils import nodes | ||
from docutils.parsers.rst import Directive | ||
|
||
abrv_to_sensor = { | ||
"ecg": "Electrocardiography", | ||
"eda": "Electrodermal Activity", | ||
"rsp": "Respiration", | ||
"ppg": "Photoplethysmography", | ||
"eeg": "Electroencephalography", | ||
"emg": "Electromyography", | ||
"eog": "Electrooculography", | ||
"hrv": "Heart Rate Variability", | ||
} | ||
|
||
class CSVDocDirective(Directive): | ||
has_content = True | ||
|
||
def run(self): | ||
# Codebook path | ||
csv_file_path = os.path.join(os.path.abspath('.'), "_static", "neurokit_codebook.csv") | ||
|
||
# Check if the file exists and whether it is empty | ||
file_empty = not os.path.exists(csv_file_path) or os.stat(csv_file_path).st_size == 0 | ||
|
||
# List to hold bullet list nodes | ||
bullet_list = nodes.bullet_list() | ||
|
||
doc_source_name = self.state.document.settings.env.temp_data.get('object')[0] | ||
|
||
maybe_sensor = doc_source_name.split("_") | ||
doc_sensor = "N/A" | ||
|
||
if len(maybe_sensor) > 0 and maybe_sensor[0] in abrv_to_sensor: | ||
doc_sensor = abrv_to_sensor[maybe_sensor[0]] | ||
|
||
# Open the CSV file and append the content | ||
with open(csv_file_path, 'a', newline='', encoding='utf-8') as csvfile: | ||
writer = csv.writer(csvfile) | ||
|
||
# Write header if file is newly created or empty | ||
if file_empty: | ||
header = ['Field Name', 'Field Description', 'Field Category', 'Source File Name'] | ||
writer.writerow(header) | ||
|
||
# Iterate through rows: add them to the codebook and add them to the page | ||
for line in self.content: | ||
|
||
fields = line.split('|') | ||
|
||
# Remove multi line long space sequences | ||
for fid in range(len(fields)): | ||
fields[fid] = " ".join(fields[fid].split()) | ||
|
||
# Append last fields | ||
fields.append(doc_sensor) | ||
fields.append(f"{doc_source_name}.py") | ||
|
||
# Write to CSV | ||
writer.writerow([field.strip() for field in fields]) | ||
|
||
|
||
# Prepare the documentation stylization | ||
if len(fields) >= 2: | ||
paragraph = nodes.paragraph() | ||
|
||
# Create backtick formatting around the field name | ||
field1 = nodes.literal('', '', nodes.Text(fields[0].strip())) | ||
|
||
# Add the remainder of the line | ||
colon_space = nodes.Text(': ') | ||
field2 = nodes.Text(fields[1].strip()) | ||
|
||
# Add all the parts to the paragraph | ||
paragraph += field1 | ||
paragraph += colon_space | ||
paragraph += field2 | ||
|
||
# Add to the bullet point list | ||
list_item = nodes.list_item() | ||
list_item += paragraph | ||
bullet_list += list_item | ||
|
||
return [bullet_list] | ||
|
||
|
||
def setup(app): | ||
app.add_directive("codebookadd", CSVDocDirective) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
from .video import * | ||
|
||
# Info | ||
__version__ = "0.2.9" | ||
__version__ = "0.2.10" | ||
|
||
|
||
# Maintainer info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.