Skip to content

Commit

Permalink
Merge pull request #1 from Zanderlabs/change_names
Browse files Browse the repository at this point in the history
Change name to IXR-Suite
  • Loading branch information
agchitu committed May 23, 2023
2 parents 4deec16 + f3d5416 commit 0b98c31
Show file tree
Hide file tree
Showing 20 changed files with 748 additions and 41 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -72,6 +73,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -83,6 +85,9 @@ ipython_config.py

# pyenv
.python-version
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand All @@ -92,6 +97,22 @@ ipython_config.py
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
Expand Down Expand Up @@ -137,3 +158,15 @@ dmypy.json
# experiments
exp/
experiments/
# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bin/z_flow → bin/ixr_flow
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from z_flow import ZFlow
from ixr_flow import IXRFlow

if __name__ == '__main__':
ZFlow().run()
IXRFlow().run()
4 changes: 2 additions & 2 deletions bin/z_suite → bin/ixr_suite
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import tkinter as tk

from z_flow import ZSuite
from ixr_flow import IXRSuite

if __name__ == "__main__":
root = tk.Tk()
app = ZSuite(root)
app = IXRSuite(root)
root.mainloop()
2 changes: 2 additions & 0 deletions ixr_flow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ixr_flow.ixr_flow import IXRFlow
from ixr_flow.ixr_suite import IXRSuite
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions ixr_flow/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .ixrdashboard import IXRDashboard
from .tooltip import ToolTip
12 changes: 6 additions & 6 deletions z_flow/gui/zdashboard.py → ixr_flow/gui/ixrdashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Channel:
display: bool


