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
1,571 changes: 744 additions & 827 deletions doc/_static/mne_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,571 changes: 744 additions & 827 deletions doc/_static/mne_logo_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
783 changes: 783 additions & 0 deletions doc/_static/mne_logo_gray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions doc/_static/mne_logo_small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions doc/sphinxext/gen_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def generate_commands_rst(app=None):
from sphinx.util.display import status_iterator
except Exception:
from sphinx.util import status_iterator
root = Path(__file__).parent.parent.parent.absolute()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even on this branch:

$ git grep "\.parent\.parent" | wc -l
70

but they are now at least all isolated to tests files, I made the others more compact in this PR

out_dir = (root / "doc" / "generated").absolute()
root = Path(__file__).parents[2]
out_dir = root / "doc" / "generated"
out_dir.mkdir(exist_ok=True)
out_fname = out_dir / "commands.rst.new"

Expand Down
112 changes: 72 additions & 40 deletions logo/generate_mne_logos.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
"""
===============================================================================
Script 'mne logo'
===============================================================================
"""Generate the MNE-Python logos."""

This script makes the logo for MNE.
"""
# @author: drmccloy
# Created on Mon Jul 20 11:28:16 2015
# License: BSD-3-Clause

import numpy as np
import os.path as op
import pathlib

import matplotlib.pyplot as plt
from matplotlib import rcParams
from scipy.stats import multivariate_normal
import numpy as np
from matplotlib import font_manager, rcParams
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.patches import Ellipse, FancyBboxPatch, PathPatch, Rectangle
from matplotlib.path import Path
from matplotlib.text import TextPath
from matplotlib.patches import PathPatch, Ellipse, FancyBboxPatch, Rectangle
from matplotlib.colors import LinearSegmentedColormap
from scipy.stats import multivariate_normal

# manually set values
dpi = 300
center_fudge = np.array([15, 30]) # compensate for font bounding box padding
tagline_scale_fudge = 0.97 # to get justification right
tagline_offset_fudge = np.array([0, -100.0])

# font, etc
# font, etc (default to MNE font)
rcp = {
"font.sans-serif": ["Primetime"],
"font.style": "normal",
Expand All @@ -38,6 +34,9 @@
plt.rcdefaults()
rcParams.update(rcp)

# %%
# mne_logo.svg and mne_logo_dark.svg

# initialize figure (no axes, margins, etc)
fig = plt.figure(1, figsize=(5, 2.25), frameon=False, dpi=dpi)
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
Expand Down Expand Up @@ -108,14 +107,21 @@
im.set_clip_path(mne_clip, transform=im.get_transform())
ax.add_patch(rect)
rect.set_clip_path(mne_clip, transform=im.get_transform())
for coll in cs.collections:
coll.set_clip_path(mne_clip, transform=im.get_transform())
cs.set_clip_path(mne_clip, transform=im.get_transform())
# get final position of clipping mask
mne_corners = mne_clip.get_extents().corners()

# For this make sure that this gives something like ""
fnt = font_manager.findfont("Cooper Hewitt:style=normal:weight=book")
if "Book" not in fnt or "CooperHewitt" not in fnt:
print(
f"WARNING: Might not use correct Cooper Hewitt, got {fnt} but want "
"CooperHewitt-Book.otf or similar"
)

# add tagline
rcParams.update({"font.sans-serif": ["Cooper Hewitt"], "font.weight": "300"})
tag_path = TextPath((0, 0), "MEG + EEG ANALYSIS & VISUALIZATION")
with plt.rc_context({"font.sans-serif": ["Cooper Hewitt"], "font.weight": "book"}):
tag_path = TextPath((0, 0), "MEG + EEG ANALYSIS & VISUALIZATION")
dims = tag_path.vertices.max(0) - tag_path.vertices.min(0)
vert = tag_path.vertices - dims / 2.0
mult = tagline_scale_fudge * (plot_dims / dims).min()
Expand All @@ -126,26 +132,36 @@
- tagline_offset_fudge
)
tag_clip = Path(offset + vert * mult, tag_path.codes)
tag_patch = PathPatch(tag_clip, facecolor="k", edgecolor="none", zorder=10)
tag_patch = PathPatch(tag_clip, facecolor="0.6", edgecolor="none", zorder=10)
ax.add_patch(tag_patch)
yl = ax.get_ylim()
yy = np.max([tag_clip.vertices.max(0)[-1], tag_clip.vertices.min(0)[-1]])
ax.set_ylim(np.ceil(yy), yl[-1])

# only save actual image extent plus a bit of padding
plt.draw()
static_dir = op.join(op.dirname(__file__), "..", "doc", "_static")
assert op.isdir(static_dir)
plt.savefig(op.join(static_dir, "mne_logo.svg"), transparent=True)
tag_patch.set_facecolor("w")
rect.set_facecolor("0.5")
plt.savefig(op.join(static_dir, "mne_logo_dark.svg"), transparent=True)
tag_patch.set_facecolor("k")
rect.set_facecolor("w")
fig.canvas.draw_idle()
static_dir = pathlib.Path(__file__).parents[1] / "doc" / "_static"
assert static_dir.is_dir()
kind_color = dict(
mne_logo_dark=("0.8", "0.5"),
mne_logo_gray=("0.6", "0.75"),
mne_logo=("0.3", "w"), # always last
)
for kind, (tag_color, rect_color) in kind_color.items():
tag_patch.set_facecolor(tag_color)
rect.set_facecolor(rect_color)
fig.savefig(
static_dir / f"{kind}.svg",
transparent=True,
)

# %%
# mne_splash.png

# modify to make the splash screen
data_dir = op.join(op.dirname(__file__), "..", "mne", "icons")
ax.patches[-1].set_facecolor("w")
data_dir = pathlib.Path(__file__).parents[1] / "mne" / "icons"
assert data_dir.is_dir()
tag_patch.set_facecolor("0.7")
for coll in list(ax.collections):
coll.remove()
bounds = np.array(
Expand All @@ -159,7 +175,10 @@
r = np.diff(bounds, axis=1).max() * 1.2
w, h = r, r * (2 / 3)
box_xy = [xy[0] - w * 0.5, xy[1] - h * (2 / 5)]
ax.set_ylim(box_xy[1] + h * 1.001, box_xy[1] - h * 0.001)
ax.set(
ylim=(box_xy[1] + h * 1.001, box_xy[1] - h * 0.001),
xlim=(box_xy[0] - w * 0.001, box_xy[0] + w * 1.001),
)
patch = FancyBboxPatch(
box_xy,
w,
Expand All @@ -174,33 +193,43 @@
)
ax.add_patch(patch)
fig.set_size_inches((512 / dpi, 512 * (h / w) / dpi))
plt.savefig(op.join(data_dir, "mne_splash.png"), transparent=True)
fig.savefig(
data_dir / "mne_splash.png",
transparent=True,
)
patch.remove()

# %%
# mne_default_icon.png

# modify to make an icon
ax.patches.pop(-1) # no tag line for our icon
ax.patches[-1].remove() # no tag line for our icon
patch = Ellipse(xy, r, r, clip_on=False, zorder=-1, fc="k")
ax.add_patch(patch)
ax.set_ylim(xy[1] + r / 1.9, xy[1] - r / 1.9)
ax.set_ylim(xy[1] + r / 1.99, xy[1] - r / 1.99)
fig.set_size_inches((256 / dpi, 256 / dpi))
# Qt does not support clip paths in SVG rendering so we have to use PNG here
# then use "optipng -o7" on it afterward (14% reduction in file size)
plt.savefig(op.join(data_dir, "mne_default_icon.png"), transparent=True)
plt.close()
fig.savefig(
data_dir / "mne_default_icon.png",
transparent=True,
)

# %%
# mne_logo_small.svg

# 188x45 image
dpi = 96 # for SVG it's different
w_px = 188
h_px = 45
center_fudge = np.array([60, 0])
scale_fudge = 2.1
rcParams.update({"font.sans-serif": ["Primetime"], "font.weight": "black"})
x = np.linspace(-1.0, 1.0, w_px // 2)
y = np.linspace(-1.0, 1.0, h_px // 2)
X, Y = np.meshgrid(x, y)
# initialize figure (no axes, margins, etc)
fig = plt.figure(
1, figsize=(w_px / dpi, h_px / dpi), facecolor="k", frameon=False, dpi=dpi
2, figsize=(w_px / dpi, h_px / dpi), facecolor="k", frameon=False, dpi=dpi
)
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
ax.set_axis_off()
Expand Down Expand Up @@ -232,6 +261,9 @@
ypad = np.abs(np.diff([ymax, ymin])) / 20.0
ax.set_xlim(xmin - xpad, xl[1] + xpad)
ax.set_ylim(ymax + ypad, ymin - ypad)
plt.draw()
plt.savefig(op.join(static_dir, "mne_logo_small.svg"), dpi=dpi, transparent=True)
plt.close()
fig.canvas.draw_idle()
fig.savefig(
static_dir / "mne_logo_small.svg",
dpi=dpi,
transparent=True,
)
Binary file modified mne/icons/mne_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mne/icons/mne_splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mne/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def _get_stim_channel(stim_channel, info, raise_error=True):

def _get_root_dir():
"""Get as close to the repo root as possible."""
root_dir = Path(__file__).parent.parent.expanduser().absolute()
root_dir = Path(__file__).parents[1]
up_dir = root_dir.parent
if (up_dir / "setup.py").is_file() and all(
(up_dir / x).is_dir() for x in ("mne", "examples", "doc")
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/backends/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _alpha_blend_background(ctable, background_color):
def _qt_init_icons():
from qtpy.QtGui import QIcon

icons_path = f"{Path(__file__).parent.parent.parent}/icons"
icons_path = str(Path(__file__).parents[2] / "icons")
QIcon.setThemeSearchPaths([icons_path])
return icons_path

Expand Down
2 changes: 1 addition & 1 deletion tools/check_mne_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
import mne

want_mne_dir = Path(__file__).parent.parent / "mne"
want_mne_dir = Path(__file__).parents[1] / "mne"
got_mne_dir = Path(mne.__file__).parent
want_mne_dir = want_mne_dir.resolve()
got_mne_dir = got_mne_dir.resolve()
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_codemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
parser.add_argument("release_version", type=str)
release_version = parser.parse_args().release_version

out_dir = Path(__file__).parent.parent
out_dir = Path(__file__).parents[1]

# NOTE: ../codemeta.json and ../citation.cff should not be continuously
# updated. Run this script only at release time.
Expand Down
2 changes: 1 addition & 1 deletion tutorials/evoked/20_visualize_evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def custom_func(x):
# compute 3D field maps without a ``trans`` file, but it will only work for
# calculating the field *on the MEG helmet from the MEG sensors*.

subjects_dir = root.parent.parent / "subjects"
subjects_dir = root.parents[1] / "subjects"
trans_file = root / "sample_audvis_raw-trans.fif"

# %%
Expand Down