`group` property is re-enumerated from 0 when slicing a recording with a probe (`split_by`, `remove_channels`) since 0.105
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
Start by reading ChannelSliceRecording.__init__ and the set_probegroup path that calls _set_group_property_based_on_probegroup; also inspect the corresponding re-attachment path in ChannelsAggregationRecording. Use the minimal reproducer to check how slicing and channel removal affect group, then add regression coverage for the reported cases. Done means existing parent group values survive slicing and aggregation rather than being re-enumerated.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Since 0.105.0, slicing a recording that has a probe attached (split_by, select_channels, remove_channels, channel_slice) no longer keeps the group property of the parent: ChannelSliceRecording.__init__ copies the properties and then calls self.set_probegroup(sliced_probegroup), which runs _set_group_property_based_on_probegroup(..., group_mode="auto") and re-enumerates group from 0 over whatever probe/shank/side combinations are still present. The parent's values are overwritten.
Consequences:
split_by("group")returns sub-recordings that all havegroup == 0.- Removing a whole shank renumbers the remaining shanks.
- Any user-defined grouping on a single-shank probe (
set_property("group", ...)) is wiped by any channel removal (everything becomes group 0).
0.103.x and 0.104.1 keep the parent's values. Introduced by #4465 (ChannelSliceRecording re-attaching the sliced probegroup with the new auto mode); the same code is on main.
Minimal reproducer
from spikeinterface.core import generate_recording
rec = generate_recording(num_channels=8, durations=[1.0]) # has a probe attached
rec.set_property("group", [0, 0, 1, 1, 2, 2, 3, 3])
for g, sub in rec.split_by("group").items():
print(g, sub.get_property("group").tolist())
print(rec.remove_channels(rec.channel_ids[[1, 3]]).get_property("group").tolist())
| 0.103.0 / 0.104.1 | 0.105.0 | |
|---|---|---|
split_by("group")[1] |
[1, 1] |
[0, 0] |
split_by("group")[2] |
[2, 2] |
[0, 0] |
split_by("group")[3] |
[3, 3] |
[0, 0] |
remove_channels(2 channels) |
[0, 1, 2, 2, 3, 3] |
[0, 0, 0, 0, 0, 0] |
Realistic probes (384 channels)
import numpy as np
from probeinterface import generate_multi_shank, generate_multi_columns_probe
from spikeinterface.core import generate_recording, aggregate_channels
def summarize(label, rec):
vals, counts = np.unique(rec.get_property("group"), return_counts=True)
print(f" {label:<34} n_ch={rec.get_num_channels():>3} groups={dict(zip(vals.tolist(), counts.tolist()))}")
def make(probe, n):
probe.set_device_channel_indices(np.arange(n))
rec = generate_recording(num_channels=n, durations=[1.0], set_probe=False)
return rec.rename_channels([f"AP{i}" for i in range(n)]), probe
rng = np.random.default_rng(0)
# NP2-like 4-shank probe, 96 channels per shank, grouped by shank
rec, probe = make(generate_multi_shank(num_shank=4, num_columns=2, num_contact_per_column=48, shank_pitch=[250, 0]), 384)
rec = rec.set_probe(probe, group_mode="by_shank") or rec # 0.103 returns a new object, 0.105 is in place
summarize("parent", rec)
for g, sub in rec.split_by("group").items():
summarize(f"split_by[{g}] (first id {sub.channel_ids[0]})", sub)
summarize("remove_channels(10 random)", rec.remove_channels(rec.channel_ids[rng.choice(384, 10, replace=False)]))
summarize("remove_channels(all of shank 2)", rec.remove_channels(rec.channel_ids[192:288]))
# NP1-like single-shank probe, 384 channels, user-defined group = 4 depth bands of 96
rec, probe = make(generate_multi_columns_probe(num_columns=2, num_contact_per_column=192, xpitch=32, ypitch=20), 384)
rec = rec.set_probe(probe) or rec
rec.set_property("group", np.repeat([0, 1, 2, 3], 96))
for g, sub in rec.split_by("group").items():
summarize(f"split_by[{g}] (first id {sub.channel_ids[0]})", sub)
summarize("remove_channels(10 random)", rec.remove_channels(rec.channel_ids[rng.choice(384, 10, replace=False)]))
4-shank probe, set_probe(group_mode="by_shank"):
| operation | 0.103.0 | 0.105.0 |
|---|---|---|
| parent | {0:96, 1:96, 2:96, 3:96} |
same |
split_by("group")[1] (AP96…) |
{1:96} |
{0:96} |
split_by("group")[2] (AP192…) |
{2:96} |
{0:96} |
split_by("group")[3] (AP288…) |
{3:96} |
{0:96} |
remove_channels (10 random) |
{0:92, 1:94, 2:94, 3:94} |
same (all shanks still present) |
remove_channels (entire shank 2) |
{0:96, 1:96, 3:96} |
{0:96, 1:96, 2:96} – shank 3 relabelled 2 |
aggregate_channels(split_by(...)) |
{0..3: 96} |
same |
Single-shank probe, user-defined groups:
| operation | 0.103.0 | 0.105.0 |
|---|---|---|
split_by("group")[1..3] |
{1:96}, {2:96}, {3:96} |
all {0:96} |
remove_channels (10 random) |
{0:92, 1:94, 2:94, 3:94} |
{0:374} – grouping gone |
(macOS arm64, Python 3.12, numpy 2.5.3, probeinterface 0.4.0; the 0.105 column is identical on linux x86_64 in the aind-ephys-pipeline-base:1.4.0 image.)
Real-world impact
aind-ephys-pipeline 1.4.0 pins SI 0.105 in its images. aind-ephys-job-dispatch does recording.split_by("group") and dumps each slice to JSON; every slice now reports group 0. aind-units-nwb builds the electrode-group label from that property, so all shanks of a NP2 4-shank probe become <probe>_group0, while the electrodes table written from the full recording still has _group0.._group3. The units export then fails on the first channel of shank 1 (KeyError: 'AP48'). Workaround PR: AllenNeuralDynamics/aind-units-nwb#32 (derive the label from the recording name instead of the property).
Suggested fix
When ChannelSliceRecording (and ChannelsAggregationRecording) re-attach the sliced/aggregated probegroup, keep an existing group property instead of overwriting it, and only derive group from the probegroup when the parent had none. Alternatively copy_metadata could run after set_probegroup, so user values win.
- Ngôn ngữ chính
- Python
- Star
- 858
- Fork
- 281
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SpikeInterface/spikeinterface
-
testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SpikeInterface/spikeinterface#4756 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SpikeInterface/spikeinterface#4510 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Implement filtering by banks of channels to reduce RAMCó thể đã có người làm @h-mayorquin đã nhận hôm nay. Đang mởpreprocessing
SpikeInterface/spikeinterface#4837 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Extend `TimeSeriesExecutor` to `num_chunks_per_job`Có thể đã có người làm @samuelgarcia đã nhận 1 ngày trước. Đang mởconcurrency
SpikeInterface/spikeinterface#4831 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement motion correction
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 65/100
SpikeInterface/spikeinterface#4829 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của SpikeInterface/spikeinterface
Issue tương tự
-
area/install reliability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
FluidNumerics/fluid-walk-blocker#191 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
TransformerLensOrg/TransformerLens#1868 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
climate-analytics-lab/jax-gcm#1057 ·
Maintainer thường phản hồi trong vòng 1 ngày