You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For multiple probe displays I get an issue trying to use figrid specifically, if I use many axes, some of them do not keep the same scale. It changes according to the number of axes, for example here with N=11 and 13.
At first I thought it was because of the labels, so I did plot the same insertion over and over again. Still the same.
The get_coords is also fine, the diffs are constant so I think the issue may lie with figrid.
Have you ever encountered this and found a fix ?
# %%
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from ibl_style.style import figure_style
from ibl_style.utils import MM_TO_INCH, get_coords
import figrid as fg
import ephys_atlas.data
import brainbox.ephys_plots
import iblatlas.atlas
import iblatlas.plots
ba = iblatlas.atlas.AllenAtlas()
regions = iblatlas.atlas.BrainRegions()
figure_style()
FIG_SIZE = (13, 6)
pids = ephys_atlas.data.BENCHMARK_PIDS
n_pids = len(pids)
path_features = Path('/Users/olivier/Documents/datadisk/Data/paper-ephys-atlas/ephys-atlas-decoding/features/2024_W50') # mac
path_features = Path('/mnt/s0/ephys-atlas-decoding/features/2024_W50') # parede
df_voltage = pd.read_parquet(path_features / 'raw_ephys_features_denoised.pqt')
ax_ratios = np.r_[np.ones(n_pids), 2, 8]
# Make a double column figure
fig = plt.figure(figsize=FIG_SIZE)
# Get the dimensions of the figure in mm
width, height = fig.get_size_inches() / MM_TO_INCH
xspans = get_coords(width, ratios=ax_ratios, space=15, pad=5, span=(0, 1))
yspans = get_coords(height, ratios=[1], space=[20], pad=5, span=(0, 1))
ax = [fg.place_axes_on_grid(fig, xspan=xspans[i], yspan=yspans[0]) for i in range(len(ax_ratios))]
ba.plot_top(ax=ax[-1])
for i, pid in enumerate(pids):
df_pid = df_voltage.loc[pids[0]]
depth = df_pid.groupby('axial_um').agg(atlas_id=pd.NamedAgg(column='atlas_id', aggfunc='first')).reset_index()
brainbox.ephys_plots.plot_brain_regions(
depth['atlas_id'].values, channel_depths=depth['axial_um'].values,
brain_regions=regions, display=True, ax=ax[i])
ax[-1].plot(df_pid['x'].values * 1e6, df_pid['y'].values * 1e6, '.', color='r', markersize=2)
ax[-1].plot(df_pid['x'].values[-1] * 1e6, df_pid['y'].values[-1] * 1e6, '*', color='k', markersize=2)
for i in range(13, 15):
ax[i].axis('off')
def adjust_figure(fig):
# Remove 7.5 mm of whitespace around figure in all directions
adjust = 7.5
# Depending on the location of axis labels leave a bit more space
extra = 5
width, height = fig.get_size_inches() / MM_TO_INCH
fig.subplots_adjust(top=1-adjust/height, bottom=(adjust + extra)/height,
left=(adjust + extra)/width, right=1-adjust/width)
adjust_figure(fig)
The text was updated successfully, but these errors were encountered:
Hello,
For multiple probe displays I get an issue trying to use figrid specifically, if I use many axes, some of them do not keep the same scale. It changes according to the number of axes, for example here with N=11 and 13.
At first I thought it was because of the labels, so I did plot the same insertion over and over again. Still the same.
The get_coords is also fine, the diffs are constant so I think the issue may lie with figrid.
Have you ever encountered this and found a fix ?
The text was updated successfully, but these errors were encountered: