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

[Feature]: Selecting channels from OpenEphys data to convert #1023

Open
2 tasks done
rly opened this issue Aug 22, 2024 · 3 comments
Open
2 tasks done

[Feature]: Selecting channels from OpenEphys data to convert #1023

rly opened this issue Aug 22, 2024 · 3 comments

Comments

@rly
Copy link
Contributor

rly commented Aug 22, 2024

What would you like to see added to NeuroConv?

I have an OpenEphys binary data file continuous.dat that has shape (num_samples = 157733308, num_channels = 264). The first 256 channels are neural data. The last 8 channels are analog data (the first one contains received TTL pulses). I want to convert the 256 channels into an ElectricalSeries. Is there a way to configure NeuroConv to do this? Similarly, I would like to convert just channel index 256 to a TimeSeries.

At the JHU workshop, we ran into a related issue where someone was using their last recording channel to record something non-neural. I forget which system. I wasn't sure how to use NeuroConv for this.

Is your feature request related to a problem?

No response

Do you have any interest in helping implement the feature?

Yes.

Code of Conduct

@h-mayorquin
Copy link
Collaborator

Hi, @rly . Can you tell me more about your case? I would like to fix this at the root and it would be useful to document cases when spikeinterface is loading more channels that it should (see here)

Meanwhile, yes, there is a way. Here is example code of how would you do that:

from neuroconv.tools.testing.mock_interfaces import MockRecordingInterface
from neuroconv import ConverterPipe


interface = MockRecordingInterface(num_channels=4)
# Suppose you only want to convert the first two channels

recording = interface.recording_extractor
channel_ids_to_convert = [0, 1]
interface.recording_extractor = recording.select_channels(channel_ids=channel_ids_to_convert)

data_interfaces = [interface]

# data_interfaces.append(other_data_interfaces_of_the_conversion)
 
converter_pipe = ConverterPipe(data_interfaces=data_interfaces)

converter_pipe.run_conversion(**run_conversion_kwargs)

Let me know if it makes sense.

@rly
Copy link
Contributor Author

rly commented Aug 23, 2024

@h-mayorquin thanks! that's useful. The OpenEphys system was set up with 266 channels. In settings.xml, you can kind of see how different channels are grouped by inspecting the channel info:

<?xml version="1.0" encoding="UTF-8"?>

<SETTINGS>
  <INFO>
    <VERSION>0.4.5</VERSION>
    <PLUGIN_API_VERSION>6</PLUGIN_API_VERSION>
    <DATE>25 Jul 2022 15:30:00</DATE>
    <OS>Windows 8.0</OS>
    <MACHINE>DESKTOP-BJV64H9</MACHINE>
  </INFO>
  <SIGNALCHAIN>
    <PROCESSOR name="Sources/Rhythm FPGA" insertionPoint="1" pluginName="Rhythm FPGA"
               pluginType="4" pluginIndex="1" libraryName="Rhythm FPGA" libraryVersion="1"
               isSource="1" isSink="0" NodeId="100">
      <CHANNEL_INFO>
        <CHANNEL name="CH1" number="0" gain="0.19499999284744263"/>
        <CHANNEL name="CH2" number="1" gain="0.19499999284744263"/>
        ...
        <CHANNEL name="CH256" number="255" gain="0.19499999284744263"/>
        <CHANNEL name="ADC1" number="256" gain="0.000152587890625"/>
        <CHANNEL name="ADC2" number="257" gain="0.000152587890625"/>
        <CHANNEL name="ADC3" number="258" gain="0.000152587890625"/>
        <CHANNEL name="ADC4" number="259" gain="0.000152587890625"/>
        <CHANNEL name="ADC5" number="260" gain="0.000152587890625"/>
        <CHANNEL name="ADC6" number="261" gain="0.000152587890625"/>
        <CHANNEL name="ADC7" number="262" gain="0.000152587890625"/>
        <CHANNEL name="ADC8" number="263" gain="0.000152587890625"/>
      </CHANNEL_INFO>
      <CHANNEL name="0" number="0">
        <SELECTIONSTATE param="1" record="1" audio="0"/>
      </CHANNEL>
      <CHANNEL name="1" number="1">
        <SELECTIONSTATE param="1" record="1" audio="0"/>
      </CHANNEL>
      ...
      <CHANNEL name="263" number="263">
        <SELECTIONSTATE param="1" record="1" audio="0"/>
      </CHANNEL>
      <EVENTCHANNEL name="0" number="0"/>
      <EDITOR isCollapsed="0" displayName="Rhythm FPGA" SampleRate="17" SampleRateString="30.0 kS/s"
              LowCut="2.4959882418772361" HighCut="7603.7651218333704" AUXsOn="0"
              ADCsOn="1" AudioOutputL="-1" AudioOutputR="-1" NoiseSlicer="0"
              TTLFastSettle="1" DAC_TTL="0" DAC_HPF="1" DSPOffset="1" DSPCutoffFreq="0.14571292570770725"
              save_impedance_measurements="1" auto_measure_impedances="0" LEDs="1"
              ClockDivideRatio="1">
        <ADCRANGE Channel="0" Range="0"/>
        <ADCRANGE Channel="1" Range="0"/>
        <ADCRANGE Channel="2" Range="0"/>
        <ADCRANGE Channel="3" Range="0"/>
        <ADCRANGE Channel="4" Range="0"/>
        <ADCRANGE Channel="5" Range="0"/>
        <ADCRANGE Channel="6" Range="0"/>
        <ADCRANGE Channel="7" Range="0"/>
      </EDITOR>
    </PROCESSOR>
    ... other processors and settings that do not seem to differ between channels

@h-mayorquin
Copy link
Collaborator

Thanks. JFI. Spikeinterface and neo now are grouping channels that have the same dtype, number of samples and sampling_frequency as a one stream (a buffer stream) we want to change that so streams are logical as discussed here.

Once I have some project that uses openephys I can take some time to fix that : )

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

No branches or pull requests

2 participants