Skip to content

Discussion: deprecate read_imro #351

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

Open
h-mayorquin opened this issue May 27, 2025 · 1 comment
Open

Discussion: deprecate read_imro #351

h-mayorquin opened this issue May 27, 2025 · 1 comment

Comments

@h-mayorquin
Copy link
Collaborator

h-mayorquin commented May 27, 2025

When discussing this pull request with @chrishalcrow, I’ve been thinking about the following:

Why do we expose read_imro directly?

The private function _read_imro_string is the one actually used by SpikeGLX and Open Ephys, while read_imro is just a wrapper around it that, for a reason that I can't remember, is exposed.

To make read_imro work, we need quite a bit of logic to infer the imDatPrb_pn (probe model number) from imDatPrb_type (probe type). This code is complex and since it was determined through trial and error when we did not have a general table, maybe not very reliable:

imro_table_header_str, *imro_table_values_list, _ = imro_str.strip().split(")")
imro_table_header = tuple(map(int, imro_table_header_str[1:].split(",")))
if imDatPrb_pn is None:
if len(imro_table_header) == 3:
# In older versions of neuropixel arrays (phase 3A), imro tables were structured differently.
probe_serial_number, probe_option, num_contact = imro_table_header
imDatPrb_type = "Phase3a"
elif len(imro_table_header) == 2:
imDatPrb_type, num_contact = imro_table_header
else:
raise ValueError(f"read_imro error, the header has a strange length: {imro_table_header}")
imDatPrb_type = str(imDatPrb_type)
else:
if imDatPrb_pn not in probe_part_number_to_probe_type:
raise NotImplementedError(f"Probe part number {imDatPrb_pn} is not supported yet")
imDatPrb_type = probe_part_number_to_probe_type[imDatPrb_pn]
probe_description = npx_descriptions[imDatPrb_type]

This was necessary when our probe descriptions were based on the probe type. However, now that the official metadata table is organized around imDatPrb_pn (probe part number), this complexity is no longer needed. In other words, this logic doesn’t serve the key functionality anymore, which is reading neuropixel metadata.

Additionally, I’m not sure exposing the functionality to read IMRO tables on their own makes sense. These tables are embedded in the meta file, and trying to read them independently seems like a feature no one has asked for.

Proposed solution:

  1. Move the logic for inferring imDatPrb_pn from imDatPrb_type out of the core function (_read_imro_string) and into the wrapper (read_imro), keeping the complexity at the periphery.
  2. If there is no use for stand-alone reading of imro tables then deprecate read_imro and eventually remove it. This will allow us to eliminate code that is no longer needed now that we can rely on the metadata table.
@h-mayorquin
Copy link
Collaborator Author

Ah, the metadata of spikeglx mentions that imro tables can be created and read independently so the feature might be needed indeed.

I still think that the complexity of figuring out the probe part number from the probe type should be relegated to that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant