Exemple #1
0
 def test_if_pipeline_works_at_all(self):
     pipeline = Pipeline()
     pipeline.source = self.input_node
     for processor_node in self.processor_nodes:
         pipeline.add_processor(processor_node=processor_node)
     pipeline.add_output(self.output_node)
     pipeline.run()
Exemple #2
0
def pipeline():
    source = ConcreteSource()
    processor = ConcreteProcessor()
    output = ConcreteOutput()
    pipeline = Pipeline()
    pipeline.source = source
    source.add_child(processor)
    processor.add_child(output)
    pipeline._processors.append(processor)
    pipeline._outputs.append(output)
    return pipeline
import mne

from pyqtgraph import QtCore, QtGui
import pyqtgraph

pyqtgraph.setConfigOption('useOpenGL',True)

from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
from cognigraph import TIME_AXIS
from cognigraph.gui.window import GUIWindow
import logging

app = QtGui.QApplication(sys.argv)

pipeline = Pipeline()

cur_dir =  '/home/dmalt/Code/python/cogni_submodules'
test_data_path = cur_dir + '/tests/data/'
print(test_data_path)
# sim_data_fname = 'raw_sim.fif'
data_fname = 'Koleno.fif'

data_path = op.join(test_data_path, data_fname)


source = sources.FifSource(file_path=data_path)
pipeline.source = source


# Processors
%gui qt

from PyQt5 import QtCore

from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
from cognigraph.gui.window import GUIWindow

pipeline = Pipeline()

file_path = r"C:\Users\evgenii\Downloads\brainvision\Bulavenkova_A_2017-10-24_15-33-18_Rest.vmrk"
pipeline.source = sources.FileSource(file_path=file_path)

# linear_filter = processors.LinearFilter(lower_cutoff=0.1, upper_cutoff=40)
# pipeline.add_processor(linear_filter)
# pipeline.add_processor(processors.MNE(method='MNE'))
# pipeline.add_processor(processors.EnvelopeExtractor())
# pipeline.add_output(outputs.BrainViewer())
# pipeline.add_output(outputs.LSLStreamOutput())
# pipeline.initialize_all_nodes()

window = GUIWindow(pipeline=pipeline)
window.init_ui()
window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
window.show()
Exemple #5
0
def assemble_pipeline(file_path=None,
                      fwd_path=None,
                      subject=None,
                      subjects_dir=None,
                      inverse_method='mne'):
    pipeline = Pipeline()
    source = sources.FileSource(file_path=file_path)
    source.loop_the_file = True
    source.MAX_SAMPLES_IN_CHUNK = 10000
    pipeline.source = source

    # ----------------------------- processors ----------------------------- #
    preprocessing = processors.Preprocessing(collect_for_x_seconds=120)
    pipeline.add_processor(preprocessing)

    linear_filter = processors.LinearFilter(lower_cutoff=8.0,
                                            upper_cutoff=12.0)
    pipeline.add_processor(linear_filter)

    if inverse_method == 'mne':
        inverse_model = processors.InverseModel(method='MNE',
                                                snr=1.0,
                                                forward_model_path=fwd_path)
        # inverse_model = processors.MneGcs(snr=1.0, seed=1000,
        #                                   forward_model_path=fwd_path)
        pipeline.add_processor(inverse_model)
        envelope_extractor = processors.EnvelopeExtractor(0.99)
        pipeline.add_processor(envelope_extractor)
    elif inverse_method == 'beamformer':
        inverse_model = processors.Beamformer(
            forward_model_path=fwd_path,
            is_adaptive=True,
            output_type='activation',
            forgetting_factor_per_second=0.95)
        pipeline.add_processor(inverse_model)
        envelope_extractor = processors.EnvelopeExtractor(0.99)
        pipeline.add_processor(envelope_extractor)
    elif inverse_method == 'mce':
        inverse_model = processors.MCE(forward_model_path=fwd_path, snr=1.0)
        pipeline.add_processor(inverse_model)
        envelope_extractor = processors.EnvelopeExtractor(0.995)
        pipeline.add_processor(envelope_extractor)
    # ---------------------------------------------------------------------- #

    # ------------------------------ outputs ------------------------------ #
    global_mode = outputs.BrainViewer.LIMITS_MODES.GLOBAL

    brain_viewer = outputs.BrainViewer(limits_mode=global_mode,
                                       buffer_length=6,
                                       surfaces_dir=None)
    pipeline.add_output(brain_viewer, parent=envelope_extractor)

    # roi_average = processors.AtlasViewer(SUBJECT, subjects_dir)
    # roi_average.parent = inverse_model
    # pipeline.add_processor(roi_average)

    # aec = processors.AmplitudeEnvelopeCorrelations(
    #     method=None,
    #     seed=1000
    #     # method='temporal_orthogonalization',
    #     # method='geometric_correction',
    #     # seed=0
    # )
    # pipeline.add_processor(aec)
    # aec.parent = inverse_model
    # # coh = processors.Coherence(
    # #     method='coh', seed=0)
    # aec_env = processors.EnvelopeExtractor(0.995)
    # pipeline.add_processor(aec_env)

    # seed_viewer = outputs.BrainViewer(
    #     limits_mode=global_mode, buffer_length=6,
    #     surfaces_dir=op.join(subjects_dir, SUBJECT))

    # pipeline.add_output(seed_viewer, parent=aec_env)

    # pipeline.add_output(outputs.LSLStreamOutput())
    # signal_viewer = outputs.SignalViewer()
    # signal_viewer_src = outputs.SignalViewer()
    # pipeline.add_output(signal_viewer, parent=linear_filter)
    # pipeline.add_output(signal_viewer_src, parent=roi_average)
    # con_viewer = outputs.ConnectivityViewer(
    #     surfaces_dir=op.join(subjects_dir, SUBJECT))
    # pipeline.add_output(con_viewer, parent=aec)
    # --------------------------------------------------------------------- #
    return pipeline
