Skip to content
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
14 changes: 13 additions & 1 deletion examples/plot_10_run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
In this notebook, we will run the pyLossless pipeline on a publicly available dataset.
"""

# %%
# Installation (in the terminal or through Jupyter)
# -------
#!pip install -q pylossless
#!pip install -q openneuro-py


# %%
# Imports
# -------
Expand All @@ -14,7 +21,12 @@
import pylossless as ll

# %%
# Get the data
# Get the data.
#
# Note: If you are testing this examples in Google Colab, the
# openneuro-py download function does not always work flawlessly. You may have
# to run this cell twice for the files to be properly downloaded and usable by
# the next cell.
# ------------
raw, config, bids_path = ll.datasets.load_openneuro_bids()

Expand Down
5 changes: 2 additions & 3 deletions pylossless/dash/css_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
DEFAULT_LAYOUT_XAXIS = {
"zeroline": False,
"showgrid": True,
"title": "time (seconds)",
"title": {"text": "time (seconds)", "font": {"color": "#ADB5BD"}},
"gridcolor": "white",
"fixedrange": True,
"showline": True,
"titlefont": dict(color="#ADB5BD"),
"tickfont": dict(color="#ADB5BD"),
"automargin": True,
}
Expand All @@ -35,7 +34,7 @@
"autorange": False, # 'reversed',
"scaleratio": 0.5,
"tickmode": "array",
"titlefont": dict(color="#ADB5BD"),
"title": {"font": {"color": "#ADB5BD"}},
"tickfont": dict(color="#ADB5BD"),
"fixedrange": True,
"automargin": True,
Expand Down
3 changes: 2 additions & 1 deletion pylossless/dash/mne_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def inst(self, inst):
)
if self.scalings_arg == "auto":
for kind in np.unique(self.inst.get_channel_types()):
self.scalings[kind] = np.percentile(self.inst.get_data(), 99.5)
data = self.inst.get_data(picks=kind)
self.scalings[kind] = np.percentile(data, 99.5)
else:
self.scalings.update(self.scalings_arg)

Expand Down
24 changes: 19 additions & 5 deletions pylossless/dash/qcannotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@
self._duration = duration
self._description = description_str

self._dash_layout = layout
self._dash_shape = dict(
name=self.id,
name=self._id,
type="rect",
xref="x",
yref="y",
x0=self.onset,
y0=self._dash_layout.yaxis["range"][0],
y0=layout.yaxis["range"][0],
x1=self.onset + self.duration,
y1=self._dash_layout.yaxis["range"][1],
y1=layout.yaxis["range"][1],
fillcolor="red",
opacity=0.25 if self.duration else 0.75,
line_width=1,
Expand All @@ -53,13 +52,20 @@
)
self._dash_description = dict(
x=self.onset + self.duration / 2,
y=self._dash_layout.yaxis["range"][1],
y=layout.yaxis["range"][1],
text=self.description,
showarrow=False,
yshift=10,
font={"color": "#F1F1F1"},
)

def to_dict(self):
"""Return a dict representation of the EEGAnnotation object."""
return {"_id": self._id, "_onset": self._onset,

Check warning on line 64 in pylossless/dash/qcannotations.py

View check run for this annotation

Codecov / codecov/patch

pylossless/dash/qcannotations.py#L64

Added line #L64 was not covered by tests
"_duration": self._duration, "_description": self._description,
"_dash_description": self._dash_description,
"_dash_shape": self._dash_shape}

def update_dash_objects(self):
"""Update plotly shape/annotations.

Expand Down Expand Up @@ -174,6 +180,14 @@
else:
self.annotations = pd.Series()

def to_plotly_json(self):
"""Return a dict representation of the EEGAnnotation object.

Implementing this function is necessary for Plotly/Dash to serialize
EEGAnnotationList objects.
"""
return {key: value.to_dict() for key, value in self.annotations.items()}

Check warning on line 189 in pylossless/dash/qcannotations.py

View check run for this annotation

Codecov / codecov/patch

pylossless/dash/qcannotations.py#L189

Added line #L189 was not covered by tests

def __get_series(self, attr):
return pd.Series(
{annot.id: getattr(annot, attr) for annot in self.annotations.values}
Expand Down
Loading