class ZDashboard(Thread):
class IXRDashboard(Thread):
"""Class that implements a basic dashboard to
display EEG, PPG, motion, brain waves, and z-flow metrics.
display EEG, PPG, motion, brain waves, and ixr-flow metrics.
It also pushes computed power metrics over LSL.
Expand Down Expand Up @@ -84,14 +84,14 @@ def __init__(self, board_shim: BoardShim, reference: str = 'mean', display_ref:
# LSL stream
name = 'BrainPower'
logging.info(f"Starting '{name}' Power Metric stream.")
info_transmit = StreamInfo(name=name, type='Z-metric', channel_count=1,
channel_format=cf_double64, source_id='zflow_transmit_power')
info_transmit = StreamInfo(name=name, type='IXR-metric', channel_count=1,
channel_format=cf_double64, source_id='ixrflow_transmit_power')
self.outlet_transmit = StreamOutlet(info_transmit)
logging.info(f"'{self.outlet_transmit.get_info().name()}' Power Metric stream started.")

def run(self):
self.app = QtGui.QApplication([])
self.win = pg.GraphicsWindow(title='Z-flow', size=(1500, 1000))
self.win = pg.GraphicsWindow(title='IXR-flow', size=(1500, 1000))

self._init_pens()
self._init_timeseries()
Expand All @@ -106,7 +106,7 @@ def run(self):

def set_parameters(self, calib_length: int = 600, power_length: int = 10, scale: float = 1.5,
offset: float = 0.5, head_impact: float = 0.2) -> None:
"""Allows setting z-flow metrics. Is called with defaults on object initialization.
"""Allows setting ixr-flow metrics. Is called with defaults on object initialization.
:param calib_length: Calibration length, defaults to 600
:type calib_length: int, optional
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions z_flow/z_flow.py → ixr_flow/ixr_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from brainflow.board_shim import BoardIds, BoardShim, BrainFlowInputParams

from z_flow.board import BrainFlowHandler
from z_flow.lsl_utility import BfLslDataPublisher, LslEventListener, LslLogger
from z_flow.gui import ZDashboard
from ixr_flow.board import BrainFlowHandler
from ixr_flow.lsl_utility import BfLslDataPublisher, LslEventListener, LslLogger
from ixr_flow.gui import IXRDashboard


class ZFlow:
class IXRFlow:
def __init__(self, args: list[str] | None = None) -> None:
self.board_shim = None
self.classifiers = {}
Expand All @@ -37,7 +37,7 @@ def __init__(self, args: list[str] | None = None) -> None:
logging.FileHandler(self.args.log_file),
]
if self.args.lsl_log:
handlers.append(LslLogger('z-flow-log'))
handlers.append(LslLogger('ixr-flow-log'))
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] [%(threadName)s] [%(levelname)s] %(message)s",
Expand All @@ -60,7 +60,7 @@ def run(self) -> None:
brainflow_thread.start()

logging.info("Starting dashboard.")
dashboard_thread = ZDashboard(board_shim, self.args.reference, self.args.display_ref,
dashboard_thread = IXRDashboard(board_shim, self.args.reference, self.args.display_ref,
thread_name="graph_1", thread_daemon=False)
dashboard_thread.set_parameters(self.args.calib_length, self.args.power_length,
self.args.scale, self.args.offset, self.args.head_impact)
Expand All @@ -75,10 +75,10 @@ def run(self) -> None:
lsl_data_pusher_thread = BfLslDataPublisher(board_shim, push_full_vec=self.args.push_full_vec, stay_alive=stay_alive, thread_daemon=False)
lsl_data_pusher_thread.start()

logging.info("Running Z-flow as long as the dashboard is open, please close the dashboard to close Z-flow.")
logging.info("Running IXR-flow as long as the dashboard is open, please close the dashboard to close IXR-flow.")
dashboard_thread.join()

logging.info("Z-flow dashboard closed, terminating all child threads.")
logging.info("IXR-flow dashboard closed, terminating all child threads.")
stay_alive.clear()
lsl_event_listener_thread.join()
lsl_data_pusher_thread.join()
Expand All @@ -88,7 +88,7 @@ def run(self) -> None:

@staticmethod
def create_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser("Z-flow")
parser = argparse.ArgumentParser("IXR-flow")

# Brainflow arguments
# use docs to check which parameters are required for specific board, for muse products, see specifically:
Expand All @@ -108,16 +108,16 @@ def create_parser() -> argparse.ArgumentParser:
parser.add_argument('--display-ref', action='store_true',
help="Displays signal of the reference electrode(s) on the dashboard. ")

# Z-flow Dashboard arguments
# IXR-flow Dashboard arguments
parser.add_argument('--calib-length', type=int, default=600, help='Calibration length, defaults to 600')
parser.add_argument('--power-length', type=int, default=10, help='Power length, defaults to 10')
parser.add_argument('--scale', type=float, default=1.5, help='Scale, defaults to 1.5')
parser.add_argument('--offset', type=float, default=0.5, help='Offset, defaults to 0.5')
parser.add_argument('--head-impact', type=float, default=0.2, help='Head impact, defaults to 0.2')

# Z-flow utility arguments
parser.add_argument('--log-file', type=str, default='z_flow.log', required=False,
help="The file name where the Z-flow will write it's log's to. "
# IXR-flow utility arguments
parser.add_argument('--log-file', type=str, default='ixr_flow.log', required=False,
help="The file name where the IXR-flow will write it's log's to. "
"If a relative path is given it is relative to the current working directory.")
parser.add_argument('--log-brainflow', type=bool, default=False, required=False,
help="Also write Brainflow logs to log file.")
Expand Down
16 changes: 8 additions & 8 deletions z_flow/z_suite.py → ixr_flow/ixr_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import tkinter.font as tkfont
import tkinter.ttk as ttk

from z_flow import ZFlow
from z_flow.gui import ToolTip
from ixr_flow import IXRFlow
from ixr_flow.gui import ToolTip


class ZSuite():
class IXRSuite():
def __init__(self, root) -> None:
# setting title
root.title("Z-suite mini v0.2")
root.title("IXR Suite")
# setting window size
root.configure(width=400, height=600)
root.configure(bg='#264653')
Expand All @@ -31,7 +31,7 @@ def __init__(self, root) -> None:
titleLabel["font"] = ft
titleLabel["fg"] = "#168aad"
titleLabel["justify"] = "center"
titleLabel["text"] = "Z-Suite Mini"
titleLabel["text"] = "Intuitive XR Suite v0.3"
titleLabel.place(x=0, y=20, width=400, height=25)

# create input boxes
Expand Down Expand Up @@ -108,7 +108,7 @@ def create_reference_input(self, root):
self.reference_ent["font"] = ft
self.reference_ent["fg"] = "#264653"
self.reference_ent["justify"] = "center"
self.reference_ent.insert(tk.END, 'mean')
self.reference_ent.insert(tk.END, 'none')
self.reference_ent.place(x=250, y=160, width=70, height=25)

reference_label = tk.Label(root)
Expand Down Expand Up @@ -273,8 +273,8 @@ def connectBtn_command(self) -> None:
if self.display_ref_ent.get() == '1':
arguments.append('--display-ref')

zflow = ZFlow(args=arguments)
x = threading.Thread(target=zflow.run, daemon=True)
ixrflow = IXRFlow(args=arguments)
x = threading.Thread(target=ixrflow.run, daemon=True)
x.start()

@staticmethod
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def run(self) -> None:
"""
for data_type, preset in self.data_types.items():
rate = self.board_shim.get_sampling_rate(self.board_id, preset)
name = f'z-flow-{data_type}-data'
name = f'ixr-flow-{data_type}-data'
channel_count = self.board_shim.get_board_descr(self.board_id, preset)['num_rows'] \
if self.push_full_vec else len(self.channels[data_type])

logging.info(f"Starting '{name}' LSL Data Publisher stream.")
info_data = StreamInfo(name=name, type=data_type, channel_count=channel_count, nominal_srate=rate,
channel_format=cf_double64, source_id='z-flow-lsl-data-publisher')
channel_format=cf_double64, source_id='ixr-flow-lsl-data-publisher')
stream_channels = info_data.desc().append_child("channels")
for _, label in self.channels[data_type].items():
ch = stream_channels.append_child("channel")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from brainflow import BoardShim
from pylsl import (StreamInfo, StreamInlet, StreamOutlet, local_clock,
resolve_byprop)
from z_flow.classifiers import Classifier, ClfError
from ixr_flow.classifiers import Classifier, ClfError


class DecodeError(Exception):
Expand Down Expand Up @@ -44,10 +44,10 @@ def __init__(self, board_shim: BoardShim, stay_alive: Event, reference: str = 'm
self.board_shim = board_shim
self.reference = reference
self.classifiers = {}
name = 'z-flow-lsl-relay'
name = 'ixr-flow-lsl-relay'
logging.info(f"Starting '{name}' LSL event relay stream.")
self.outlet = StreamOutlet(StreamInfo(name=name, type='Markers', channel_count=3,
nominal_srate=0, channel_format='string', source_id='z-flow-lsl-relay'))
nominal_srate=0, channel_format='string', source_id='ixr-flow-lsl-relay'))
logging.info(f"'{self.outlet.get_info().name()}' LSL event relay stream started.")

def run(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LslLogger(StreamHandler):
def __init__(self, name: str = 'lsl_logger', stype: str = 'log') -> None:
StreamHandler.__init__(self)
self.outlet = StreamOutlet(StreamInfo(name=name, type=stype, channel_count=1,
channel_format='string', source_id='z-flow-lsl-logger'))
channel_format='string', source_id='ixr-flow-lsl-logger'))

def emit(self, message: str) -> None:
"""Method that is called by the logger to log a messages.
Expand Down
2 changes: 0 additions & 2 deletions z_flow/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions z_flow/gui/__init__.py

This file was deleted.

0 comments on commit 0b98c31

Please sign in to comment.