Exemple #6
0
import sys

from pyqtgraph import QtCore, QtGui

from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
from cognigraph import TIME_AXIS
from cognigraph.gui.window import GUIWindow

app = QtGui.QApplication(sys.argv)

# BOBE
pipeline = Pipeline()

file_path = r"/home/evgenii/Downloads/brainvision/Bulavenkova_A_2017-10-24_15-33-18_Rest.vhdr"
source = sources.FileSource(file_path=file_path)
pipeline.source = source

inverse = processors.InverseModel()
pipeline.add_processor(inverse)

three_dee = outputs.ThreeDeeBrain()
pipeline.add_output(three_dee)

pipeline.initialize_all_nodes()

three_dee.widget.show()

source.output = source.data.take(indices=(0,), axis=TIME_AXIS)

inverse.update()
%gui qt

from pyqtgraph import QtCore

from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
from cognigraph.gui.window import GUIWindow

pipeline = Pipeline()

file_path = r"C:\Users\evgenii\Downloads\brainvision\Bulavenkova_A_2017-10-24_15-33-18_Rest.vmrk"
pipeline.source = sources.BrainvisionSource(file_path=file_path)

# linear_filter = processors.LinearFilter(lower_cutoff=0.1, upper_cutoff=40)
# pipeline.add_processor(linear_filter)
# pipeline.add_processor(processors.InverseModel(method='MNE'))
# pipeline.add_processor(processors.EnvelopeExtractor())
# pipeline.add_output(outputs.ThreeDeeBrain())
# pipeline.add_output(outputs.LSLStreamOutput())
# pipeline.initialize_all_nodes()

window = GUIWindow(pipeline=pipeline)
window.init_ui()
window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
window.show()
Exemple #8
0
from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
# from cognigraph import TIME_AXIS
from cognigraph.gui.window import GUIWindow
import logging
import mne

mne.set_log_level('WARNING')

app = QtWidgets.QApplication(sys.argv)

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s:%(name)-17s:%(levelname)s:%(message)s')

logger = logging.getLogger(__name__)
pipeline = Pipeline()

cur_dir = '/home/dmalt/Code/python/cogni_submodules'
test_data_path = cur_dir + '/tests/data/'
print(test_data_path)
sim_data_fname = 'raw_sim_nobads.fif'
# sim_data_fname = 'DF_2018-03-02_11-34-38.edf'
# sim_data_fname = 'Koleno.fif'
fwd_fname = 'dmalt_custom_mr-fwd.fif'
# fwd_fname = 'sample_1005-eeg-ico-4-fwd.fif'
# fwd_fname = 'sample_1005-eeg-oct-6-fwd.fif'
# fwd_fname = 'DF_2018-03-02_11-34-38-fwd.fif'

surf_dir = '/home/dmalt/mne_data/MNE-sample-data/subjects/sample/surf'

fwd_path = op.join(test_data_path, fwd_fname)
import sys

from pyqtgraph import QtCore, QtGui

from cognigraph.pipeline import Pipeline
from cognigraph.nodes import sources, processors, outputs
from cognigraph import TIME_AXIS
from cognigraph.gui.window import GUIWindow

app = QtGui.QApplication(sys.argv)

pipeline = Pipeline()

# file_path = r"/home/dmalt/Code/python/real_eyes/Koleno.eeg"
file_path = r"/home/dmalt/Data/cognigraph/data/Koleno.eeg"
# vhdr_file_path = r"/home/dmalt/Code/python/real_eyes/Koleno.vhdr"
# vhdr_file_path = r"/home/dmalt/Data/cognigraph/data/Koleno.vhdr"
# vhdr_file_path = r"/home/dmalt/Data/cognigraph/data/Koleno.fif"
fwd_path = r'/home/dmalt/mne_data/MNE-sample-data/MEG/sample/dmalt_custom-fwd.fif'
source = sources.FileSource(file_path=file_path)
pipeline.source = source
# pipeline.source = sources.LSLStreamSource(stream_name='cognigraph-mock-stream')

# Processors
preprocessing = processors.Preprocessing(collect_for_x_seconds=120)
pipeline.add_processor(preprocessing)

linear_filter = processors.LinearFilter(lower_cutoff=8.0, upper_cutoff=12.0)
pipeline.add_processor(linear_filter)

inverse_model = processors.InverseModel(method='MNE',