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

Adding large segment to BinWriter object #30

Open
ephathaway opened this issue Apr 8, 2020 · 2 comments
Open

Adding large segment to BinWriter object #30

ephathaway opened this issue Apr 8, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@ephathaway
Copy link
Member

When I attempt to add a block of signals larger than about 2000000 samples (for 256 channels) to a BinWriter object, I get this error:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-7-6fddd83ebbc4> in <module>
      1 B = BinWriter(sampling_rate=sr)
----> 2 B.add_block(signals.astype(np.float32))
      3 W = Writer(join('examples', 'sample.mff'))
      4 startdatetime = datetime.strptime('1984-02-18T14:00:10.000000+0100',
      5         "%Y-%m-%dT%H:%M:%S.%f%z")

~/Repositories/mffpy/mffpy/bin_writer.py in add_block(self, data, offset_us)
     99             )
    100         # Write header/data to stream, and add an epochs block
--> 101         write_header_block(self.stream, self.header)
    102         self.append(data.tobytes())
    103         self._add_block_to_epochs(num_samples, offset_us=offset_us)

~/Repositories/mffpy/mffpy/header_block.py in write_header_block(fp, hdr)
    130     """write HeaderBlock `hdr` to file pointer `fp`"""
    131     fp.write(struct.pack('4i',
--> 132                          1, hdr.header_size, hdr.block_size, hdr.num_channels))
    133     num_samples = (hdr.block_size//hdr.num_channels) // 4
    134     # Write channel offset into the data block

error: 'i' format requires -2147483648 <= number <= 2147483647

I am able to work around this error for now by splitting the signals into multiple block and adding the blocks one at a time with no gap in time between them. I run into this error often enough that it would be good to look into how we could allow adding of larger blocks of EEG to a BinWriter object.

@jusjusjus
Copy link
Collaborator

Can this request be closed?

@ephathaway
Copy link
Member Author

@jusjusjus I think this is still worth solving. Basically we can't write a block of data of a certain size. I think we should at least throw out a message stating the maximum size of a block that we can write when this error occurs.

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

No branches or pull requests

2 participants