Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 119 additions & 2 deletions ArtificialIntelligence.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Rectangle {
// Framework selection state
property string currentFramework: "PyTorch"

//Headset slection state
property string currentHeadset: "OpenBCI"

// TOP-LEVEL LAYOUT
ColumnLayout {
anchors.fill: parent
Expand Down Expand Up @@ -994,9 +997,123 @@ Rectangle {
}
}

Item { Layout.fillHeight: true } // spacer

// Buttons to choose the source headset------------
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: false
Layout.preferredHeight: Math.min(root.height * 0.25, 220)
Layout.minimumHeight: root.minControlSize
color: "#1f2740"
radius: 8
border.color: "#1a2035"

ColumnLayout {
anchors.fill: parent
anchors.margins: 16
spacing: 12

// Title
Text {
text: "Choose Headset"
color: "white"
font.bold: true
font.pixelSize: Math.max(10, Math.min(32, root.height * 0.05))
horizontalAlignment: Text.AlignHCenter
Layout.alignment: Qt.AlignHCenter
}


Item {
Layout.fillHeight: true
}

// Select headset buttons
RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
spacing: 16

// OpenBCI
Rectangle {
Layout.fillWidth: true
Layout.minimumWidth: root.minControlSize
Layout.minimumHeight: root.minControlSize
Layout.maximumWidth: 260
implicitWidth: Math.max(root.minControlSize,
Math.min(root.width * 0.12, 220))
implicitHeight: Math.max(root.minControlSize,
Math.min(root.height * 0.07, 80))
radius: 8
color: "#2d7a4a"
border.color: currentHeadset === "OpenBCI" ? "yellow" : "#2d7a4a"
border.width: currentHeadset === "OpenBCI" ? 3 : 1

Text {
anchors.centerIn: parent
text: "OpenBCI"
color: currentHeadset === "OpenBCI" ? "yellow" : "white"
font.bold: true
font.pixelSize: Math.max(10,
Math.min(18, parent.height * 0.35))
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap
}

MouseArea {
anchors.fill: parent
onClicked: {
currentHeadset = "OpenBCI"
backend.setBCISource("openbci")
logToConsole("Changed headset to OpenBCI")

}
}
}

// Neurosity
Rectangle {
Layout.fillWidth: true
Layout.minimumWidth: root.minControlSize
Layout.minimumHeight: root.minControlSize
Layout.maximumWidth: 260
implicitWidth: Math.max(root.minControlSize,
Math.min(root.width * 0.12, 220))
implicitHeight: Math.max(root.minControlSize,
Math.min(root.height * 0.07, 80))
radius: 8
color: "#2d7a4a"
border.color: currentHeadset === "Neurosity" ? "yellow" : "#2d7a4a"
border.width: currentHeadset === "Neurosity" ? 3 : 1

Text {
anchors.centerIn: parent
text: "Neurosity"
color: currentHeadset === "Neurosity" ? "yellow" : "white"
font.bold: true
font.pixelSize: Math.max(10,
Math.min(18, parent.height * 0.35))
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap
}

MouseArea {
anchors.fill: parent
onClicked: {
currentHeadset = "Neurosity"
backend.setBCISource("neurosity")
logToConsole("Changed headset to Neurosity")

}
}
}
}
}
}
}
}
}
}
}
}
24 changes: 18 additions & 6 deletions GUI5.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

from developers_api import DevelopersAPI



from NA06_Manual_Control import ManualNaoController
from NA06_Manual_Control.camera_view import DroneCameraController

# Import BCI connection for brainwave prediction
try:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'random-forest-prediction')))
from client.brainflow1 import bciConnection, DataMode
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'prediction-random-forest', 'tensorflow', 'client')))
from brainflow1 import bciConnection, DataMode
BCI_AVAILABLE = True
except ImportError as e:
print(f"Warning: BCI connection not available: {e}")
Expand Down Expand Up @@ -889,6 +890,20 @@ def convert_pdfs_to_images(self):

self.imagesReady.emit(self.image_paths) # Send data to QML

#Allows the user to switch between the OpenBCI or Neurosity Crown headsets
@Slot(str)
def setBCISource(self, source):
self.logMessage.emit(f"Switching BCI source to: {source}")

if source == "neurosity":
self.current_bci_source = "neurosity"

elif source == "openbci":
self.current_bci_source = "openbci"

else:
self.logMessage.emit("Unknown BCI source selected")

@Slot(str)
def setDataMode(self, mode):
"""
Expand Down Expand Up @@ -974,7 +989,4 @@ def init_live_board(self):
# Ensure image model updates correctly
backend.imagesReady.connect(lambda images: engine.rootContext().setContextProperty("imageModel", images))

sys.exit(app.exec())



sys.exit(app.exec())
78 changes: 74 additions & 4 deletions ReadBrain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import QtQuick3D 6.7

// Read Brain view
Rectangle {
id: root
property string selectedModel: "Random Forest"
property string currentFramework: "PyTorch"
property string selectedHeadset: "OpenBCI"
color: "#718399"
Layout.fillWidth: true
Layout.fillHeight: true
Expand Down Expand Up @@ -437,8 +439,8 @@ Rectangle {

// Model Selection Buttons in dark box
Rectangle {
width: parent.width * 0.9
height: parent.height * 0.18
width: parent.width * 0.95
height: parent.height * 0.25
color: "#2c3e50"

Column {
Expand All @@ -449,7 +451,7 @@ Rectangle {
// Model Selection Row
Row {
width: parent.width
height: (parent.height - parent.spacing) * 0.5
height: (parent.height - parent.spacing * 2) / 3
spacing: parent.width * 0.02

Rectangle {
Expand Down Expand Up @@ -534,7 +536,7 @@ Rectangle {
// Framework Selection Row
Row {
width: parent.width
height: (parent.height - parent.spacing) * 0.5
height: (parent.height - parent.spacing * 2) / 3
spacing: parent.width * 0.02

Rectangle {
Expand Down Expand Up @@ -611,8 +613,72 @@ Rectangle {
}
}
}

}

//Headset select row
Row{
width: parent.width
height: (parent.height - parent.spacing * 2) / 3
spacing: parent.width * 0.02

Rectangle {
width: (parent.width - parent.spacing ) / 2
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: selectedHeadset === "OpenBCI" ? "yellow" : "#4a9d6f"
border.width: selectedHeadset === "OpenBCI" ? 3 : 1

Text {
text: "OpenBCI"
font.pixelSize: parent.height * 0.3
font.bold: true
color: selectedHeadset === "OpenBCI" ? "yellow" : "white"
anchors.centerIn: parent
}

MouseArea {
anchors.fill: parent
onClicked: {
selectedHeadset = "OpenBCI"
backend.setBCISource("openbci")

}
}
}

Rectangle {
width: (parent.width - parent.spacing ) / 2
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: selectedHeadset === "Neurosity" ? "yellow" : "#4a9d6f"
border.width: selectedHeadset === "Neurosity" ? 3 : 1

Text {
text: "Neurosity"
font.pixelSize: parent.height * 0.3
font.bold: true
color: selectedHeadset === "Neurosity" ? "yellow" : "white"
anchors.centerIn: parent
}

MouseArea {
anchors.fill: parent
onClicked: {
selectedHeadset = "Neurosity"
backend.setBCISource("neurosity")

}
}
}

}



}
}
}
}
Expand Down Expand Up @@ -689,5 +755,9 @@ Rectangle {
}
onClicked: backend.setDataMode("synthetic")
}

}



}