Skip to content
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

Minimal fix of SpikeGadgetsRawIO channel ID issue #1496

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

khl02007
Copy link
Contributor

Only the part from #1303 that fixes the channel id issue from #1215
Hopefully this can be merged easily

try:
num_chan_per_chip = int(sconf.attrib["chanPerChip"])
except KeyError:
num_chan_per_chip = 32 # default value for Intan chips
Copy link
Contributor

Choose a reason for hiding this comment

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

Intan also has 64 and 16 channel headstages. Where is this 32 coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most spikegadgets products use 64 channel chips, but a 64 channel chip is just two 32 channel chips sharing an output pin so this is a reasonable default for most cases.

Copy link

@jnjnnjzch jnjnnjzch Nov 30, 2024

Choose a reason for hiding this comment

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

most spikegadgets products use 64 channel chips, but a 64 channel chip is just two 32 channel chips sharing an output pin so this is a reasonable default for most cases.

Again, sorry to interrupt you, @khl02007 ... Is this still work on signal channel level? I mean in practice, does it mean there is no need to change num_chan_per_chip manually into 64 even we know we are using a 64 channel chip, but the header_text xml extracts as sconf.attrib["chanPerChip"] = 32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jnjnnjzch if you are using this product then yes, no need to change num_chan_per_chip. If you're using some other product, I'm actually not sure what would happen here...

Choose a reason for hiding this comment

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

Thanks! we are exactly using this product! And your opinion is validated again by checking the signal synchronization of the extracted trace. Thanks a lot!

Copy link
Contributor

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

Just one error correction to implement and then a discussion on the ephys channels function. I'll also have Alessio be a second pair of eyes, but once the error is fixed I would be fine with this (with a slight preference to tidying up the function either with my comment or switching to better explained for loops).

neo/rawio/spikegadgetsrawio.py Outdated Show resolved Hide resolved
neo/rawio/spikegadgetsrawio.py Outdated Show resolved Hide resolved
@zm711
Copy link
Contributor

zm711 commented Jul 2, 2024

@khl02007,

the only thing preventing this from getting merged from my perspective is using the appropriate error message. Would you like to do that fix?

@zm711
Copy link
Contributor

zm711 commented Jul 10, 2024

@alejoe91, I've added my cleanup to this PR. So I'm okay with this. Do you know the spikegadgets format well enough to double check the logic of this?

ephys_channel_ids_list = []
for hw_channel in range(n_channels_per_chip):
hw_channel_list = [
hw_channel + chip * n_channels_per_chip for chip in range(int(n_total_channels / n_channels_per_chip))
Copy link
Contributor

Choose a reason for hiding this comment

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

will this int(n_total_channels / n_channels_per_chip) works for any n_total_channels numbers.
Do we need an explicit ceil or floor ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be good. Most of the times you'll have increments of 32 channels/chip. So total channels would have to be some multiple of 32. I don't know gadgets well enough, but I guess the problem would be Intan does sell 16 channel headstage so if you were allowed to mix headstage chips then this math wouldn't work. But I think in this case we wait for a user to open an issue so we have mixed headstage data to work with.

@samuelgarcia
Copy link
Contributor

Hi Kyu,
Sorry for the super long delay.
this looks good to me.
I made a very small comments
@zm711 i thinkwe can merge.

@zm711 zm711 merged commit 44f0b2b into NeuralEnsemble:master Jul 24, 2024
3 checks passed
@khl02007
Copy link
Contributor Author

@zm711 @samuelgarcia sorry I forgot about this PR. In general I'm happy to let you guys make any changes to the PR as long as the functionality is preserved (which you seem to have done). Thanks and hopefully we can access spikegadgets rec files via spikeinterface now.

@zm711 zm711 added this to the 13.2 milestone Jul 26, 2024
sconf_channels = np.sum([len(x) for x in sconf])
if sconf_channels < num_ephy_channels:
num_ephy_channels = sconf_channels
if sconf_channels > num_ephy_channels:
Copy link

@jnjnnjzch jnjnnjzch Nov 30, 2024

Choose a reason for hiding this comment

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

Sorry to interrupt, but is that necessarry to add a comparing that num_chan_per_chip > num_ephy_channels?
I got a recording recently and found that num_chan_per_chip is ocasionally read as 339134394.
I manage to extract the xml file and see
<SpikeConfiguration categories="" chanPerChip="339134394" device="intan">
which implies some error...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean the workspace file you use to collect data has chanPerChip="339134394"?

Choose a reason for hiding this comment

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

No, we are using the workspace file with chanPerChip="32", but when we check the output .rec file, it becomes chanPerChip="339134394". We're still trying to figure out what's going on...

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

Successfully merging this pull request may close these issues.

4 participants