ofgulban / bvbabel

A lightweight Python library for reading & writing BrainVoyager file formats.
MIT License
19 stars 11 forks source link

Long term suggestion: separate read_header and read_data #21

Open jorievanharen opened 1 year ago

jorievanharen commented 1 year ago

For many instances it could be preferred to read only the header information instead of the head + img information. For example, one might want to know the start / end positions of a vtc file, with this information being in the header there is no need to load gigabytes of data to obtain this. While for many people there is a easy fix (i.e. copy the read_xxx function and remove the data read portion), in the long run it might be good to have a solution to only read header data.

ofgulban commented 1 year ago

Thanks @jorievanharen for the suggestion, I think it is a good idea. Maybe one option can be having and extra flag (e.g. skip_data=True) in the read functions. Hmm, I will think about it. If you think of an alternative solution please let me know :)

jorievanharen commented 1 year ago

Will let you know if I think of an elegant solution. skip_data=True is one way, though, is another parameter (and with these low level functions simplicity is king), and will make things more convoluted (e.g. what will the return be: header, none? Anyway sure there is a way.

ofgulban commented 1 year ago

I guess a more general solution would be separating read_vtc_header from e.g. read_vtc. read_vtc_header can be called within read_vtc.

ofgulban commented 1 year ago

Note for future: I think separating read and write functions would benefit writing the tests too.