Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

217 not all the eeg channels are turning up on the expression plot #218

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EEG001: 'P09'
EEG001: 'PO9'
EEG002: 'FPz'
EEG003: 'PO10'
EEG004: 'AF7'
Expand All @@ -23,10 +23,10 @@ EEG023: 'FCZ'
EEG024: 'FC2'
EEG025: 'FC4'
EEG026: 'FC6'
EEG027: 'FC8'
EEG027: 'FT8'
EEG030: 'T7'
EEG031: 'С5'
EEG032: 'С3'
EEG031: 'C5'
EEG032: 'C3'
EEG033: 'C1'
EEG034: 'CZ'
EEG035: 'C2'
Expand All @@ -40,8 +40,8 @@ EEG043: 'CP3'
EEG044: 'CP1'
EEG045: 'CPZ'
EEG046: 'CP2'
EEG047: 'СР4'
EEG048: 'СР6'
EEG047: 'CP4'
EEG048: 'CP6'
EEG049: 'TP8'
EEG050: 'TP10'
EEG052: 'P7'
Expand All @@ -55,10 +55,10 @@ EEG059: 'P6'
EEG060: 'P8'
EEG062: 'PO7'
EEG063: 'PO3'
EEG064: 'P0Z'
EEG018: 'P04'
EEG028: 'P08'
EEG064: 'POZ'
EEG018: 'PO4'
EEG028: 'PO8'
EEG029: 'O1'
EEG039: 'OZ'
EEG051: 'O2'
EEG061: 'IZ'
EEG061: 'IZ'
2 changes: 1 addition & 1 deletion kymata/config/dataset4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Config file for Kymata Dataset 4.00

# General
data_location: "cbu-local" # local | cbu | cbu-local
data_location: "local" # local | cbu | cbu-local
dataset_directory_name: "dataset_4-english-narratives"
mri_structurals_directory: "raw_mri_structurals"

Expand Down
20 changes: 8 additions & 12 deletions kymata/plot/layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def get_meg_sensor_xy() -> dict[str, Point2d]:


def get_eeg_sensor_xy() -> dict[str, Point2d]:
with Path(Path(__file__).parent.parent.parent, "kymata-toolbox-data", "sensor_locations",
"EEG-layout-channel-mappings.yaml").open("r") as eeg_name_mapping_file:
mapping = yaml.safe_load(eeg_name_mapping_file)
mapping = {k.upper(): v.upper() for k, v in mapping.items()}
d = dict()
with Path(Path(__file__).parent.parent.parent, "kymata-toolbox-data", "sensor_locations",
"EEG1005.lay").open("r") as layout_file:
Expand All @@ -44,19 +48,11 @@ def get_eeg_sensor_xy() -> dict[str, Point2d]:
y = float(parts[2])
name = parts[-1].upper()
d[name] = Point2d(x, y)
# Get name mapping
with Path(Path(__file__).parent.parent.parent, "kymata-toolbox-data", "sensor_locations",
"EEG-layout-channel-mappings.yaml").open("r") as eeg_name_mapping_file:
mapping = yaml.safe_load(eeg_name_mapping_file)
mapping = {k.upper(): v.upper() for k, v in mapping.items()}
inverted_mapping = {v: k for k, v in mapping.items()}
# Apply name mapping
new_d = {
inverted_mapping[name]: point
for name, point in d.items()
if name in inverted_mapping.keys()
our_sensor_d = {
our_name: d[their_name]
for our_name, their_name in mapping.items()
}
return new_d
return our_sensor_d


def plot_eeg_sensor_positions(raw_fif: Raw):
Expand Down
4 changes: 2 additions & 2 deletions kymata/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AxisAssignment(NamedTuple):
axis_channels: list


_left_right_sensors: tuple[AxisAssignment, AxisAssignment] = (
sensor_left_right_assignment: tuple[AxisAssignment, AxisAssignment] = (
AxisAssignment(axis_name="left",
axis_channels=[
sensor
Expand Down Expand Up @@ -179,7 +179,7 @@ def expression_plot(
# We have a special case with paired sensor data, in that some sensors need to appear
# on both sides of the midline.
if paired_axes and isinstance(expression_set, SensorExpressionSet):
assign_left_right_channels = _left_right_sensors
assign_left_right_channels = sensor_left_right_assignment
# Some points will be plotted on one axis, filled, some on both, empty
top_chans = set(assign_left_right_channels[0].axis_channels)
bottom_chans = set(assign_left_right_channels[1].axis_channels)
Expand Down
30 changes: 22 additions & 8 deletions tests/test_iterables.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import pytest

from kymata.entities.iterables import all_equal


def test_all_0s_are_equal():
all_zeros = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
assert all_equal(all_zeros)
@pytest.fixture
def all_0s():
return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


@pytest.fixture
def all_0s_and_a_1():
return [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]


@pytest.fixture
def all_nones():
return [None, None, None, None, None, None, None, None]


def test_all_0s_are_equal(all_0s):
assert all_equal(all_0s)


def test_0s_and_a_1_are_not_equal():
all_zeros_and_a_one = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
assert not all_equal(all_zeros_and_a_one)
def test_0s_and_a_1_are_not_equal(all_0s_and_a_1):
assert not all_equal(all_0s_and_a_1)


def test_all_nones_are_equal():
all_nones = [None, None, None, None, None, None, None, None]
def test_all_nones_are_equal(all_nones):
assert all_equal(all_nones)


Expand Down
Loading
Loading