From 7ccf0fc9baea563964275fca38472e077b6ef522 Mon Sep 17 00:00:00 2001 From: Parv Agarwal <65726543+Parvfect@users.noreply.github.com> Date: Sun, 16 Oct 2022 20:31:18 +0100 Subject: [PATCH] Adding pipelines for cli analysis (#202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * started pipelines function * almost working simple function equivalents of nb scripts * fix: fixed import (brainflow updated API) * sqc fixes for unicorn (#176) * Ignore pushes * Trying to create a cli * Stepping through the problem * First commit * Fixing pause in signal quality check * Fixing Signal quality check problem * fix the technical debt * Save path done for automated saving pdf * I feel amazing * Almost through * Update eegnb/cli/__main__.py Co-authored-by: Erik Bjäreholt * Trying to create cli but it's being really painful * Extra word cli error * Changed example handling * Pain * Adding whole datapath * Finally fixed cli * hmm * Looking good * added hyperlink * Having some issues with detecting css and image deltetion * Just the css now * Fixed the css linking problem though it's a weird soln * Automated running, still fnames problem * Hahahah embedded images in html * Improving code * Okay now * Look at that * Almost there just the two figures now * Now * Added attrdict to do with cli error Co-authored-by: John Griffiths Co-authored-by: Erik Bjäreholt Co-authored-by: John Griffiths --- eegnb/cli/__main__.py | 31 ++++++++++++++++++++++ eegnb/cli/introprompt.py | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/eegnb/cli/__main__.py b/eegnb/cli/__main__.py index d43702e4..e9ddc9ce 100644 --- a/eegnb/cli/__main__.py +++ b/eegnb/cli/__main__.py @@ -128,6 +128,37 @@ def create_analysis_report( experiment, eegdevice, subject, session, site, filepath = analysis_intro_prompt() analysis_report(experiment, eegdevice, subject, session, site, filepath) +@main.command() +@click.option("-ex", "--experiment", help="Experiment to run") +@click.option("-ed", "--eegdevice", help="EEG device to use") +@click.option("-sub", "--subject", help="Subject ID") +@click.option("-sess", "--session", help="Session number") +@click.option("-fp", "--filepath", help="Filepath to save data") +@click.option( + "-ip", "--prompt", help="Use interactive prompt to ask for parameters", is_flag=True +) +def create_analysis_report( + experiment: str, + eegdevice: str = None, + subject: str = None, + session: str = None, + filepath:str = None, + prompt: bool = False, +): + """ + Create analysis report of recorded data + """ + + if prompt: + example = input("Do you want to load an example experiment? (y/n)\n") + print() + if example == 'y': + example_analysis_report() + return + else: + experiment, eegdevice, subject, session, filepath = analysis_intro_prompt() + create_analysis_report_(experiment, eegdevice, subject, session, filepath) + @main.command() @click.option("-ed", "--eegdevice", help="EEG device to use", required=True) diff --git a/eegnb/cli/introprompt.py b/eegnb/cli/introprompt.py index 6f8aa488..cd9f7bbc 100644 --- a/eegnb/cli/introprompt.py +++ b/eegnb/cli/introprompt.py @@ -160,6 +160,63 @@ def intro_prompt() -> Tuple[EEG, str, int, str]: return eeg_device, exp_selection, duration, str(save_fn) +def analysis_device_prompt(): + + boards = { + "none": "None", + "muse2016": "Muse (2016)", + "muse2": "Muse 2", + "museS": "Muse S", + "muse2016_bfn": "Muse 2016 - brainflow, native bluetooth", + "muse2016_bfb": "Muse 2016 - brainflow, BLED bluetooth dongle", + "muse2_bfn": "Muse 2 - brainflow, native bluetooth", + "muse2_bfb": "Muse 2 - brainflow, BLED bluetooth dongle", + "museS_bfn": "Muse S - brainflow, native bluetooth", + "museS_bfb": "Muse S - brainflow, BLED bluetooth dongle", + "ganglion": "OpenBCI Ganglion", + "cyton": "OpenBCI Cyton", + "cyton_daisy": "OpenBCI Cyton + Daisy", + "unicorn": "G.Tec Unicorn", + "brainbit": "BrainBit", + "notion1": "Notion 1", + "notion2": "Notion 2", + "crown": "Crown", + "synthetic": "Synthetic", + "freeeeg32": "FreeEEG32", + } + + print("Please enter the integer value corresponding to your EEG device: \n") + print("\n".join(f"[{i:2}] {board}" for i, board in enumerate(boards.values()))) + + board_idx = int(input("\nEnter Board Selection: \n")) + + # Board_codes are the actual names to be passed to the EEG class + board_code = list(boards.keys())[board_idx] + return board_code + +def analysis_intro_prompt(): + + # check if user has filepath + print("Welcome to NeurotechX EEG Notebooks\n") + print("Do you have a filepath to a .csv file you would like to analyze? \n") + print("[1] Yes \n") + print("[0] No \n") + file_idx = int(input("Enter selection: \n")) + if file_idx == 1: + print("Please enter the filepath to the .csv file you would like to analyze. \n") + filepath = input("Enter filepath: \n") + subject, session = None, None + else: + subject = int(input("Enter subject ID#: \n")) + session = int(input("Enter session #: \n")) + filepath = None + + eegdevice = analysis_device_prompt() + experiment = exp_prompt() + + return experiment, eegdevice, subject, session, filepath + + def analysis_device_prompt():