Skip to content

IO for Intan RHD2000 files #305

Closed
Closed

Description

@danielmk

Hello,
is anyone currently working on a neo IO for Intan RHD2000 files? If not, I would consider starting to work on it.

Activity

  1. apdavison commented on Apr 3, 2017

    @apdavison
    Member

    Not to my knowledge.

  2. added this to the future milestone on Apr 3, 2017
  3. alejoe91 commented on May 5, 2017

    @alejoe91
    Contributor

    Hi,

    We have developed a pyintan class that parses RHS (not RHD for now but the extension should be straightforward, you probably just need to remove the stimulation part).
    We haven't converted it to neo directly because we wanted to keep it more flexible.
    Anyways the conversion should be easy as we have neo-like classes such as Analogsignals, DigitalSignals, etc..

    The code is here:
    https://github.com/CINPLA/expipe-io-neuro/blob/dev/expipe_io_neuro/intan/pyintan.py

    I hope this helps!
    Alessio

  4. danielmk commented on May 5, 2017

    @danielmk
    Author

    Hey Alessio,

    thank you for sharing your code. To read rhd files there is also a script provided on the intan website.
    I will also look into your code to see which one may be easier to convert to neo.

  5. johntukker commented on Jun 30, 2017

    @johntukker

    hi Daniel, I'm also interested in this, currently trying a 'workaround' which is to use the intan converter to NeuroExplorer format (available at http://intantech.com/downloads.html), and then using the NeuroExplorerIO. I just tried this today, still having some trouble with the NeuroExplorer IO possibly related to Python version, so cannot say yet that it's a good idea, but maybe worth considering (perhaps you have more luck/Python skills). cheers, John

  6. danielmk commented on Jul 6, 2017

    @danielmk
    Author

    Hello John,

    I am still in the stage of understanding the neo interface and in particular the baseio to do this properly. I looked into both the python script from intan as well as Alessio's solution. Both do a fine job at loading files and it would be fairly straight forward to transform the result into neo objects. Implementing the lazy and cascade options however, would require a lot more effort from what I can tell. I think fully implementing a workaround that depends on another io should of course work but is not a good idea in the neo framework. I am still looking into it.

    Best,
    Daniel

  7. samuelgarcia commented on Jul 6, 2017

    @samuelgarcia
    Contributor

    I am refactoring neo.io into neo.rawio.

    This is work in progress but I guess that writting an IO with this new low level API is much simpler for a dev.

    If you code something in neo.rawio the neo.io is automatic and there are no need to code lazy and cascade stuff!

    Have a look here #355 and #354.

  8. bionicinnovations commented on Oct 25, 2018

    @bionicinnovations

    Hi,

    We have developed a pyintan class that parses RHS (not RHD for now but the extension should be straightforward, you probably just need to remove the stimulation part).
    We haven't converted it to neo directly because we wanted to keep it more flexible.
    Anyways the conversion should be easy as we have neo-like classes such as Analogsignals, DigitalSignals, etc..

    The code is here:
    https://github.com/CINPLA/expipe-io-neuro/blob/dev/expipe_io_neuro/intan/pyintan.py

    I hope this helps!
    Alessio

    Hi Alessio,
    Im trying to read intan rhs files, but I cant work it out (new to Python). I have no idea how to implement your script you generously provided. Would you mind giving me some instructions on how to use your code to extract data from an Intan .rhs file? I'd be super grateful!!
    Cheers
    Jason

  9. samuelgarcia commented on Oct 25, 2018

    @samuelgarcia
    Contributor

    I will have a look at this code to write the neo.rawio.intrawio.
    For the moment I need a file to start the work.

  10. alejoe91 commented on Oct 25, 2018

    @alejoe91
    Contributor

    Hi Alessio,
    Im trying to read intan rhs files, but I cant work it out (new to Python). I have no idea how to implement your script you generously provided. Would you mind giving me some instructions on how to use your code to extract data from an Intan .rhs file? I'd be super grateful!!
    Cheers
    Jason

    Hi @bionicinnovations !

    I setup a python package to quickly load intan files. You can find it here: https://github.com/alejoe91/pyintan

    It's not tested, but it gives quick access to the recordings.

    @samuelgarcia I have some .rhs files that I could share them with you. If you are interested write me an email: [email protected]

    Cheers,
    Alessio

  11. bionicinnovations commented on Oct 25, 2018

    @bionicinnovations

    Thanks Alessio,
    I wrote to Intan after my message to you and they have just submitted files for reading rhs files! I am yet to work out how to implement it, but the timing is hilarious!

    http://www.intantech.com/files/load_intan_rhs_format.zip

    If I can't work out what to do next, I'll send you an email. Thanks again!!

    Cheers
    Jason

  12. samuelgarcia commented on Oct 26, 2018

    @samuelgarcia
    Contributor

    I was aware of theses intan script. You can have them here.

    I still plan to implement intan in neo.rawio. This will be uselfull for people who want to sort spikes with tridesclous.

  13. bionicinnovations commented on Oct 29, 2018

    @bionicinnovations

    Thanks Alessio, pyintan works great!! ;-)

  14. bionicinnovations commented on Oct 29, 2018

    @bionicinnovations
  15. samuelgarcia commented on Nov 5, 2018

    @samuelgarcia
    Contributor

    @bionicinnovations @alejoe91 @johntukker @danielmuellernai

    I have done more or less the base for the new intanIO.
    See here: https://github.com/samuelgarcia/python-neo/tree/intanrawio

    I plan to read both RHD and RHS in the same IO wich is a bit chalenge but there is a strong overlap between the 2 file format.
    pyintan deal only with rhs.
    With official code provide by intan, there are 2 different zip archive (one for each format) whihch have a very string overlap. Bad pratice!! The official code provide by intan is not efficient at all. They don't use memmap and preallocate everything.

    This version should be faster and **do not pre allocate any array. Chunk are read on demand.

    Done:

    • read header for rhs
    • read signal by time slice
    • read signal channel slice

    To be done:

    • deal with units/gain/offset: should be easy
    • deal with digital port : (make them as event ???)
    • do the RDH header wich have 3 diffrents version (1.0, to 1.3)
    • do the neo.io class : easy.

    @alejoe91 I have a strong problem with the only file I tested bipolarstim_5uA_170418_192008.rhs. They is some a gap in timestamp which means that there is probably a data packet lost.
    In short the timestamp vector is not continuous.
    How are you dealing with this in pyintan ?
    See line 60 in my code. If you uncomment it you raise error.

            timestamp = self._raw_data['timestamp'].flatten()
            assert np.all(np.diff(timestamp)==1)

    In any case I strongly need a rhd file for starting continuing the job.
    Does anyone have this ?

    If anyone have time to test it : install the working branch and do this:

    from neo.rawio.intanrawio import IntanRawIO
    
    filename = 'bipolarstim_5uA_170418_192008.rhs'
    
    reader = IntanRawIO(filename=filename)
    reader.parse_header()
    print(reader)
    
    raw_sigs = reader.get_analogsignal_chunk(block_index=0, seg_index=0, i_start=None, i_stop=None, channel_indexes=None)
    print(raw_sigs.shape)
    
    raw_sigs = reader.get_analogsignal_chunk(block_index=0, seg_index=0, i_start=64, i_stop=567, channel_indexes=None)
    print(raw_sigs.shape)
    
    raw_sigs = reader.get_analogsignal_chunk(block_index=0, seg_index=0, i_start=64, i_stop=567, channel_indexes=[1, 5, 8])
    print(raw_sigs.shape)
  16. samuelgarcia commented on Nov 6, 2018

    @samuelgarcia
    Contributor

    @alejoe91 do take in account previous comment about timestamp. It was a bug in previous comit.

  17. samuelgarcia commented on Nov 7, 2018

    @samuelgarcia
    Contributor

    Implemented in #593
    Need rdh and rhs files at gnode for CI before merging.

  18. samuelgarcia commented on Nov 7, 2018

    @samuelgarcia
    Contributor

    The latest commit:

    • also contain RHD for 3 versions (not tested at all because I don't have files).
    • the neo.io.IntaIO class
    • units and rescaling.
    from neo.io import IntanIO
    
    filename = 'bipolarstim_5uA_170418_192008.rhs'
    
    reader = IntanIO(filename=filename)
    seg = reader.read_segment()
    
    for anasig in seg.analogsignals:
        print(anasig.name, anasig.shape, anasig.units)
        print(anasig.annotations['channel_names'])
    
    sig = seg.analogsignals[0].magnitude[:, 0]
    times = seg.analogsignals[0].times
    
    fig, ax = plt.subplots()
    ax.plot(times, sig)
    ax.set_title( seg.analogsignals[0].annotations['channel_names'][0])
    ax.set_ylabel('uV')
    plt.show()
    Channel bundle (B-000,B-001,B-002,B-003,B-004,B-005,B-006,B-007,B-008,B-009,B-010,B-011,B-012,B-013,B-014,B-015)  (1130496, 16) 1.0 uV
    ['B-000' 'B-001' 'B-002' 'B-003' 'B-004' 'B-005' 'B-006' 'B-007' 'B-008'
     'B-009' 'B-010' 'B-011' 'B-012' 'B-013' 'B-014' 'B-015']
    Channel bundle (ANALOG-IN-1)  (1130496, 1) 1.0 V
    ['ANALOG-IN-1']
    Channel bundle (B-000_STIM,B-001_STIM,B-002_STIM,B-003_STIM,B-004_STIM,B-005_STIM,B-006_STIM,B-007_STIM,B-008_STIM,B-009_STIM,B-010_STIM,B-011_STIM,B-012_STIM,B-013_STIM,B-014_STIM,B-015_STIM)  (1130496, 16) 1.0 dimensionless
    ['B-000_STIM' 'B-001_STIM' 'B-002_STIM' 'B-003_STIM' 'B-004_STIM'
     'B-005_STIM' 'B-006_STIM' 'B-007_STIM' 'B-008_STIM' 'B-009_STIM'
     'B-010_STIM' 'B-011_STIM' 'B-012_STIM' 'B-013_STIM' 'B-014_STIM'
     'B-015_STIM']
    

    @bionicinnovations : could you confirm that this figure for first channel on file bipolarstim_5uA_170418_192008.rhs looks OK:

    figure_1

  19. modified the milestones: future, 0.7.0 on Nov 7, 2018
  20. bionicinnovations commented on Nov 8, 2018

    @bionicinnovations

    Hi Samuel, I don't have bipolarstim_5uA_170418_192008.rhs so I can't test it.

    The file I sent you was called: pul04_180727_163010.rhs, there is the link to that file:
    https://drive.google.com/file/d/1w7big3U3Xxbt-88B0tFhR_fOITIXKGxp/view?usp=sharing

    when I use my file and substitute sig as follows:

    sig = seg.analogsignals[1].magnitude[:, 0] # I use the second channel [1], not the first [0], I get this output:

    figure_1

  21. bionicinnovations commented on Nov 8, 2018

    @bionicinnovations

    I also get this output which I think reflects my Intan hardware:

    Channel bundle (B-000,B-001,B-002,B-003,B-004,B-005,B-006,B-007,B-008,B-009,B-010,B-011,B-012,B-013,B-014,B-015,B-016,B-017,B-018,B-019,B-020,B-021,B-022,B-023,B-024,B-025,B-026,B-027,B-028,B-029,B-030,B-031) (517120, 32) 1.0 uV
    ['B-000' 'B-001' 'B-002' 'B-003' 'B-004' 'B-005' 'B-006' 'B-007' 'B-008'
    'B-009' 'B-010' 'B-011' 'B-012' 'B-013' 'B-014' 'B-015' 'B-016' 'B-017'
    'B-018' 'B-019' 'B-020' 'B-021' 'B-022' 'B-023' 'B-024' 'B-025' 'B-026'
    'B-027' 'B-028' 'B-029' 'B-030' 'B-031']
    Channel bundle (ANALOG-IN-1,ANALOG-IN-2,ANALOG-IN-3) (517120, 3) 1.0 V
    ['ANALOG-IN-1' 'ANALOG-IN-2' 'ANALOG-IN-3']
    Channel bundle (ANALOG-OUT-1,ANALOG-OUT-4) (517120, 2) 1.0 V
    ['ANALOG-OUT-1' 'ANALOG-OUT-4']
    Channel bundle (B-000_STIM,B-001_STIM,B-002_STIM,B-003_STIM,B-004_STIM,B-005_STIM,B-006_STIM,B-007_STIM,B-008_STIM,B-009_STIM,B-010_STIM,B-011_STIM,B-012_STIM,B-013_STIM,B-014_STIM,B-015_STIM,B-016_STIM,B-017_STIM,B-018_STIM,B-019_STIM,B-020_STIM,B-021_STIM,B-022_STIM,B-023_STIM,B-024_STIM,B-025_STIM,B-026_STIM,B-027_STIM,B-028_STIM,B-029_STIM,B-030_STIM,B-031_STIM) (517120, 32) 1.0 dimensionless
    ['B-000_STIM' 'B-001_STIM' 'B-002_STIM' 'B-003_STIM' 'B-004_STIM'
    'B-005_STIM' 'B-006_STIM' 'B-007_STIM' 'B-008_STIM' 'B-009_STIM'
    'B-010_STIM' 'B-011_STIM' 'B-012_STIM' 'B-013_STIM' 'B-014_STIM'
    'B-015_STIM' 'B-016_STIM' 'B-017_STIM' 'B-018_STIM' 'B-019_STIM'
    'B-020_STIM' 'B-021_STIM' 'B-022_STIM' 'B-023_STIM' 'B-024_STIM'
    'B-025_STIM' 'B-026_STIM' 'B-027_STIM' 'B-028_STIM' 'B-029_STIM'
    'B-030_STIM' 'B-031_STIM']

    It took me a while how to install the package etc, I am new at all this, but I got it to work (and learned lots along the way!)

  22. bionicinnovations commented on Nov 8, 2018

    @bionicinnovations

    Also, not sure why, but I couldn't get your first script to work properly because I wasn't specifying the right channel indexes (and I didnt know what they were supposed to be). Not sure if that's helpful info or not!)

    Thanks for your hard work!

  23. samuelgarcia commented on Nov 22, 2018

    @samuelgarcia
    Contributor

    Close by #593

  24. ChauhanT commented on Sep 22, 2023

    @ChauhanT

    Hi,

    I am trying to use this reader (neo.io.IntanIO) to read output from an RHD2164 in the "one channel per file" format but I see zero time points. The output is in a folder with several .dat files and an info.rhd file. I am guessing I get zero time-points because only the .rhd file is read and the .dat files are left out. Am I right? Is there some sort of an option to read this "one channel per file" format ?

    Thank you!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions