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

IntanIO problem with one file per stream format #1556

Closed
Tevin-yue opened this issue Sep 16, 2024 · 4 comments · May be fixed by #1558
Closed

IntanIO problem with one file per stream format #1556

Tevin-yue opened this issue Sep 16, 2024 · 4 comments · May be fixed by #1558
Assignees
Labels

Comments

@Tevin-yue
Copy link

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?

@zm711
Copy link
Contributor

zm711 commented Sep 16, 2024

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 :)

@zm711 zm711 self-assigned this Sep 16, 2024
@Tevin-yue
Copy link
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.

@zm711 zm711 added bug and removed Documentation labels Sep 18, 2024
@zm711 zm711 changed the title About IntanIO problem IntanIO problem with one file per stream format Sep 18, 2024
@zm711
Copy link
Contributor

zm711 commented Sep 18, 2024

Linked a PR that should fix it!

@Tevin-yue
Copy link
Author

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

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

Successfully merging a pull request may close this issue.

2 participants