Skip to content

IntanIO problem with one file per stream format #1556

Closed

Description

@Tevin-yue

Which page is the problem on?
IntanIO

What is the problem?
IntanIO reads problematic. The function works well with rhd files but is problematic with dat files. Here are the pictures of the result.
from_raw_data
neo_intan_fig1
neo_intan_fig1_1
When reading .dat file from numpy directly(Fig 1), everything goes well. But the IntanIO seems wrongly loaded data. I doubt whether the data type is causing this problem. [.rhd, uint16; .dat, int16].

Suggestions for fixing the problem
Could you please provide more information about reading .dat files?

Activity

  1. zm711 commented on Sep 16, 2024

    @zm711
    Contributor

    That looks like a scaling error. I'll look into this later today. Which version one file-per channel or one file per stream?

    What script did you run? I want to make sure the scaling happened correctly so I need to see what code you specifically ran to get this :)

  2. self-assigned this
    on Sep 16, 2024
  3. Tevin-yue commented on Sep 18, 2024

    @Tevin-yue
    Author

    The simulated data were generated using Intan version 3.3.1.

    Here is the code:

    import os
    from neo import io
    import matplotlib.pyplot as plt
    
    # Load rhd file
    data_rhd = io.IntanIO(r'F:\MATLAB\RHD_test\RHD_test.rhd')
    raw_chunk_rhd = data_rhd.get_analogsignal_chunk(block_index=0,
                                          stream_index=0,
                                          seg_index=0)
    
    rhd = data_rhd.rescale_signal_raw_to_float(raw_chunk_rhd, stream_index=0)
    plt.plot(rhd[:,3])
    
    #Load dat file
    data_dat = io.IntanIO(r'F:\MATLAB\DAT_test\info.rhd')
    raw_chunk_dat = data_dat.get_analogsignal_chunk(block_index=0,
                                          stream_index=0,
                                          seg_index=0)
    dat= data_dat.rescale_signal_raw_to_float(raw_chunk_dat, stream_index=0)
    plt.plot(dat[:,3])
    
    #Load from numpy
    def load_dat(filename, num_channels):
    	fileinfo = os.stat(filename)
    	num_samples = fileinfo.st_size // (num_channels * 2)
    
    	with open(filename, 'rb') as f:
    		v = np.fromfile(f, dtype=np.int16, count=num_channels * num_samples)
    		v = v.reshape((num_samples, num_channels)).T
    	v = v * 0.195
    	return v
    data_wiht_numpy = load_dat(r'F:\MATLAB\DAT_test\amplifier.dat', 64)
    plt.plot(data_wiht_numpy[3])

    The scale is correct but not the wavefoms with .dat files.

  4. changed the title [-]About IntanIO problem[/-] [+]IntanIO problem with one file per stream format[/+] on Sep 18, 2024
  5. zm711 commented on Sep 18, 2024

    @zm711
    Contributor

    Linked a PR that should fix it!

  6. Tevin-yue commented on Sep 19, 2024

    @Tevin-yue
    Author

    Great!
    Everything is going well. I revised the intanrawio script as you showed.

  7. added this to the 0.14.0 milestone on Oct 1, 2024
  8. modified the milestones: 0.14.0, 0.13.4 on Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions