about

12/Keyword%20Discussion/ticker-posts

Muse2: 10日目: GUIからグラフ: Muse2graphGUI: I created a GUI version of the program

I added a GUI and some functions to the program that outputs Muse2 and Mind Monitor data in graphs.
Click here for English explanation


Muse2とMind Monitorのデータをグラフで出力するプログラムにGUIといくつかの機能を加えました。

※自分用のプログラムですが、参考までに公開します。
Here is the code: https://github.com/uminomae/Muse2graphGUI

Muse2graph

概要

Muse2とMind Monitorアプリを使って取得したデータからグラフを出力するプログラムです。

【Muse (headband) - Wikipedia】 https://en.wikipedia.org/wiki/Muse_(headband)
【Mind Monitor】 https://mind-monitor.com/

GUI

スクリーンショット 2023-12-12 6 19 07

class

2023-12-10_21 42 04

機能:

  • macのダウンロードディレクトリにある.zipファイルからグラフを作成します。
  • 移動平均線は直近5つのデータポイントとの平均です。
  • 出力するデータの範囲は、取得開始時からor取得時の最後(直近)の時間で指定できます。※0orデータの範囲を超える時間数を指定すると全てを出力します スクリーンショット 2023-12-11 19 28 17

事前準備

  1. 全てのファイルを適当な場所(例:~/Documents/Muse2)に保存してください。同じディレクトリにある必要があります。
    • ※必要なsaved_plots,extracted_data,configディレクトリは自動で作成されます。 スクリーンショット 2023-12-12 3 57 57

使い方:

Muse2,Mind Monitor,Dropbox

  1. Muse2使用時に、Mind Monitorアプリを使用してDropboxに転送(標準機能)してください。
    スクリーンショット 2023-12-06 10 29 47
  2. 記録を終えたら、Dropboxから計測データ(zip)を標準のダウンロードディレクトリにダウンロードしてください。
    スクリーンショット 2023-12-06 9 10 12

ターミナルでのbashによる操作

  1. ターミナル上でcloneした(zipをDLした場合、解凍して作成された)ディレクトリに移動してください
  2. python3 main.pyを実行してください。GUIが起動します。
    • 前回の設定と同じであれば起動後Returnキーを押すだけでグラフが出力され自動でCSVとPNGが保存されます。
    • データの保存先
      ※ディレクトリは自動で作成されます
      • saved_plots/
        • グラフ画像 (PNG)
      • extracted_data/
        • DropBoxからダウンロードした.zipを解凍したファイル (CSV)

例:

cd ~/Documents/Muse2graphGUI-main; python3 main.py

GUI操作

スクリーンショット 2023-12-12 6 19 07
  • Graph Title
    • グラフ画像の上部に文字を表示します。
      • 自由に入力可能です。
      • メニューから選択することもできます。
        • oprions.pyを編集することで選択肢を増やすことができます。TITLE_OPTIONS
      • ショートカットキーはcontrol+'m'などで設定しています。
        • ショートカットキーも編集可能です。 KEY_BINDINGS
  • Data Span
    • Recent
      • データの終了時点から直近の指定した時間分のデータを元にグラフを出力します。
    • First
      • データの開始時点から指定した時間分のデータを元にグラフを出力します。
  • Select File
    • データを自由に選択できます。
    • 未選択の場合、~/Downloadディレクトリから最新の.zipファイルを探してグラフを出力します。
  • Create Graph
    • .zipを解凍し、CSVファイルを保存し、グラフを保存し、ウィンドウに画像を出力します。
    • Returnキーでも動作します。

スクリプトエディタでアプリとして保存する場合

https://support.apple.com/ja-jp/guide/script-editor/scpedt1072/2.11/mac/14.0

tell application "Terminal" do script "cd ~/Documents/Muse2; python3 main.py" end tell
スクリーンショット 2023-12-12 6 41 22

Dockにエイリアスを登録することでターミナル操作をせずに起動できます
スクリーンショット 2023-12-12 6 38 11

参考

参考:【Muse2(BMI)で脳波を測ってみた! | TECH | NRI Digital】 https://www.nri-digital.jp/tech/20211228-7840/


Muse2graph

Overview

Muse2graph is a program that generates graphs from data obtained using the Muse2 headband and the Mind Monitor app.

GUI

GUI Screenshot

Classes

Class Diagram

Features:

Creates graphs from .zip files in the Mac downloads directory. The moving average line is calculated from the last 5 data points. You can specify the output data range from the start of acquisition or the most recent data. Specifying 0 or a time beyond the data range will output everything.

Preparation

全てのファイルを適当な場所(例:~/Documents/Muse2)に保存してください。同じディレクトリにある必要があります。

Usage:

With Muse2, Mind Monitor, Dropbox

Muse2使用時に、Mind Monitorアプリを使用してDropboxに転送(標準機能)してください。記録を終えたら、Dropboxから計測データ(zip)を標準のダウンロードディレクトリにダウンロードしてください。

Mind Monitor Screenshot     Dropbox Screenshot

Using Terminal

  1. Navigate to the cloned (or unzipped) directory on the terminal.
  2. Execute `python3 main.py`. The GUI will launch.

Example:

cd ~/Documents/Muse2graphGUI-main; python3 main.py

GUI Operations

Saving as an App with Script Editor

For instructions on how to save as an app using Script Editor, visit Apple Support.

Example AppleScript to open Terminal and run the program:


tell application "Terminal"
    do script "cd ~/Documents/Muse2; python3 main.py"
end tell
    

Registering an alias in the Dock allows you to launch the program without using the Terminal.

Reference

Using Muse2 (BMI) to Measure Brainwaves! | TECH | NRI Digital